Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
[LibOS/regression] Add test for host root FS
Browse files Browse the repository at this point in the history
Graphene supports a special "root FS" parameter in the manifest:
"fs.root". This commit adds a test that uses this parameter.
  • Loading branch information
dimakuv committed Dec 18, 2019
1 parent 05cc509 commit b8a955c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
31 changes: 31 additions & 0 deletions LibOS/shim/test/regression/host_root_fs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <dirent.h>
#include <stdio.h>

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;
}
16 changes: 16 additions & 0 deletions LibOS/shim/test/regression/host_root_fs.manifest.template
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions LibOS/shim/test/regression/test_libos.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def test_021_getdents_large_dir(self):

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")
Expand Down

0 comments on commit b8a955c

Please sign in to comment.