Commit 5c0109c6 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Handle new readdir() behavior of 22/05 release of Go.

parent d33686e1
...@@ -59,11 +59,11 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status ...@@ -59,11 +59,11 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status
Mode: infos[i].Mode, Mode: infos[i].Mode,
} }
} }
if len(infos) < want { if len(infos) < want || err == os.EOF {
break break
} }
if err != nil { if err != nil {
// TODO - how to signal error log.Println("Readdir() returned err:", err)
break break
} }
} }
......
...@@ -533,16 +533,17 @@ func (me *testCase) testLargeDirRead() { ...@@ -533,16 +533,17 @@ func (me *testCase) testLargeDirRead() {
dir, err := os.Open(filepath.Join(me.mountPoint, "readdirSubdir")) dir, err := os.Open(filepath.Join(me.mountPoint, "readdirSubdir"))
CheckSuccess(err) CheckSuccess(err)
defer dir.Close()
// 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)
CheckSuccess(err) if len(namesRead) == 0 || err == os.EOF {
if len(namesRead) == 0 {
break break
} }
CheckSuccess(err)
for _, v := range namesRead { for _, v := range namesRead {
readSet[v] = true readSet[v] = true
} }
...@@ -558,9 +559,6 @@ func (me *testCase) testLargeDirRead() { ...@@ -558,9 +559,6 @@ func (me *testCase) testLargeDirRead() {
me.tester.Errorf("Name %v not found in output", k) me.tester.Errorf("Name %v not found in output", k)
} }
} }
dir.Close()
os.RemoveAll(subdir) os.RemoveAll(subdir)
} }
...@@ -581,9 +579,23 @@ func TestMount(t *testing.T) { ...@@ -581,9 +579,23 @@ func TestMount(t *testing.T) {
ts.testAccess() ts.testAccess()
ts.testMknod() ts.testMknod()
ts.testFSync() ts.testFSync()
ts.testTouch()
}
func TestLargeRead(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
ts.testLargeRead() ts.testLargeRead()
}
func TestLargeDirRead(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
ts.testLargeDirRead() ts.testLargeDirRead()
ts.testTouch()
} }
func TestDelRename(t *testing.T) { func TestDelRename(t *testing.T) {
......
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