From a0fd3eca98218aa7d165080ab20cf234330e5e09 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 2 Apr 2018 18:43:50 +0200 Subject: fsck: test against example_filesystems --- tests/fsck/fsck_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/fsck') diff --git a/tests/fsck/fsck_test.go b/tests/fsck/fsck_test.go index b5bbf84..77f94c3 100644 --- a/tests/fsck/fsck_test.go +++ b/tests/fsck/fsck_test.go @@ -1,7 +1,9 @@ package fsck import ( + "os" "os/exec" + "strings" "testing" "github.com/rfjakob/gocryptfs/internal/exitcodes" @@ -18,3 +20,41 @@ func TestBrokenFsV14(t *testing.T) { t.Errorf("wrong exit code, have=%d want=%d", code, exitcodes.FsckErrors) } } + +func TestExampleFses(t *testing.T) { + dirfd, err := os.Open("../example_filesystems") + if err != nil { + t.Fatal(err) + } + var fsNames []string + entries, err := dirfd.Readdir(0) + if err != nil { + t.Fatal(err) + } + for _, e := range entries { + if !e.IsDir() { + continue + } + if strings.Contains(e.Name(), "reverse") { + continue + } + if e.Name() == "content" { + continue + } + fsNames = append(fsNames, e.Name()) + } + for _, n := range fsNames { + path := "../example_filesystems/" + n + cmd := exec.Command(test_helpers.GocryptfsBinary, "-fsck", "-extpass", "echo test", path) + outBin, err := cmd.CombinedOutput() + out := string(outBin) + code := test_helpers.ExtractCmdExitCode(err) + if code == exitcodes.DeprecatedFS { + continue + } + if code != 0 { + t.Log(out) + t.Errorf("fsck returned code %d but fs should be clean", code) + } + } +} -- cgit v1.2.3