summaryrefslogtreecommitdiff
path: root/integration_tests/helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-15 15:05:15 +0100
committerJakob Unterwurzacher2015-11-15 15:05:15 +0100
commit40882c6e49186510a8adc6ae4b41a879c5d3278f (patch)
tree789510deb01d2a1fa7db5bd0d44f998b11860399 /integration_tests/helpers.go
parent296bdf3af21a8964dcb884ff41ea7556cc811e9a (diff)
tests: add example_filesystems, test password and -masterkey mount
Diffstat (limited to 'integration_tests/helpers.go')
-rw-r--r--integration_tests/helpers.go48
1 files changed, 30 insertions, 18 deletions
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
index 3ab1d21..87e133b 100644
--- a/integration_tests/helpers.go
+++ b/integration_tests/helpers.go
@@ -12,51 +12,63 @@ import (
// Note: the code assumes that all have a trailing slash
const tmpDir = "/tmp/gocryptfs_main_test/"
-const plainDir = tmpDir + "plain/"
-const cipherDir = tmpDir + "cipher/"
+const defaultPlainDir = tmpDir + "plain/"
+const defaultCipherDir = tmpDir + "cipher/"
const gocryptfsBinary = "../gocryptfs"
func resetTmpDir() {
- fu := exec.Command("fusermount", "-z", "-u", plainDir)
+ fu := exec.Command("fusermount", "-z", "-u", defaultPlainDir)
fu.Run()
- os.RemoveAll(tmpDir)
+ err := os.RemoveAll(tmpDir)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
- err := os.MkdirAll(plainDir, 0777)
+ err = os.MkdirAll(defaultPlainDir, 0777)
if err != nil {
- panic("Could not create plainDir")
+ fmt.Println(err)
+ os.Exit(1)
}
- err = os.MkdirAll(cipherDir, 0777)
+ err = os.MkdirAll(defaultCipherDir, 0777)
if err != nil {
- panic("Could not create cipherDir")
+ fmt.Println(err)
+ os.Exit(1)
}
}
-func mount(extraArgs ...string) {
+// mount CIPHERDIR "c" on PLAINDIR "p"
+func mount(c string, p string, extraArgs ...string) {
var args []string
args = append(args, extraArgs...)
//args = append(args, "--fusedebug")
- args = append(args, cipherDir)
- args = append(args, plainDir)
- c := exec.Command(gocryptfsBinary, args...)
+ args = append(args, c)
+ args = append(args, p)
+ cmd := exec.Command(gocryptfsBinary, args...)
if testing.Verbose() {
- c.Stdout = os.Stdout
- c.Stderr = os.Stderr
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
}
- err := c.Run()
+ err := cmd.Run()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
-func unmount() error {
- fu := exec.Command("fusermount", "-z", "-u", plainDir)
+// unmount PLAINDIR "p"
+func unmount(p string) error {
+ fu := exec.Command("fusermount", "-u", "-z", p)
fu.Stdout = os.Stdout
fu.Stderr = os.Stderr
- return fu.Run()
+ err := fu.Run()
+ if err != nil {
+ fmt.Println(err)
+ }
+ return err
}
// Return md5 string for file "filename"