Commit 882312bf authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: skip tests if kernel doesn't support lseek/copy_file_range

parent 71c48e77
...@@ -58,8 +58,8 @@ const ( ...@@ -58,8 +58,8 @@ const (
_OP_FALLOCATE = uint32(43) // protocol version 19. _OP_FALLOCATE = uint32(43) // protocol version 19.
_OP_READDIRPLUS = uint32(44) // protocol version 21. _OP_READDIRPLUS = uint32(44) // protocol version 21.
_OP_RENAME2 = uint32(45) // protocol version 23. _OP_RENAME2 = uint32(45) // protocol version 23.
_OP_LSEEK = uint32(46) _OP_LSEEK = uint32(46) // protocol version 24
_OP_COPY_FILE_RANGE = uint32(47) _OP_COPY_FILE_RANGE = uint32(47) // protocol version 28.
// The following entries don't have to be compatible across Go-FUSE versions. // The following entries don't have to be compatible across Go-FUSE versions.
_OP_NOTIFY_INVAL_ENTRY = uint32(100) _OP_NOTIFY_INVAL_ENTRY = uint32(100)
......
...@@ -92,7 +92,7 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) { ...@@ -92,7 +92,7 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
// change content but no metadata. // change content but no metadata.
func TestKeepCache(t *testing.T) { func TestKeepCache(t *testing.T) {
root := &keepCacheRoot{} root := &keepCacheRoot{}
mntDir, clean := testMount(t, root, nil) mntDir, _, clean := testMount(t, root, nil)
defer clean() defer clean()
c1, err := ioutil.ReadFile(mntDir + "/keep") c1, err := ioutil.ReadFile(mntDir + "/keep")
if err != nil { if err != nil {
......
...@@ -54,7 +54,7 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl ...@@ -54,7 +54,7 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
func TestDirectIO(t *testing.T) { func TestDirectIO(t *testing.T) {
root := &dioRoot{} root := &dioRoot{}
mntDir, clean := testMount(t, root, nil) mntDir, server, clean := testMount(t, root, nil)
defer clean() defer clean()
f, err := os.Open(mntDir + "/file") f, err := os.Open(mntDir + "/file")
...@@ -74,6 +74,9 @@ func TestDirectIO(t *testing.T) { ...@@ -74,6 +74,9 @@ func TestDirectIO(t *testing.T) {
t.Errorf("got %q want %q", got, want) t.Errorf("got %q want %q", got, want)
} }
if !server.KernelSettings().SupportsVersion(7, 24) {
t.Skip("Kernel does not support lseek")
}
if n, err := syscall.Seek(int(f.Fd()), 512, _SEEK_DATA); err != nil { if n, err := syscall.Seek(int(f.Fd()), 512, _SEEK_DATA); err != nil {
t.Errorf("Seek: %v", err) t.Errorf("Seek: %v", err)
} else if n != 1024 { } else if n != 1024 {
......
...@@ -55,7 +55,7 @@ func TestInterrupt(t *testing.T) { ...@@ -55,7 +55,7 @@ func TestInterrupt(t *testing.T) {
root := &interruptRoot{} root := &interruptRoot{}
oneSec := time.Second oneSec := time.Second
mntDir, clean := testMount(t, root, &Options{ mntDir, _, clean := testMount(t, root, &Options{
EntryTimeout: &oneSec, EntryTimeout: &oneSec,
AttrTimeout: &oneSec, AttrTimeout: &oneSec,
}) })
......
...@@ -140,6 +140,10 @@ func TestCopyFileRange(t *testing.T) { ...@@ -140,6 +140,10 @@ func TestCopyFileRange(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, true, true)
defer tc.Clean() defer tc.Clean()
if !tc.server.KernelSettings().SupportsVersion(7, 28) {
t.Skip("need v7.28 for CopyFileRange")
}
tc.writeOrig("src", "01234567890123456789", 0644) tc.writeOrig("src", "01234567890123456789", 0644)
tc.writeOrig("dst", "abcdefghijabcdefghij", 0644) tc.writeOrig("dst", "abcdefghijabcdefghij", 0644)
......
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
"github.com/hanwen/go-fuse/internal/testutil" "github.com/hanwen/go-fuse/internal/testutil"
) )
func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func()) { func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.Server, func()) {
t.Helper() t.Helper()
mntDir := testutil.TempDir() mntDir := testutil.TempDir()
...@@ -32,7 +32,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func()) ...@@ -32,7 +32,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
return mntDir, func() { return mntDir, server, func() {
server.Unmount() server.Unmount()
os.Remove(mntDir) os.Remove(mntDir)
} }
...@@ -41,7 +41,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func()) ...@@ -41,7 +41,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func())
func TestDataFile(t *testing.T) { func TestDataFile(t *testing.T) {
want := "hello" want := "hello"
root := &Inode{} root := &Inode{}
mntDir, clean := testMount(t, root, &Options{ mntDir, _, clean := testMount(t, root, &Options{
FirstAutomaticIno: 1, FirstAutomaticIno: 1,
OnAdd: func(ctx context.Context) { OnAdd: func(ctx context.Context) {
n := root.EmbeddedInode() n := root.EmbeddedInode()
...@@ -94,7 +94,7 @@ func TestDataFileLargeRead(t *testing.T) { ...@@ -94,7 +94,7 @@ func TestDataFileLargeRead(t *testing.T) {
data := make([]byte, 256*1024) data := make([]byte, 256*1024)
rand.Read(data[:]) rand.Read(data[:])
mntDir, clean := testMount(t, root, &Options{ mntDir, _, clean := testMount(t, root, &Options{
FirstAutomaticIno: 1, FirstAutomaticIno: 1,
OnAdd: func(ctx context.Context) { OnAdd: func(ctx context.Context) {
n := root.EmbeddedInode() n := root.EmbeddedInode()
...@@ -137,7 +137,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f ...@@ -137,7 +137,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
func TestDataSymlink(t *testing.T) { func TestDataSymlink(t *testing.T) {
root := &SymlinkerRoot{} root := &SymlinkerRoot{}
mntDir, clean := testMount(t, root, nil) mntDir, _, clean := testMount(t, root, nil)
defer clean() defer clean()
if err := syscall.Symlink("target", mntDir+"/link"); err != nil { if err := syscall.Symlink("target", mntDir+"/link"); err != nil {
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
func TestReadonlyCreate(t *testing.T) { func TestReadonlyCreate(t *testing.T) {
root := &Inode{} root := &Inode{}
mntDir, clean := testMount(t, root, nil) mntDir, _, clean := testMount(t, root, nil)
defer clean() defer clean()
_, err := syscall.Creat(mntDir+"/test", 0644) _, err := syscall.Creat(mntDir+"/test", 0644)
...@@ -28,7 +28,7 @@ func TestReadonlyCreate(t *testing.T) { ...@@ -28,7 +28,7 @@ func TestReadonlyCreate(t *testing.T) {
func TestDefaultPermissions(t *testing.T) { func TestDefaultPermissions(t *testing.T) {
root := &Inode{} root := &Inode{}
mntDir, clean := testMount(t, root, &Options{ mntDir, _, clean := testMount(t, root, &Options{
DefaultPermissions: true, DefaultPermissions: true,
OnAdd: func(ctx context.Context) { OnAdd: func(ctx context.Context) {
dir := root.NewPersistentInode(ctx, &Inode{}, NodeAttr{Mode: syscall.S_IFDIR}) dir := root.NewPersistentInode(ctx, &Inode{}, NodeAttr{Mode: syscall.S_IFDIR})
......
...@@ -62,7 +62,7 @@ func TestZipFS(t *testing.T) { ...@@ -62,7 +62,7 @@ func TestZipFS(t *testing.T) {
} }
root := &zipRoot{zr: r} root := &zipRoot{zr: r}
mntDir, clean := testMount(t, root, nil) mntDir, _, clean := testMount(t, root, nil)
defer clean() defer clean()
for k, v := range testData { for k, v := range testData {
...@@ -104,7 +104,7 @@ func TestZipFSOnAdd(t *testing.T) { ...@@ -104,7 +104,7 @@ func TestZipFSOnAdd(t *testing.T) {
zr := &zipRoot{zr: r} zr := &zipRoot{zr: r}
root := &Inode{} root := &Inode{}
mnt, clean := testMount(t, root, &Options{ mnt, _, clean := testMount(t, root, &Options{
OnAdd: func(ctx context.Context) { OnAdd: func(ctx context.Context) {
root.AddChild("sub", root.AddChild("sub",
root.NewPersistentInode(ctx, zr, NodeAttr{Mode: syscall.S_IFDIR}), false) root.NewPersistentInode(ctx, zr, NodeAttr{Mode: syscall.S_IFDIR}), false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment