Commit 675a48a2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Move fallocate test to linux specific too. Check kernel

interface version.
parent e00427dc
......@@ -40,3 +40,31 @@ func clearStatfs(s *syscall.Statfs_t) {
// TODO - figure out what this is for.
s.Flags = 0
}
func TestFallocate(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
if ts.state.KernelSettings().Minor < 19 {
t.Log("FUSE does not support Fallocate.")
return
}
rwFile, err := os.OpenFile(ts.mnt+"/file", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
if err != nil {
t.Fatalf("OpenFile failed: %v", err)
}
defer rwFile.Close()
err = syscall.Fallocate(int(rwFile.Fd()), 0, 1024, 4096)
if err != nil {
t.Fatalf("FUSE Fallocate failed: %v", err)
}
fi, err := os.Lstat(ts.orig + "/file")
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
if fi.Size() < (1024 + 4096) {
t.Fatalf("fallocate should have changed file size. Got %d bytes",
fi.Size())
}
}
......@@ -979,25 +979,3 @@ func TestUmask(t *testing.T) {
t.Errorf("got %o, expect mode %o for file %s", got, expect, fn)
}
}
func TestFallocate(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
rwFile, err := os.OpenFile(ts.mnt+"/file", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
if err != nil {
t.Fatalf("OpenFile failed: %v", err)
}
defer rwFile.Close()
err = syscall.Fallocate(int(rwFile.Fd()), 0, 1024, 4096)
if err != nil {
t.Fatalf("Fallocate failed: %v", err)
}
fi, err := os.Lstat(ts.orig + "/file")
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
if fi.Size() < (1024 + 4096) {
t.Fatalf("fallocate should have changed file size. Got %d bytes",
fi.Size())
}
}
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