Commit b2ac4af8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Skip TestFSetAttrFs if file operations are not supported.

Use normal loopback for LargeWrite test, and move it into
loopback_test.go

Change-Id: I61c8186aea63f7bb6e591f1bcadcdad49e0866fe
parent 63309b28
...@@ -157,10 +157,8 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func( ...@@ -157,10 +157,8 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func(
t.Fatal("WaitMount", err) t.Fatal("WaitMount", err)
} }
// Trigger INIT.
os.Lstat(dir)
if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 { if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 {
t.Log("Mount does not support file operations") t.Skip("Mount does not support file operations")
} }
return dir, func() { return dir, func() {
...@@ -172,27 +170,6 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func( ...@@ -172,27 +170,6 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func(
} }
} }
func TestDataReadLarge(t *testing.T) {
fs := &FSetAttrFs{
FileSystem: pathfs.NewDefaultFileSystem(),
}
dir, clean := setupFAttrTest(t, fs)
defer clean()
content := randomData(385 * 1023)
fn := dir + "/file"
err := ioutil.WriteFile(fn, []byte(content), 0644)
if err != nil {
t.Fatalf("WriteFile failed: %v", err)
}
back, err := ioutil.ReadFile(fn)
if err != nil {
t.Fatalf("ReadFile failed: %v", err)
}
CompareSlices(t, back, content)
}
func TestFSetAttr(t *testing.T) { func TestFSetAttr(t *testing.T) {
fSetAttrFs := &FSetAttrFs{ fSetAttrFs := &FSetAttrFs{
FileSystem: pathfs.NewDefaultFileSystem(), FileSystem: pathfs.NewDefaultFileSystem(),
...@@ -277,6 +254,4 @@ func TestFSetAttr(t *testing.T) { ...@@ -277,6 +254,4 @@ func TestFSetAttr(t *testing.T) {
if !fSetAttrFs.file.FsyncCalled { if !fSetAttrFs.file.FsyncCalled {
t.Error("Fsync was not called") t.Error("Fsync was not called")
} }
// TODO - test chown if run as root.
} }
...@@ -678,6 +678,20 @@ func TestReadLarge(t *testing.T) { ...@@ -678,6 +678,20 @@ func TestReadLarge(t *testing.T) {
CompareSlices(t, back, content) CompareSlices(t, back, content)
} }
func TestWriteLarge(t *testing.T) {
tc := NewTestCase(t)
defer tc.Cleanup()
content := randomData(385 * 1023)
tc.WriteFile(tc.mountFile, []byte(content), 0644)
back, err := ioutil.ReadFile(tc.origFile)
if err != nil {
t.Fatalf("ReadFile failed: %v", err)
}
CompareSlices(t, back, content)
}
func randomLengthString(length int) string { func randomLengthString(length int) string {
r := rand.Intn(length) r := rand.Intn(length)
......
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