aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/syscallcompat/getdents_test.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/internal/syscallcompat/getdents_test.go b/internal/syscallcompat/getdents_test.go
index 4b50575..bfcc50a 100644
--- a/internal/syscallcompat/getdents_test.go
+++ b/internal/syscallcompat/getdents_test.go
@@ -5,6 +5,7 @@ package syscallcompat
import (
"io/ioutil"
"os"
+ "runtime"
"strings"
"syscall"
"testing"
@@ -14,17 +15,38 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
-var getdentsUnderTest = getdents
+var emulate = false
func TestGetdents(t *testing.T) {
t.Logf("testing native getdents")
testGetdents(t)
t.Logf("testing emulateGetdents")
- getdentsUnderTest = emulateGetdents
+ emulate = true
testGetdents(t)
}
+// skipOnGccGo skips the emulateGetdents test when we are
+// running linux and were compiled with gccgo. The test is known to fail
+// (https://github.com/rfjakob/gocryptfs/issues/201), but getdents emulation
+// is not used on linux, so let's skip the test and ignore the failure.
+func skipOnGccGo(t *testing.T) {
+ if !emulate || runtime.GOOS != "linux" {
+ return
+ }
+ // runtime.Version() output...
+ // on go: go1.9.2
+ // on gccgo: go1.8.1 gccgo (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
+ v := runtime.Version()
+ if strings.Contains(v, "gccgo") {
+ t.Skipf("test is known-broken on gccgo")
+ }
+}
+
func testGetdents(t *testing.T) {
+ getdentsUnderTest := getdents
+ if emulate {
+ getdentsUnderTest = emulateGetdents
+ }
// Fill a directory with filenames of length 1 ... 255
testDir, err := ioutil.TempDir(tmpDir, "TestGetdents")
if err != nil {
@@ -63,7 +85,9 @@ func testGetdents(t *testing.T) {
}
getdentsEntries, err := getdentsUnderTest(int(fd.Fd()))
if err != nil {
- t.Fatal(err)
+ t.Log(err)
+ skipOnGccGo(t)
+ t.FailNow()
}
getdentsMap := make(map[string]fuse.DirEntry)
for _, v := range getdentsEntries {