From b1f362d28af28e35ae8d24813ad00a8f033ed861 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 26 Mar 2018 21:54:17 +0200 Subject: [PATCH] tests: replace xattr.Supported This function has been deprecated by the pkg/xattr upstream, so write our own. --- tests/xattr/xattr_integration_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/xattr/xattr_integration_test.go b/tests/xattr/xattr_integration_test.go index 58d62d9..c491f60 100644 --- a/tests/xattr/xattr_integration_test.go +++ b/tests/xattr/xattr_integration_test.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "strings" + "syscall" "testing" xattr "github.com/rfjakob/pkg-xattr" @@ -18,10 +19,10 @@ import ( var alternateTestParentDir = "/var/tmp/gocryptfs-xattr-test-parent" func TestMain(m *testing.M) { - if !xattr.Supported(test_helpers.TmpDir) { + if !xattrSupported(test_helpers.TmpDir) { 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) 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 +}