aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-03-24 21:37:41 +0100
committerJakob Unterwurzacher2018-03-24 21:40:11 +0100
commitf20974c4dad913a07ce5808005fe07084f87c95f (patch)
treeb51d2442fc810d421bf0cc248f1b565d3ce7eb28
parent3d54fc3a3afab2b016c45c8bd4743e06aefe4789 (diff)
test_helpers: add SwitchTestParentDir
SwitchTestParentDir changes testParentDir. This is used when you want to perform tests on a special filesystem. For example, the xattr tests cannot run on tmpfs and use /var/tmp instead of /tmp.
-rw-r--r--tests/test_helpers/helpers.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 0cb45d4..5c0319e 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -22,7 +22,7 @@ import (
)
// TmpDir will be created inside this directory
-const testParentDir = "/tmp/gocryptfs-test-parent"
+var testParentDir = "/tmp/gocryptfs-test-parent"
// GocryptfsBinary is the assumed path to the gocryptfs build.
const GocryptfsBinary = "../../gocryptfs"
@@ -43,7 +43,19 @@ var DefaultPlainDir string
// DefaultCipherDir is TmpDir + "/default-cipher"
var DefaultCipherDir string
+// SwitchTestParentDir changes testParentDir. This is used when you want
+// to perform tests on a special filesystem. For example, the xattr tests
+// cannot run on tmpfs and use /var/tmp instead of /tmp.
+func SwitchTestParentDir(newDir string) {
+ testParentDir = newDir
+ doInit()
+}
+
func init() {
+ doInit()
+}
+
+func doInit() {
X255 = string(bytes.Repeat([]byte("X"), 255))
os.MkdirAll(testParentDir, 0700)