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.
This commit is contained in:
parent
bf2f9640c4
commit
8151222ada
|
@ -5,6 +5,7 @@ package syscallcompat
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -14,17 +15,38 @@ import (
|
||||||
"github.com/hanwen/go-fuse/fuse"
|
"github.com/hanwen/go-fuse/fuse"
|
||||||
)
|
)
|
||||||
|
|
||||||
var getdentsUnderTest = getdents
|
var emulate = false
|
||||||
|
|
||||||
func TestGetdents(t *testing.T) {
|
func TestGetdents(t *testing.T) {
|
||||||
t.Logf("testing native getdents")
|
t.Logf("testing native getdents")
|
||||||
testGetdents(t)
|
testGetdents(t)
|
||||||
t.Logf("testing emulateGetdents")
|
t.Logf("testing emulateGetdents")
|
||||||
getdentsUnderTest = emulateGetdents
|
emulate = true
|
||||||
testGetdents(t)
|
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) {
|
func testGetdents(t *testing.T) {
|
||||||
|
getdentsUnderTest := getdents
|
||||||
|
if emulate {
|
||||||
|
getdentsUnderTest = emulateGetdents
|
||||||
|
}
|
||||||
// Fill a directory with filenames of length 1 ... 255
|
// Fill a directory with filenames of length 1 ... 255
|
||||||
testDir, err := ioutil.TempDir(tmpDir, "TestGetdents")
|
testDir, err := ioutil.TempDir(tmpDir, "TestGetdents")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -63,7 +85,9 @@ func testGetdents(t *testing.T) {
|
||||||
}
|
}
|
||||||
getdentsEntries, err := getdentsUnderTest(int(fd.Fd()))
|
getdentsEntries, err := getdentsUnderTest(int(fd.Fd()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Log(err)
|
||||||
|
skipOnGccGo(t)
|
||||||
|
t.FailNow()
|
||||||
}
|
}
|
||||||
getdentsMap := make(map[string]fuse.DirEntry)
|
getdentsMap := make(map[string]fuse.DirEntry)
|
||||||
for _, v := range getdentsEntries {
|
for _, v := range getdentsEntries {
|
||||||
|
|
Loading…
Reference in New Issue