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 (
_OP_FALLOCATE = uint32(43) // protocol version 19.
_OP_READDIRPLUS = uint32(44) // protocol version 21.
_OP_RENAME2 = uint32(45) // protocol version 23.
_OP_LSEEK = uint32(46)
_OP_COPY_FILE_RANGE = uint32(47)
_OP_LSEEK = uint32(46) // protocol version 24
_OP_COPY_FILE_RANGE = uint32(47) // protocol version 28.
// The following entries don't have to be compatible across Go-FUSE versions.
_OP_NOTIFY_INVAL_ENTRY = uint32(100)
......
......@@ -92,7 +92,7 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
// change content but no metadata.
func TestKeepCache(t *testing.T) {
root := &keepCacheRoot{}
mntDir, clean := testMount(t, root, nil)
mntDir, _, clean := testMount(t, root, nil)
defer clean()
c1, err := ioutil.ReadFile(mntDir + "/keep")
if err != nil {
......
......@@ -54,7 +54,7 @@ func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFl
func TestDirectIO(t *testing.T) {
root := &dioRoot{}
mntDir, clean := testMount(t, root, nil)
mntDir, server, clean := testMount(t, root, nil)
defer clean()
f, err := os.Open(mntDir + "/file")
......@@ -74,6 +74,9 @@ func TestDirectIO(t *testing.T) {
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 {
t.Errorf("Seek: %v", err)
} else if n != 1024 {
......
......@@ -55,7 +55,7 @@ func TestInterrupt(t *testing.T) {
root := &interruptRoot{}
oneSec := time.Second
mntDir, clean := testMount(t, root, &Options{
mntDir, _, clean := testMount(t, root, &Options{
EntryTimeout: &oneSec,
AttrTimeout: &oneSec,
})
......
......@@ -140,6 +140,10 @@ func TestCopyFileRange(t *testing.T) {
tc := newTestCase(t, true, true)
defer tc.Clean()
if !tc.server.KernelSettings().SupportsVersion(7, 28) {
t.Skip("need v7.28 for CopyFileRange")
}
tc.writeOrig("src", "01234567890123456789", 0644)
tc.writeOrig("dst", "abcdefghijabcdefghij", 0644)
......
......@@ -17,7 +17,7 @@ import (
"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()
mntDir := testutil.TempDir()
......@@ -32,7 +32,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func())
if err != nil {
t.Fatal(err)
}
return mntDir, func() {
return mntDir, server, func() {
server.Unmount()
os.Remove(mntDir)
}
......@@ -41,7 +41,7 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, func())
func TestDataFile(t *testing.T) {
want := "hello"
root := &Inode{}
mntDir, clean := testMount(t, root, &Options{
mntDir, _, clean := testMount(t, root, &Options{
FirstAutomaticIno: 1,
OnAdd: func(ctx context.Context) {
n := root.EmbeddedInode()
......@@ -94,7 +94,7 @@ func TestDataFileLargeRead(t *testing.T) {
data := make([]byte, 256*1024)
rand.Read(data[:])
mntDir, clean := testMount(t, root, &Options{
mntDir, _, clean := testMount(t, root, &Options{
FirstAutomaticIno: 1,
OnAdd: func(ctx context.Context) {
n := root.EmbeddedInode()
......@@ -137,7 +137,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
func TestDataSymlink(t *testing.T) {
root := &SymlinkerRoot{}
mntDir, clean := testMount(t, root, nil)
mntDir, _, clean := testMount(t, root, nil)
defer clean()
if err := syscall.Symlink("target", mntDir+"/link"); err != nil {
......
......@@ -16,7 +16,7 @@ import (
func TestReadonlyCreate(t *testing.T) {
root := &Inode{}
mntDir, clean := testMount(t, root, nil)
mntDir, _, clean := testMount(t, root, nil)
defer clean()
_, err := syscall.Creat(mntDir+"/test", 0644)
......@@ -28,7 +28,7 @@ func TestReadonlyCreate(t *testing.T) {
func TestDefaultPermissions(t *testing.T) {
root := &Inode{}
mntDir, clean := testMount(t, root, &Options{
mntDir, _, clean := testMount(t, root, &Options{
DefaultPermissions: true,
OnAdd: func(ctx context.Context) {
dir := root.NewPersistentInode(ctx, &Inode{}, NodeAttr{Mode: syscall.S_IFDIR})
......
......@@ -62,7 +62,7 @@ func TestZipFS(t *testing.T) {
}
root := &zipRoot{zr: r}
mntDir, clean := testMount(t, root, nil)
mntDir, _, clean := testMount(t, root, nil)
defer clean()
for k, v := range testData {
......@@ -104,7 +104,7 @@ func TestZipFSOnAdd(t *testing.T) {
zr := &zipRoot{zr: r}
root := &Inode{}
mnt, clean := testMount(t, root, &Options{
mnt, _, clean := testMount(t, root, &Options{
OnAdd: func(ctx context.Context) {
root.AddChild("sub",
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