aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/getdents_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat/getdents_test.go')
-rw-r--r--internal/syscallcompat/getdents_test.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/internal/syscallcompat/getdents_test.go b/internal/syscallcompat/getdents_test.go
index 8f2bd09..131ffee 100644
--- a/internal/syscallcompat/getdents_test.go
+++ b/internal/syscallcompat/getdents_test.go
@@ -12,9 +12,19 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
+var getdentsUnderTest = getdents
+
func TestGetdents(t *testing.T) {
+ t.Logf("testing native getdents")
+ testGetdents(t)
+ t.Logf("testing emulateGetdents")
+ getdentsUnderTest = emulateGetdents
+ testGetdents(t)
+}
+
+func testGetdents(t *testing.T) {
// Fill a directory with filenames of length 1 ... 255
- testDir, err := ioutil.TempDir("", "TestGetdents")
+ testDir, err := ioutil.TempDir(tmpDir, "TestGetdents")
if err != nil {
t.Fatal(err)
}
@@ -35,17 +45,21 @@ func TestGetdents(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ defer fd.Close()
readdirEntries, err := fd.Readdir(0)
if err != nil {
t.Fatal(err)
}
- fd.Close()
readdirMap := make(map[string]*syscall.Stat_t)
for _, v := range readdirEntries {
readdirMap[v.Name()] = fuse.ToStatT(v)
}
- // Read using our Getdents()
- getdentsEntries, err := Getdents(dir)
+ // Read using our Getdents() implementation
+ _, err = fd.Seek(0, 0) // Rewind directory
+ if err != nil {
+ t.Fatal(err)
+ }
+ getdentsEntries, err := getdentsUnderTest(int(fd.Fd()))
if err != nil {
t.Fatal(err)
}