aboutsummaryrefslogtreecommitdiff
path: root/tests/fsck/fsck_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/fsck/fsck_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/fsck/fsck_test.go')
-rw-r--r--tests/fsck/fsck_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/fsck/fsck_test.go b/tests/fsck/fsck_test.go
new file mode 100644
index 0000000..7506636
--- /dev/null
+++ b/tests/fsck/fsck_test.go
@@ -0,0 +1,26 @@
+package fsck
+
+import (
+ "os/exec"
+ "strings"
+ "testing"
+
+ "github.com/rfjakob/gocryptfs/internal/exitcodes"
+ "github.com/rfjakob/gocryptfs/tests/test_helpers"
+)
+
+func TestBrokenFsV14(t *testing.T) {
+ cmd := exec.Command(test_helpers.GocryptfsBinary, "-fsck", "-extpass", "echo test", "broken_fs_v1.4")
+ outBin, err := cmd.CombinedOutput()
+ out := string(outBin)
+ t.Log(out)
+ code := test_helpers.ExtractCmdExitCode(err)
+ if code != exitcodes.FsckErrors {
+ t.Errorf("wrong exit code, have=%d want=%d", code, exitcodes.FsckErrors)
+ }
+ lines := strings.Split(out, "\n")
+ summaryLine := lines[len(lines)-2]
+ if summaryLine != "fsck: found 5 problems" {
+ t.Errorf("wrong summary line: %q", summaryLine)
+ }
+}