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