From 5a1ebdb4f7449759656a1344d3c63ba3798e2782 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 10 Oct 2018 22:24:20 +0200 Subject: tests: respect TMPDIR if set Setting TMPDIR now allows to run the tests against a directory of your choice, making it easier to test different filesystems. --- tests/xattr/xattr_integration_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/xattr') diff --git a/tests/xattr/xattr_integration_test.go b/tests/xattr/xattr_integration_test.go index 6d4c0c3..a989060 100644 --- a/tests/xattr/xattr_integration_test.go +++ b/tests/xattr/xattr_integration_test.go @@ -16,16 +16,15 @@ import ( "github.com/rfjakob/gocryptfs/tests/test_helpers" ) -// On modern Linux distributions, /tmp may be on tmpfs, -// which does not support user xattrs. Try /var/tmp instead. -var alternateTestParentDir = "/var/tmp/gocryptfs-xattr-test-parent" - func TestMain(m *testing.M) { - if !xattrSupported(test_helpers.TmpDir) { - test_helpers.SwitchTestParentDir(alternateTestParentDir) + // On modern Linux distributions, /tmp may be on tmpfs, + // which does not support user xattrs. Try /var/tmp instead + if !xattrSupported(test_helpers.TmpDir) && os.TempDir() == "/tmp" { + fmt.Printf("Switching from /tmp to /var/tmp for xattr tests\n") + test_helpers.SwitchTMPDIR("/var/tmp") } if !xattrSupported(test_helpers.TmpDir) { - fmt.Printf("xattrs not supported on %q", test_helpers.TmpDir) + fmt.Printf("xattrs not supported on %q\n", test_helpers.TmpDir) os.Exit(1) } test_helpers.ResetTmpDir(true) -- cgit v1.2.3