diff --git a/LibOS/shim/test/regression/host_root_fs.c b/LibOS/shim/test/regression/host_root_fs.c new file mode 100644 index 00000000..605dba18 --- /dev/null +++ b/LibOS/shim/test/regression/host_root_fs.c @@ -0,0 +1,31 @@ +#include +#include + +static int showdir(char* path) { + struct dirent* de; + + DIR* dir = opendir(path); + if (!dir) { + printf("Could not open directory `%s`\n", path); + return 1; + } + + printf("Contents of directory `%s`:\n", path); + while ((de = readdir(dir))) + printf(" %s\n", de->d_name); + printf("\n"); + + closedir(dir); + return 0; +} + +int main(int argc, char** argv) { + if (showdir("/")) + return 1; + + if (showdir("/var/")) + return 1; + + puts("Test was successful"); + return 0; +} diff --git a/LibOS/shim/test/regression/host_root_fs.manifest.template b/LibOS/shim/test/regression/host_root_fs.manifest.template new file mode 100644 index 00000000..9f0da6e0 --- /dev/null +++ b/LibOS/shim/test/regression/host_root_fs.manifest.template @@ -0,0 +1,16 @@ +loader.preload = file:../../src/libsysdb.so +loader.env.LD_LIBRARY_PATH = /lib +loader.debug_type = none +loader.syscall_symbol = syscalldb + +fs.root.type = chroot +fs.root.path = / +fs.root.uri = file:/ + +fs.mount.graphene_lib.type = chroot +fs.mount.graphene_lib.path = /lib +fs.mount.graphene_lib.uri = file:../../../../Runtime + +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 diff --git a/LibOS/shim/test/regression/test_libos.py b/LibOS/shim/test/regression/test_libos.py index 9b87f4f8..c4dd9537 100644 --- a/LibOS/shim/test/regression/test_libos.py +++ b/LibOS/shim/test/regression/test_libos.py @@ -251,6 +251,10 @@ class TC_30_Syscall(RegressionTestCase): self.assertIn('Success!', stdout) + def test_022_host_root_fs(self): + stdout, _ = self.run_binary(['host_root_fs']) + self.assertIn('Test was successful', stdout) + def test_030_fopen(self): if os.path.exists("tmp/filecreatedbygraphene"): os.remove("tmp/filecreatedbygraphene")