diff --git a/test/runner/defs.bzl b/test/runner/defs.bzl index e3d1e6210..99f24f43b 100644 --- a/test/runner/defs.bzl +++ b/test/runner/defs.bzl @@ -72,7 +72,7 @@ def _syscall_test( iouring = False, container = None, one_sandbox = True, - use_fusefs = False, + fusefs = False, **kwargs): # Prepend "runsc" to non-native platform names. full_platform = platform if platform == "native" else "runsc_" + platform @@ -85,7 +85,7 @@ def _syscall_test( name += "_overlay" if network != "none": name += "_" + network + "net" - if use_fusefs: + if fusefs: name += "_fuse" # Apply all tags. @@ -134,7 +134,7 @@ def _syscall_test( "--platform-support=" + platform_support, "--network=" + network, "--use-tmpfs=" + str(use_tmpfs), - "--use-fusefs=" + str(use_fusefs), + "--fusefs=" + str(fusefs), "--file-access=" + file_access, "--overlay=" + str(overlay), "--add-host-communication=" + str(add_host_communication), @@ -167,7 +167,7 @@ def all_platforms(): def syscall_test( test, use_tmpfs = False, - use_fusefs = False, + add_fusefs = False, add_overlay = False, add_host_communication = False, add_hostinet = False, @@ -183,6 +183,7 @@ def syscall_test( Args: test: the test target. use_tmpfs: use tmpfs in the defined tests. + add_fusefs: add a fusefs test. add_overlay: add an overlay test. add_host_communication: setup UDS and pipe external communication for tests. add_hostinet: add a hostinet test. @@ -268,12 +269,12 @@ def syscall_test( file_access = "shared", **kwargs ) - if use_fusefs: + if add_fusefs: _syscall_test( test = test, platform = default_platform, use_tmpfs = True, - use_fusefs = True, + fusefs = True, add_host_communication = add_host_communication, tags = platforms.get(default_platform, []) + tags, debug = debug, diff --git a/test/runner/fuse/BUILD b/test/runner/fuse/BUILD index 023bb9513..cb4c185a1 100644 --- a/test/runner/fuse/BUILD +++ b/test/runner/fuse/BUILD @@ -11,5 +11,6 @@ go_binary( "//runsc/specutils", "@com_github_hanwen_go_fuse_v2//fs:go_default_library", "@com_github_hanwen_go_fuse_v2//fuse:go_default_library", + "@org_golang_x_sys//unix:go_default_library", ], ) diff --git a/test/runner/fuse/fuse.go b/test/runner/fuse/fuse.go index df8299296..6297b84d2 100644 --- a/test/runner/fuse/fuse.go +++ b/test/runner/fuse/fuse.go @@ -23,6 +23,7 @@ import ( "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" + "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/log" "gvisor.dev/gvisor/runsc/specutils" ) @@ -34,20 +35,20 @@ func main() { os.Exit(1) } opts := &fuse.MountOptions{DirectMount: true, Debug: true, Options: []string{"default_permissions"}} - rawFS := fs.NewNodeFS(loopbackRoot, &fs.Options{Logger: golog.Default()}) + rawFS := fs.NewNodeFS(loopbackRoot, &fs.Options{NullPermissions: true, Logger: golog.Default()}) server, err := fuse.NewServer(rawFS, "/tmp", opts) if err != nil { log.Warningf("could not create fuse server: %v", err) os.Exit(1) } + // Clear umask so that it doesn't affect the mode bits twice. + unix.Umask(0) go server.Serve() defer func() { server.Unmount() server.Wait() }() - // TODO(b/267200022): Investigate why gofuse pollHack sometimes fails with - // EINTR. if _, _, err := specutils.RetryEintr(func() (uintptr, uintptr, error) { if err := server.WaitMount(); err != nil { return 0, 0, err diff --git a/test/runner/main.go b/test/runner/main.go index 0974eb394..9671e9713 100644 --- a/test/runner/main.go +++ b/test/runner/main.go @@ -49,7 +49,7 @@ var ( platformSupport = flag.String("platform-support", "", "String passed to the test as GVISOR_PLATFORM_SUPPORT environment variable. Used to determine which syscall tests are expected to work with the current platform.") network = flag.String("network", "none", "network stack to run on (sandbox, host, none)") useTmpfs = flag.Bool("use-tmpfs", false, "mounts tmpfs for /tmp") - useFUSEfs = flag.Bool("use-fusefs", false, "mounts a fusefs for /tmp") + fusefs = flag.Bool("fusefs", false, "mounts a fusefs for /tmp") fileAccess = flag.String("file-access", "exclusive", "mounts root in exclusive or shared mode") overlay = flag.Bool("overlay", false, "wrap filesystem mounts with writable tmpfs overlay") container = flag.Bool("container", false, "run tests in their own namespaces (user ns, network ns, etc), pretending to be root. Implicitly enabled if network=host, or if using network namespaces") @@ -378,7 +378,7 @@ func runTestCaseRunsc(testBin string, tc *gtest.TestCase, args []string, t *test args = tc.Args() } var spec *specs.Spec - if *useFUSEfs { + if *fusefs { fuseServer, err := testutil.FindFile("test/runner/fuse/fuse") if err != nil { fatalf("cannot find fuse: %v", err) @@ -433,7 +433,7 @@ func runTestCaseRunsc(testBin string, tc *gtest.TestCase, args []string, t *test testTmpDir = "/tmp" } } - if *useFUSEfs { + if *fusefs { // In fuse tests, the fuse server forwards all filesystem ops from /tmp // to /fuse. spec.Mounts = append(spec.Mounts, specs.Mount{ diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD index 05a370854..0cdaa1636 100644 --- a/test/syscalls/BUILD +++ b/test/syscalls/BUILD @@ -63,11 +63,13 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:chdir_test", ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:chmod_test", ) @@ -126,9 +128,9 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:creat_test", - use_fusefs = True, ) syscall_test( @@ -184,6 +186,7 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:fchdir_test", ) @@ -296,6 +299,7 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:lseek_test", ) @@ -321,14 +325,15 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:mkdir_test", ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:mknod_test", - use_fusefs = True, ) syscall_test( @@ -378,15 +383,16 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:open_create_test", ) syscall_test( + add_fusefs = True, add_overlay = True, shard_count = more_shards, test = "//test/syscalls/linux:open_test", - use_fusefs = True, ) syscall_test( @@ -441,16 +447,19 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:pread64_test", ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:preadv_test", ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:preadv2_test", ) @@ -506,11 +515,13 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:pwritev2_test", ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:pwrite64_test", ) @@ -529,6 +540,7 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:read_test", ) @@ -546,6 +558,7 @@ syscall_test( syscall_test( size = "medium", + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:readv_test", ) @@ -914,16 +927,16 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:statfs_test", - use_fusefs = True, use_tmpfs = True, # Test specifically relies on TEST_TMPDIR to be tmpfs. ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:stat_test", - use_fusefs = True, ) syscall_test( @@ -937,6 +950,7 @@ syscall_test( ) syscall_test( + add_fusefs = True, add_overlay = True, test = "//test/syscalls/linux:symlink_test", )