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

fuse/test: don't dereference results if FS calls return error.

parent 8bf34aaa
......@@ -209,28 +209,27 @@ func TestFSetAttr(t *testing.T) {
t.Error("truncate retval", os.NewSyscallError("Ftruncate", code))
}
a, status := fs.GetAttr("file", nil)
if !status.Ok() || a.Size != 3 {
if a, status := fs.GetAttr("file", nil); !status.Ok() {
t.Fatalf("GetAttr: status %v", status)
} else if a.Size != 3 {
t.Errorf("truncate: size %d, status %v", a.Size, status)
}
err = f.Chmod(024)
if err != nil {
if err := f.Chmod(024); err != nil {
t.Fatalf("Chmod failed: %v", err)
}
a, status = fs.GetAttr("file", nil)
if !status.Ok() || a.Mode&07777 != 024 {
t.Errorf("chmod: %o, status %v", a.Mode&0777, status)
if a, status := fs.GetAttr("file", nil); !status.Ok() {
t.Errorf("chmod: %v", status)
} else if a.Mode&07777 != 024 {
t.Errorf("getattr after chmod: %o", a.Mode&0777)
}
err = os.Chtimes(fn, time.Unix(0, 100e3), time.Unix(0, 101e3))
if err != nil {
if err := os.Chtimes(fn, time.Unix(0, 100e3), time.Unix(0, 101e3)); err != nil {
t.Fatalf("Chtimes failed: %v", err)
}
a, status = fs.GetAttr("file", nil)
if !status.Ok() {
if a, status := fs.GetAttr("file", nil); !status.Ok() {
t.Errorf("GetAttr: %v", status)
} else if a.Atimensec != 100e3 || a.Mtimensec != 101e3 {
t.Errorf("Utimens: atime %d != 100e3 mtime %d != 101e3",
......
......@@ -194,6 +194,9 @@ func TestWriteThrough(t *testing.T) {
}
fi, err := os.Lstat(tc.origFile)
if err != nil {
t.Fatalf("Lstat(%q): %v", tc.origFile, err)
}
if fi.Mode().Perm() != 0644 {
t.Errorf("create mode error %o", fi.Mode()&0777)
}
......@@ -218,17 +221,17 @@ func TestMkdirRmdir(t *testing.T) {
defer tc.Cleanup()
// Mkdir/Rmdir.
err := os.Mkdir(tc.mountSubdir, 0777)
if err != nil {
if err := os.Mkdir(tc.mountSubdir, 0777); err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
fi, err := os.Lstat(tc.origSubdir)
if !fi.IsDir() {
if fi, err := os.Lstat(tc.origSubdir); err != nil {
t.Fatalf("Lstat(%q): %v", tc.origSubdir, err)
} else if !fi.IsDir() {
t.Errorf("Not a directory: %v", fi)
}
err = os.Remove(tc.mountSubdir)
if err != nil {
if err := os.Remove(tc.mountSubdir); err != nil {
t.Fatalf("Remove failed: %v", err)
}
}
......
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