From 40882c6e49186510a8adc6ae4b41a879c5d3278f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 15 Nov 2015 15:05:15 +0100 Subject: tests: add example_filesystems, test password and -masterkey mount --- integration_tests/helpers.go | 48 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'integration_tests/helpers.go') 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" -- cgit v1.2.3