tests: replace xattr.Supported
This function has been deprecated by the pkg/xattr upstream, so write our own.
This commit is contained in:
parent
db778aae7d
commit
b1f362d28a
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
xattr "github.com/rfjakob/pkg-xattr"
|
xattr "github.com/rfjakob/pkg-xattr"
|
||||||
|
@ -18,10 +19,10 @@ import (
|
||||||
var alternateTestParentDir = "/var/tmp/gocryptfs-xattr-test-parent"
|
var alternateTestParentDir = "/var/tmp/gocryptfs-xattr-test-parent"
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
if !xattr.Supported(test_helpers.TmpDir) {
|
if !xattrSupported(test_helpers.TmpDir) {
|
||||||
test_helpers.SwitchTestParentDir(alternateTestParentDir)
|
test_helpers.SwitchTestParentDir(alternateTestParentDir)
|
||||||
}
|
}
|
||||||
if !xattr.Supported(test_helpers.TmpDir) {
|
if !xattrSupported(test_helpers.TmpDir) {
|
||||||
fmt.Printf("xattrs not supported on %q", test_helpers.TmpDir)
|
fmt.Printf("xattrs not supported on %q", test_helpers.TmpDir)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -148,3 +149,15 @@ func TestXattrList(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func xattrSupported(path string) bool {
|
||||||
|
_, err := xattr.Get(path, "user.xattrSupported-dummy-value")
|
||||||
|
if err == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
err2 := err.(*xattr.Error)
|
||||||
|
if err2.Err == syscall.EOPNOTSUPP {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue