fsck: test against example_filesystems
This commit is contained in:
parent
b6c8960b01
commit
a0fd3eca98
|
@ -169,7 +169,7 @@ func LoadConfFile(filename string, password []byte) ([]byte, *ConfFile, error) {
|
||||||
|
|
||||||
`+"\033[0m")
|
`+"\033[0m")
|
||||||
|
|
||||||
return nil, nil, fmt.Errorf("Deprecated filesystem")
|
return nil, nil, exitcodes.NewErr("Deprecated filesystem", exitcodes.DeprecatedFS)
|
||||||
}
|
}
|
||||||
if len(password) == 0 {
|
if len(password) == 0 {
|
||||||
// We have validated the config file, but without a password we cannot
|
// We have validated the config file, but without a password we cannot
|
||||||
|
|
|
@ -63,6 +63,8 @@ const (
|
||||||
Profiler = 25
|
Profiler = 25
|
||||||
// FsckErrors - the filesystem check found errors
|
// FsckErrors - the filesystem check found errors
|
||||||
FsckErrors = 26
|
FsckErrors = 26
|
||||||
|
// DeprecatedFS - this filesystem is deprecated
|
||||||
|
DeprecatedFS = 27
|
||||||
)
|
)
|
||||||
|
|
||||||
// Err wraps an error with an associated numeric exit code
|
// Err wraps an error with an associated numeric exit code
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package fsck
|
package fsck
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/exitcodes"
|
"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)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue