func TestMountOptionSubtype(t *testing.T) { if runtime.GOOS == "darwin" { t.Skip("OS X does not support Subtype") } if runtime.GOOS == "freebsd" { t.Skip("FreeBSD does not support Subtype") } t.Parallel() const name = "FuseTestMarker" mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}}, nil, fuse.Subtype(name), ) if err != nil { t.Fatal(err) } defer mnt.Close() info, err := fstestutil.GetMountInfo(mnt.Dir) if err != nil { t.Fatal(err) } if g, e := info.Type, "fuse."+name; g != e { t.Errorf("wrong Subtype: %q != %q", g, e) } }
func TestMountOptionReadOnly(t *testing.T) { t.Parallel() mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{createrDir{}}, nil, fuse.ReadOnly(), ) if err != nil { t.Fatal(err) } defer mnt.Close() // This will be prevented by kernel-level access checking when // ReadOnly is used. f, err := os.Create(mnt.Dir + "/child") if err == nil { f.Close() t.Fatal("expected an error") } perr, ok := err.(*os.PathError) if !ok { t.Fatalf("expected PathError, got %T: %v", err, err) } if perr.Err != syscall.EROFS { t.Fatalf("expected EROFS, got %T: %v", err, err) } }
func TestMountOptionDefaultPermissions(t *testing.T) { if runtime.GOOS == "freebsd" { t.Skip("FreeBSD does not support DefaultPermissions") } t.Parallel() mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{ &fstestutil.ChildMap{"child": unwritableFile{}}, }, nil, fuse.DefaultPermissions(), ) if err != nil { t.Fatal(err) } defer mnt.Close() // This will be prevented by kernel-level access checking when // DefaultPermissions is used. f, err := os.OpenFile(mnt.Dir+"/child", os.O_WRONLY, 0000) if err == nil { f.Close() t.Fatal("expected an error") } if !os.IsPermission(err) { t.Fatalf("expected a permission error, got %T: %v", err, err) } }
func TestMountOptionAllowRootThenAllowOther(t *testing.T) { t.Parallel() mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}}, nil, fuse.AllowRoot(), fuse.AllowOther(), ) if err == nil { mnt.Close() } if g, e := err, fuse.ErrCannotCombineAllowOtherAndAllowRoot; g != e { t.Fatalf("wrong error: %v != %v", g, e) } }
func TestExchangeDataNotSupported(t *testing.T) { t.Parallel() mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{&fstestutil.ChildMap{ "one": &exchangeData{}, "two": &exchangeData{}, }}, nil) if err != nil { t.Fatal(err) } defer mnt.Close() if err := unix.Exchangedata(mnt.Dir+"/one", mnt.Dir+"/two", 0); err != unix.ENOTSUP { t.Fatalf("expected ENOTSUP from exchangedata: %v", err) } }
func TestMountOptionCommaError(t *testing.T) { t.Parallel() // this test is not tied to any specific option, it just needs // some string content var evil = "FuseTest,Marker" mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}}, nil, fuse.ForTestSetMountOption("fusetest", evil), ) if err == nil { mnt.Close() t.Fatal("expected an error about commas") } if g, e := err.Error(), `mount options cannot contain commas on `+runtime.GOOS+`: "fusetest"="FuseTest,Marker"`; g != e { t.Fatalf("wrong error: %q != %q", g, e) } }
func testMountOptionFSNameEvil(t *testing.T, evil string) { if runtime.GOOS == "freebsd" { t.Skip("FreeBSD does not support FSName") } t.Parallel() var name = "FuseTest" + evil + "Marker" mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}}, nil, fuse.FSName(name), ) if err != nil { t.Fatal(err) } defer mnt.Close() info, err := fstestutil.GetMountInfo(mnt.Dir) if err != nil { t.Fatal(err) } if g, e := info.FSName, name; g != e { t.Errorf("wrong FSName: %q != %q", g, e) } }