aboutsummaryrefslogtreecommitdiff
path: root/tests/cli/cli_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-04-01 21:23:32 +0200
committerJakob Unterwurzacher2018-04-02 16:38:18 +0200
commitf28d85fad599ffaef9a8e1f353911c81a6605d2f (patch)
tree1acc3514a5dde31e88ad13e8dc48818872e40d0f /tests/cli/cli_test.go
parentfb06c65ee90e31d11cf37b3469f7d3336ae51184 (diff)
fsck: add initial implementation
Most corruption cases except xattr should be covered. With test filesystem. The output is still pretty ugly. xattr support will be added in the next commits.
Diffstat (limited to 'tests/cli/cli_test.go')
-rw-r--r--tests/cli/cli_test.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go
index 2cdaf37..2f27ec7 100644
--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -18,18 +18,6 @@ import (
var testPw = []byte("test")
-// Extract the exit code from an error value that was returned from
-// exec.Run()
-func extractExitCode(err error) int {
- if err == nil {
- return 0
- }
- // OMG this is convoluted
- err2 := err.(*exec.ExitError)
- code := err2.Sys().(syscall.WaitStatus).ExitStatus()
- return code
-}
-
func TestMain(m *testing.M) {
test_helpers.ResetTmpDir(false)
r := m.Run()
@@ -344,7 +332,7 @@ func TestMountPasswordIncorrect(t *testing.T) {
cDir := test_helpers.InitFS(t) // Create filesystem with password "test"
pDir := cDir + ".mnt"
err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo WRONG", "-wpanic=false")
- exitCode := extractExitCode(err)
+ exitCode := test_helpers.ExtractCmdExitCode(err)
if exitCode != exitcodes.PasswordIncorrect {
t.Errorf("want=%d, got=%d", exitcodes.PasswordIncorrect, exitCode)
}
@@ -373,7 +361,7 @@ func TestPasswdPasswordIncorrect(t *testing.T) {
t.Fatal(err)
}
err = cmd.Wait()
- exitCode := extractExitCode(err)
+ exitCode := test_helpers.ExtractCmdExitCode(err)
if exitCode != exitcodes.PasswordIncorrect {
t.Errorf("want=%d, got=%d", exitcodes.PasswordIncorrect, exitCode)
}
@@ -444,7 +432,7 @@ func TestMultipleOperationFlags(t *testing.T) {
//t.Logf("testing %v", args)
cmd := exec.Command(test_helpers.GocryptfsBinary, args...)
err := cmd.Run()
- exitCode := extractExitCode(err)
+ exitCode := test_helpers.ExtractCmdExitCode(err)
if exitCode != exitcodes.Usage {
t.Fatalf("this should have failed with code %d, but returned %d",
exitcodes.Usage, exitCode)