From 8151222ada4c687bfad7e2f35c73aacbbc24c6b5 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 4 Feb 2018 21:13:14 +0100 Subject: gccgo: skip emulateGetdents on linux The test is known to fail on gccgo (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. --- internal/syscallcompat/getdents_test.go | 30 +++++++++++++++++++++++++++--- 1 file 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 { -- cgit v1.2.3