Forráskód Böngészése

[LibOS] Fix C++ tests support

This commit:
* Fixes compilation and execution errors for C++ programs in LibOS/shim/test/native.
* Adds a C++ regression test.
Chia-Che Tsai 4 éve
szülő
commit
728d16aca6

+ 2 - 0
LibOS/shim/test/Makefile

@@ -17,6 +17,8 @@ CC = gcc
 CXX = g++
 CFLAGS 	= -Wall -std=gnu99
 CFLAGS-debug = $(CFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
+CXXFLAGS = -Wall -std=c++14
+CXXFLAGS-debug = $(CXXFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
 LDFLAGS	=
 LDFLAGS-debug = $(LDFLAGS) -L$(SHIMDIR) -L$(PALDIR) -Wl,-rpath-link=$(abspath $(RUNTIME))
 

+ 1 - 1
LibOS/shim/test/native/Makefile

@@ -17,7 +17,7 @@ $(c_executables): %: %.c
 
 $(cxx_executables): %: %.cpp
 	@echo [ $@ ]
-	@$(CC) $(CFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
+	@$(CXX) $(CXXFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
 	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
 
 static: %: %.c

+ 8 - 0
LibOS/shim/test/regression/00_bootstrap.py

@@ -23,6 +23,14 @@ regression.add_check(name="Five Arguments Given",
 rv = regression.run_checks()
 if rv: sys.exit(rv)
 
+regression = Regression(loader, "bootstrap-c++")
+
+regression.add_check(name="Basic Bootstrapping (C++)",
+    check=lambda res: "User Program Started" in res[0].out)
+
+rv = regression.run_checks()
+if rv: sys.exit(rv)
+
 # Running Exec
 regression = Regression(loader, "exec")
 

+ 1 - 1
LibOS/shim/test/regression/Makefile

@@ -24,7 +24,7 @@ $(c_executables): %: %.c
 
 $(cxx_executables): %: %.cpp
 	@echo [ $@ ]
-	@$(CC) $(CFLAGS) -o $@ $< \
+	@$(CXX) $(CXXFLAGS) -o $@ $< \
 	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
 
 bootstrap_static: %: %.c

+ 7 - 0
LibOS/shim/test/regression/bootstrap-c++.cpp

@@ -0,0 +1,7 @@
+#include <iostream>
+
+int main()
+{
+    std::cout << "User Program Started" << std::endl;
+    return 0;
+}

+ 18 - 4
LibOS/shim/test/regression/manifest.template

@@ -1,11 +1,19 @@
 loader.preload = file:../../src/libsysdb.so
-loader.env.LD_LIBRARY_PATH = /lib
+loader.env.LD_LIBRARY_PATH = /lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu
 loader.debug_type = none
 loader.syscall_symbol = syscalldb
 
-fs.mount.lib.type = chroot
-fs.mount.lib.path = /lib
-fs.mount.lib.uri = file:../../../../Runtime
+fs.mount.graphene_lib.type = chroot
+fs.mount.graphene_lib.path = /lib
+fs.mount.graphene_lib.uri = file:../../../../Runtime
+
+fs.mount.host_lib.type = chroot
+fs.mount.host_lib.path = /lib/x86_64-linux-gnu
+fs.mount.host_lib.uri = file:/lib/x86_64-linux-gnu
+
+fs.mount.host_usr_lib.type = chroot
+fs.mount.host_usr_lib.path = /usr/lib/x86_64-linux-gnu
+fs.mount.host_usr_lib.uri = file:/usr/lib/x86_64-linux-gnu
 
 fs.mount.bin.type = chroot
 fs.mount.bin.path = /bin
@@ -18,5 +26,11 @@ net.rules.2 = 0.0.0.0:0-65535:127.0.0.1:8000
 
 sgx.trusted_files.ld = file:../../../../Runtime/ld-linux-x86-64.so.2
 sgx.trusted_files.libc = file:../../../../Runtime/libc.so.6
+sgx.trusted_files.libdl = file:../../../../Runtime/libdl.so.2
+sgx.trusted_files.libm = file:../../../../Runtime/libm.so.6
+sgx.trusted_files.libpthread = file:../../../../Runtime/libpthread.so.0
+sgx.trusted_files.libgcc_s = file:/lib/x86_64-linux-gnu/libgcc_s.so.1
+sgx.trusted_files.libstdcxx = file:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
+
 sgx.trusted_files.victim = file:exec_victim
 sgx.trusted_children.victim = file:exec_victim.sig