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

Introduce CheckSuccess() and use throughout.

parent 0901f06b
package examplelib package examplelib
import "os" import (
"fmt"
"os"
)
//////////////// ////////////////
...@@ -18,3 +21,10 @@ func FileExists(name string) bool { ...@@ -18,3 +21,10 @@ func FileExists(name string) bool {
_, err := os.Lstat(name) _, err := os.Lstat(name)
return err == nil return err == nil
} }
func CheckSuccess(e os.Error) {
if e != nil {
panic(fmt.Sprintf("Unexpected error: %v", e))
}
}
...@@ -73,9 +73,7 @@ func (me *testCase) Setup(t *testing.T) { ...@@ -73,9 +73,7 @@ func (me *testCase) Setup(t *testing.T) {
func (me *testCase) Cleanup() { func (me *testCase) Cleanup() {
fmt.Println("Unmounting.") fmt.Println("Unmounting.")
err := me.state.Unmount() err := me.state.Unmount()
if err != nil { CheckSuccess(err)
me.tester.Errorf("Can't unmount a dir, err: %v", err)
}
os.Remove(me.mountPoint) os.Remove(me.mountPoint)
os.RemoveAll(me.origDir) os.RemoveAll(me.origDir)
} }
...@@ -85,17 +83,13 @@ func (me *testCase) Cleanup() { ...@@ -85,17 +83,13 @@ func (me *testCase) Cleanup() {
func (me *testCase) makeOrigSubdir() { func (me *testCase) makeOrigSubdir() {
err := os.Mkdir(me.origSubdir, 0777) err := os.Mkdir(me.origSubdir, 0777)
if err != nil { CheckSuccess(err)
me.tester.Errorf("orig mkdir subdir %v", err)
}
} }
func (me *testCase) removeMountSubdir() { func (me *testCase) removeMountSubdir() {
err := os.RemoveAll(me.mountSubdir) err := os.RemoveAll(me.mountSubdir)
if err != nil { CheckSuccess(err)
me.tester.Errorf("orig rmdir subdir %v", err)
}
} }
func (me *testCase) removeMountFile() { func (me *testCase) removeMountFile() {
...@@ -105,13 +99,9 @@ func (me *testCase) removeMountFile() { ...@@ -105,13 +99,9 @@ func (me *testCase) removeMountFile() {
func (me *testCase) writeOrigFile() { func (me *testCase) writeOrigFile() {
f, err := os.Open(me.origFile, os.O_WRONLY|os.O_CREAT, 0700) f, err := os.Open(me.origFile, os.O_WRONLY|os.O_CREAT, 0700)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Error orig open: %v", err)
}
_, err = f.Write([]byte(contents)) _, err = f.Write([]byte(contents))
if err != nil { CheckSuccess(err)
me.tester.Errorf("Write %v", err)
}
f.Close() f.Close()
} }
...@@ -130,15 +120,11 @@ func (me *testCase) testReadThroughFuse() { ...@@ -130,15 +120,11 @@ func (me *testCase) testReadThroughFuse() {
fmt.Println("Testing chmod.") fmt.Println("Testing chmod.")
err := os.Chmod(me.mountFile, mode) err := os.Chmod(me.mountFile, mode)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Chmod %v", err)
}
fmt.Println("Testing Lstat.") fmt.Println("Testing Lstat.")
fi, err := os.Lstat(me.mountFile) fi, err := os.Lstat(me.mountFile)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Lstat %v", err)
}
if (fi.Mode & 0777) != mode { if (fi.Mode & 0777) != mode {
me.tester.Errorf("Wrong mode %o != %o", fi.Mode, mode) me.tester.Errorf("Wrong mode %o != %o", fi.Mode, mode)
} }
...@@ -146,9 +132,7 @@ func (me *testCase) testReadThroughFuse() { ...@@ -146,9 +132,7 @@ func (me *testCase) testReadThroughFuse() {
// Open (for read), read. // Open (for read), read.
fmt.Println("Testing open.") fmt.Println("Testing open.")
f, err := os.Open(me.mountFile, os.O_RDONLY, 0) f, err := os.Open(me.mountFile, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Fuse open %v", err)
}
fmt.Println("Testing read.") fmt.Println("Testing read.")
var buf [1024]byte var buf [1024]byte
...@@ -169,9 +153,7 @@ func (me *testCase) testRemove() { ...@@ -169,9 +153,7 @@ func (me *testCase) testRemove() {
fmt.Println("Testing remove.") fmt.Println("Testing remove.")
err := os.Remove(me.mountFile) err := os.Remove(me.mountFile)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Remove %v", err)
}
_, err = os.Lstat(me.origFile) _, err = os.Lstat(me.origFile)
if err == nil { if err == nil {
me.tester.Errorf("Lstat() after delete should have generated error.") me.tester.Errorf("Lstat() after delete should have generated error.")
...@@ -182,15 +164,11 @@ func (me *testCase) testWriteThroughFuse() { ...@@ -182,15 +164,11 @@ func (me *testCase) testWriteThroughFuse() {
// Create (for write), write. // Create (for write), write.
me.tester.Log("Testing create.") me.tester.Log("Testing create.")
f, err := os.Open(me.mountFile, os.O_WRONLY|os.O_CREATE, 0644) f, err := os.Open(me.mountFile, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Fuse create/open %v", err)
}
me.tester.Log("Testing write.") me.tester.Log("Testing write.")
n, err := f.WriteString(contents) n, err := f.WriteString(contents)
if err != nil { CheckSuccess(err)
me.tester.Errorf("fuse write %v", err)
}
if n != len(contents) { if n != len(contents) {
me.tester.Errorf("Write mismatch: %v of %v", n, len(contents)) me.tester.Errorf("Write mismatch: %v of %v", n, len(contents))
} }
...@@ -201,15 +179,11 @@ func (me *testCase) testWriteThroughFuse() { ...@@ -201,15 +179,11 @@ func (me *testCase) testWriteThroughFuse() {
} }
f, err = os.Open(me.origFile, os.O_RDONLY, 0) f, err = os.Open(me.origFile, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("orig open %v", err)
}
var buf [1024]byte var buf [1024]byte
slice := buf[:] slice := buf[:]
n, err = f.Read(slice) n, err = f.Read(slice)
if err != nil { CheckSuccess(err)
me.tester.Errorf("orig read %v", err)
}
me.tester.Log("Orig contents", slice[:n]) me.tester.Log("Orig contents", slice[:n])
if string(slice[:n]) != contents { if string(slice[:n]) != contents {
me.tester.Errorf("write contents error %v", slice[:n]) me.tester.Errorf("write contents error %v", slice[:n])
...@@ -221,33 +195,26 @@ func (me *testCase) testWriteThroughFuse() { ...@@ -221,33 +195,26 @@ func (me *testCase) testWriteThroughFuse() {
func (me *testCase) testMkdirRmdir() { func (me *testCase) testMkdirRmdir() {
// Mkdir/Rmdir. // Mkdir/Rmdir.
err := os.Mkdir(me.mountSubdir, 0777) err := os.Mkdir(me.mountSubdir, 0777)
if err != nil { CheckSuccess(err)
me.tester.Errorf("mount mkdir", err)
}
fi, err := os.Lstat(me.origSubdir) fi, err := os.Lstat(me.origSubdir)
if !fi.IsDirectory() { if !fi.IsDirectory() {
me.tester.Errorf("Not a directory: %o", fi.Mode) me.tester.Errorf("Not a directory: %o", fi.Mode)
} }
err = os.Remove(me.mountSubdir) err = os.Remove(me.mountSubdir)
if err != nil { CheckSuccess(err)
me.tester.Errorf("rmdir %v", err) CheckSuccess(err)
}
} }
func (me *testCase) testLink() { func (me *testCase) testLink() {
me.tester.Log("Testing hard links.") me.tester.Log("Testing hard links.")
me.writeOrigFile() me.writeOrigFile()
err := os.Mkdir(me.origSubdir, 0777) err := os.Mkdir(me.origSubdir, 0777)
if err != nil { CheckSuccess(err)
me.tester.Errorf("mount mkdir", err)
}
// Link. // Link.
err = os.Link(me.mountFile, me.mountSubfile) err = os.Link(me.mountFile, me.mountSubfile)
if err != nil { CheckSuccess(err)
me.tester.Errorf("mount link %v", err)
}
fi, err := os.Lstat(me.mountFile) fi, err := os.Lstat(me.mountFile)
if fi.Nlink != 2 { if fi.Nlink != 2 {
...@@ -279,16 +246,11 @@ func (me *testCase) testSymlink() { ...@@ -279,16 +246,11 @@ func (me *testCase) testSymlink() {
defer os.Remove(path.Join(me.mountPoint, linkFile)) defer os.Remove(path.Join(me.mountPoint, linkFile))
defer me.removeMountFile() defer me.removeMountFile()
if err != nil { CheckSuccess(err)
me.tester.Errorf("symlink %v", err)
}
origLink := path.Join(me.origDir, linkFile) origLink := path.Join(me.origDir, linkFile)
fi, err := os.Lstat(origLink) fi, err := os.Lstat(origLink)
if err != nil { CheckSuccess(err)
me.tester.Errorf("link lstat %v", err)
return
}
if !fi.IsSymlink() { if !fi.IsSymlink() {
me.tester.Errorf("not a symlink: %o", fi.Mode) me.tester.Errorf("not a symlink: %o", fi.Mode)
...@@ -296,10 +258,7 @@ func (me *testCase) testSymlink() { ...@@ -296,10 +258,7 @@ func (me *testCase) testSymlink() {
} }
read, err := os.Readlink(path.Join(me.mountPoint, linkFile)) read, err := os.Readlink(path.Join(me.mountPoint, linkFile))
if err != nil { CheckSuccess(err)
me.tester.Errorf("orig readlink %v", err)
return
}
if read != orig { if read != orig {
me.tester.Errorf("unexpected symlink value '%v'", read) me.tester.Errorf("unexpected symlink value '%v'", read)
...@@ -312,9 +271,7 @@ func (me *testCase) testRename() { ...@@ -312,9 +271,7 @@ func (me *testCase) testRename() {
me.makeOrigSubdir() me.makeOrigSubdir()
err := os.Rename(me.mountFile, me.mountSubfile) err := os.Rename(me.mountFile, me.mountSubfile)
if err != nil { CheckSuccess(err)
me.tester.Errorf("rename %v", err)
}
if FileExists(me.origFile) { if FileExists(me.origFile) {
me.tester.Errorf("original %v still exists.", me.origFile) me.tester.Errorf("original %v still exists.", me.origFile)
} }
...@@ -329,10 +286,7 @@ func (me *testCase) testRename() { ...@@ -329,10 +286,7 @@ func (me *testCase) testRename() {
func (me *testCase) testAccess() { func (me *testCase) testAccess() {
me.writeOrigFile() me.writeOrigFile()
err := os.Chmod(me.origFile, 0) err := os.Chmod(me.origFile, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("chmod %v", err)
}
// Ugh - copied from unistd.h // Ugh - copied from unistd.h
const W_OK uint32 = 2 const W_OK uint32 = 2
...@@ -341,10 +295,7 @@ func (me *testCase) testAccess() { ...@@ -341,10 +295,7 @@ func (me *testCase) testAccess() {
me.tester.Errorf("Expected EACCES for non-writable, %v %v", errCode, syscall.EACCES) me.tester.Errorf("Expected EACCES for non-writable, %v %v", errCode, syscall.EACCES)
} }
err = os.Chmod(me.origFile, 0222) err = os.Chmod(me.origFile, 0222)
if err != nil { CheckSuccess(err)
me.tester.Errorf("chmod %v", err)
}
errCode = syscall.Access(me.mountFile, W_OK) errCode = syscall.Access(me.mountFile, W_OK)
if errCode != 0 { if errCode != 0 {
me.tester.Errorf("Expected no error code for writable. %v", errCode) me.tester.Errorf("Expected no error code for writable. %v", errCode)
...@@ -373,14 +324,9 @@ func (me *testCase) testReaddir() { ...@@ -373,14 +324,9 @@ func (me *testCase) testReaddir() {
me.makeOrigSubdir() me.makeOrigSubdir()
dir, err := os.Open(me.mountPoint, os.O_RDONLY, 0) dir, err := os.Open(me.mountPoint, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("opendir err %v", err)
return
}
infos, err := dir.Readdir(10) infos, err := dir.Readdir(10)
if err != nil { CheckSuccess(err)
me.tester.Errorf("readdir err %v", err)
}
wanted := map[string]bool{ wanted := map[string]bool{
"hello.txt": true, "hello.txt": true,
...@@ -409,9 +355,7 @@ func (me *testCase) testFSync() { ...@@ -409,9 +355,7 @@ func (me *testCase) testFSync() {
f, err := os.Open(me.mountFile, os.O_WRONLY, 0) f, err := os.Open(me.mountFile, os.O_WRONLY, 0)
_, err = f.WriteString("hello there") _, err = f.WriteString("hello there")
if err != nil { CheckSuccess(err)
me.tester.Errorf("writestring %v", err)
}
// How to really test fsync ? // How to really test fsync ?
errNo := syscall.Fsync(f.Fd()) errNo := syscall.Fsync(f.Fd())
...@@ -425,9 +369,7 @@ func (me *testCase) testLargeRead() { ...@@ -425,9 +369,7 @@ func (me *testCase) testLargeRead() {
me.tester.Log("Testing large read.") me.tester.Log("Testing large read.")
name := path.Join(me.origDir, "large") name := path.Join(me.origDir, "large")
f, err := os.Open(name, os.O_WRONLY|os.O_CREATE, 0777) f, err := os.Open(name, os.O_WRONLY|os.O_CREATE, 0777)
if err != nil { CheckSuccess(err)
me.tester.Errorf("open write err %v", err)
}
b := bytes.NewBuffer(nil) b := bytes.NewBuffer(nil)
...@@ -438,20 +380,14 @@ func (me *testCase) testLargeRead() { ...@@ -438,20 +380,14 @@ func (me *testCase) testLargeRead() {
slice := b.Bytes() slice := b.Bytes()
n, err := f.Write(slice) n, err := f.Write(slice)
if err != nil { CheckSuccess(err)
me.tester.Errorf("write err %v %v", err, n)
}
err = f.Close() err = f.Close()
if err != nil { CheckSuccess(err)
me.tester.Errorf("close err %v", err)
}
// Read in one go. // Read in one go.
g, err := os.Open(path.Join(me.mountPoint, "large"), os.O_RDONLY, 0) g, err := os.Open(path.Join(me.mountPoint, "large"), os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("open err %v", err)
}
readSlice := make([]byte, len(slice)) readSlice := make([]byte, len(slice))
m, err := g.Read(readSlice) m, err := g.Read(readSlice)
if m != n { if m != n {
...@@ -464,16 +400,12 @@ func (me *testCase) testLargeRead() { ...@@ -464,16 +400,12 @@ func (me *testCase) testLargeRead() {
} }
} }
if err != nil { CheckSuccess(err)
me.tester.Errorf("read mismatch %v", err)
}
g.Close() g.Close()
// Read in chunks // Read in chunks
g, err = os.Open(path.Join(me.mountPoint, "large"), os.O_RDONLY, 0) g, err = os.Open(path.Join(me.mountPoint, "large"), os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("open err %v", err)
}
readSlice = make([]byte, 4096) readSlice = make([]byte, 4096)
total := 0 total := 0
for { for {
...@@ -481,10 +413,7 @@ func (me *testCase) testLargeRead() { ...@@ -481,10 +413,7 @@ func (me *testCase) testLargeRead() {
if m == 0 && err == os.EOF { if m == 0 && err == os.EOF {
break break
} }
if err != nil { CheckSuccess(err)
me.tester.Errorf("read err %v %v", err, m)
break
}
total += m total += m
} }
if total != len(slice) { if total != len(slice) {
...@@ -528,10 +457,7 @@ func (me *testCase) testLargeDirRead() { ...@@ -528,10 +457,7 @@ func (me *testCase) testLargeDirRead() {
nameSet[base] = true nameSet[base] = true
f, err := os.Open(name, os.O_WRONLY|os.O_CREATE, 0777) f, err := os.Open(name, os.O_WRONLY|os.O_CREATE, 0777)
if err != nil { CheckSuccess(err)
me.tester.Errorf("open write err %v", err)
break
}
f.WriteString("bla") f.WriteString("bla")
f.Close() f.Close()
...@@ -539,17 +465,13 @@ func (me *testCase) testLargeDirRead() { ...@@ -539,17 +465,13 @@ func (me *testCase) testLargeDirRead() {
} }
dir, err := os.Open(path.Join(me.mountPoint, "readdirSubdir"), os.O_RDONLY, 0) dir, err := os.Open(path.Join(me.mountPoint, "readdirSubdir"), os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("dirread %v", err)
}
// Chunked read. // Chunked read.
total := 0 total := 0
readSet := make(map[string]bool) readSet := make(map[string]bool)
for { for {
namesRead, err := dir.Readdirnames(200) namesRead, err := dir.Readdirnames(200)
if err != nil { CheckSuccess(err)
me.tester.Errorf("readdir err %v %v", err, namesRead)
}
if len(namesRead) == 0 { if len(namesRead) == 0 {
break break
...@@ -604,9 +526,7 @@ func TestRecursiveMount(t *testing.T) { ...@@ -604,9 +526,7 @@ func TestRecursiveMount(t *testing.T) {
f, err := os.Open(path.Join(ts.mountPoint, "hello.txt"), f, err := os.Open(path.Join(ts.mountPoint, "hello.txt"),
os.O_WRONLY|os.O_CREATE, 0777) os.O_WRONLY|os.O_CREATE, 0777)
if err != nil { CheckSuccess(err)
t.Errorf("open write err %v", err)
}
f.WriteString("bla") f.WriteString("bla")
f.Close() f.Close()
...@@ -618,28 +538,19 @@ func TestRecursiveMount(t *testing.T) { ...@@ -618,28 +538,19 @@ func TestRecursiveMount(t *testing.T) {
submnt := path.Join(ts.mountPoint, "mnt") submnt := path.Join(ts.mountPoint, "mnt")
err = os.Mkdir(submnt, 0777) err = os.Mkdir(submnt, 0777)
if err != nil { CheckSuccess(err)
t.Errorf("mkdir")
}
code = ts.connector.Mount("/mnt", pfs2) code = ts.connector.Mount("/mnt", pfs2)
if code != fuse.OK { if code != fuse.OK {
t.Errorf("mkdir") t.Errorf("mkdir")
} }
_, err = os.Lstat(submnt) _, err = os.Lstat(submnt)
if err != nil { CheckSuccess(err)
t.Error("lstat submount", err)
}
_, err = os.Lstat(path.Join(submnt, "hello.txt")) _, err = os.Lstat(path.Join(submnt, "hello.txt"))
if err != nil { CheckSuccess(err)
t.Error("lstat submount/file", err)
}
f, err = os.Open(path.Join(submnt, "hello.txt"), os.O_RDONLY, 0) f, err = os.Open(path.Join(submnt, "hello.txt"), os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
t.Error("open submount/file", err)
}
code = ts.connector.Unmount("/mnt") code = ts.connector.Unmount("/mnt")
if code != fuse.EBUSY { if code != fuse.EBUSY {
t.Error("expect EBUSY") t.Error("expect EBUSY")
......
...@@ -68,9 +68,7 @@ func (me *stackFsTestCase) Setup(t *testing.T) { ...@@ -68,9 +68,7 @@ func (me *stackFsTestCase) Setup(t *testing.T) {
func (me *stackFsTestCase) Cleanup() { func (me *stackFsTestCase) Cleanup() {
fmt.Println("Unmounting.") fmt.Println("Unmounting.")
err := me.state.Unmount() err := me.state.Unmount()
if err != nil { CheckSuccess(err)
me.tester.Errorf("Can't unmount a dir, err: %v", err)
}
os.RemoveAll(me.testDir) os.RemoveAll(me.testDir)
} }
...@@ -79,14 +77,9 @@ func (me *stackFsTestCase) Cleanup() { ...@@ -79,14 +77,9 @@ func (me *stackFsTestCase) Cleanup() {
func (me *stackFsTestCase) testReaddir() { func (me *stackFsTestCase) testReaddir() {
fmt.Println("testReaddir... ") fmt.Println("testReaddir... ")
dir, err := os.Open(me.mountDir, os.O_RDONLY, 0) dir, err := os.Open(me.mountDir, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("opendir err %v", err)
return
}
infos, err := dir.Readdir(10) infos, err := dir.Readdir(10)
if err != nil { CheckSuccess(err)
me.tester.Errorf("readdir err %v", err)
}
wanted := map[string]bool{ wanted := map[string]bool{
"sub1": true, "sub1": true,
...@@ -128,42 +121,31 @@ func (me *stackFsTestCase) testSubFs() { ...@@ -128,42 +121,31 @@ func (me *stackFsTestCase) testSubFs() {
} }
content1 := "booh!" content1 := "booh!"
f, err = os.Open(mountFile, os.O_WRONLY|os.O_CREATE, magicMode) f, err = os.Open(mountFile, os.O_WRONLY|os.O_CREATE, magicMode)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Create %v", err)
}
f.Write([]byte(content1)) f.Write([]byte(content1))
f.Close() f.Close()
err = os.Chmod(mountFile, magicMode) err = os.Chmod(mountFile, magicMode)
if err != nil { CheckSuccess(err)
me.tester.Errorf("chmod %v", err)
}
fi, err := os.Lstat(mountFile) fi, err := os.Lstat(mountFile)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Lstat %v", err)
} else {
if fi.Mode&0777 != magicMode { if fi.Mode&0777 != magicMode {
me.tester.Errorf("Mode %o", fi.Mode) me.tester.Errorf("Mode %o", fi.Mode)
} }
}
g, err := os.Open(mountFile, os.O_RDONLY, 0) g, err := os.Open(mountFile, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("Open %v", err)
} else {
buf := make([]byte, 1024) buf := make([]byte, 1024)
n, err := g.Read(buf) n, err := g.Read(buf)
if err != nil { CheckSuccess(err)
me.tester.Errorf("read err %v", err)
}
if string(buf[:n]) != content1 { if string(buf[:n]) != content1 {
me.tester.Errorf("content %v", buf[:n]) me.tester.Errorf("content %v", buf[:n])
} }
g.Close() g.Close()
} }
}
} }
func (me *stackFsTestCase) testAddRemove() { func (me *stackFsTestCase) testAddRemove() {
...@@ -185,24 +167,20 @@ func (me *stackFsTestCase) testAddRemove() { ...@@ -185,24 +167,20 @@ func (me *stackFsTestCase) testAddRemove() {
conn.Init(new(fuse.InHeader), new(fuse.InitIn)) conn.Init(new(fuse.InHeader), new(fuse.InitIn))
fi, err := os.Lstat(path.Join(me.mountDir, "third")) fi, err := os.Lstat(path.Join(me.mountDir, "third"))
if err != nil { CheckSuccess(err)
me.tester.Errorf("third lstat err %v", err)
} else {
if !fi.IsDirectory() { if !fi.IsDirectory() {
me.tester.Errorf("not a directory %v", fi) me.tester.Errorf("not a directory %v", fi)
} }
}
fs := me.fs.RemoveFileSystem("third") fs := me.fs.RemoveFileSystem("third")
if fs == nil { if fs == nil {
me.tester.Errorf("remove fail") me.tester.Errorf("remove fail")
} }
dir, err := os.Open(me.mountDir, os.O_RDONLY, 0) dir, err := os.Open(me.mountDir, os.O_RDONLY, 0)
if err != nil { CheckSuccess(err)
me.tester.Errorf("opendir err %v", err)
return
}
infos, err := dir.Readdir(10) infos, err := dir.Readdir(10)
CheckSuccess(err)
if len(infos) != 2 { if len(infos) != 2 {
me.tester.Errorf("lstat expect 2 infos %v", infos) me.tester.Errorf("lstat expect 2 infos %v", infos)
} }
......
...@@ -4,15 +4,8 @@ import ( ...@@ -4,15 +4,8 @@ import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"os" "os"
"testing" "testing"
"fmt"
) )
func CheckSuccess(e os.Error) {
if e != nil {
panic(fmt.Sprintf("Unexpected error: %v", e))
}
}
func TestZipFs(t *testing.T) { func TestZipFs(t *testing.T) {
wd, err := os.Getwd() wd, err := os.Getwd()
CheckSuccess(err) CheckSuccess(err)
......
...@@ -319,7 +319,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFilesystem) S ...@@ -319,7 +319,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFilesystem) S
dirParentNode := me.findInode(dirParent) dirParentNode := me.findInode(dirParent)
// Make sure we know the mount point. // Make sure we know the mount point.
attr, _ := me.internalLookup(dirParentNode.NodeId, base, 0) _, _ = me.internalLookup(dirParentNode.NodeId, base, 0)
} }
node = me.findInode(mountPoint) node = me.findInode(mountPoint)
......
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