aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/example_filesystems/example_filesystems_test.go12
-rw-r--r--tests/matrix/matrix_test.go18
-rw-r--r--tests/reverse/correctness_test.go4
-rw-r--r--tests/reverse/exclude_test.go4
-rw-r--r--tests/test_helpers/helpers.go9
5 files changed, 24 insertions, 23 deletions
diff --git a/tests/example_filesystems/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go
index 08cd958..88132c0 100644
--- a/tests/example_filesystems/example_filesystems_test.go
+++ b/tests/example_filesystems/example_filesystems_test.go
@@ -200,7 +200,7 @@ func TestExampleFSv11reverse(t *testing.T) {
dirA = tmpFsPath + dirA
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-extpass", "echo test", opensslOpt)
c := dirB + "/gocryptfs.conf"
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-extpass", "echo test", opensslOpt)
@@ -211,7 +211,7 @@ func TestExampleFSv11reverse(t *testing.T) {
m := "68b51855-042abd80-635ae1ba-90152a78-2ec2d243-832ac72a-eab0561a-f2d37913"
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-masterkey", m,
"-raw64=false", "-hkdf=false", opensslOpt)
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-aessiv", "-masterkey", m,
@@ -237,7 +237,7 @@ func TestExampleFSv11reversePlaintextnames(t *testing.T) {
dirA = tmpFsPath + dirA
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-extpass", "echo test", opensslOpt)
c := dirB + "/gocryptfs.conf"
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-extpass", "echo test", opensslOpt)
@@ -248,7 +248,7 @@ func TestExampleFSv11reversePlaintextnames(t *testing.T) {
m := "e7fb8f0d-2a81df9e-26611e4b-5540b218-e48aa458-c2a623af-d0c82637-1466b5f2"
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-masterkey", m,
"-raw64=false", "-hkdf=false", opensslOpt)
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-aessiv", "-masterkey", m,
@@ -335,7 +335,7 @@ func TestExampleFSv13reverse(t *testing.T) {
// Mount using password
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-extpass", "echo test", opensslOpt)
c := dirB + "/gocryptfs.conf"
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-extpass", "echo test", opensslOpt)
@@ -367,7 +367,7 @@ func TestExampleFSv13reverse(t *testing.T) {
// Mount using masterkey
m := "2290a7f4-3e1908fb-b006f7d9-261bdaf1-4b72bc38-3b24956c-db7d8a8d-d996076a"
test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-masterkey", m, opensslOpt)
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
test_helpers.MountOrFatal(t, dirB, dirC, "-aessiv", "-masterkey", m, opensslOpt)
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index b51d927..2542844 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -493,7 +493,7 @@ func TestLongNames(t *testing.T) {
t.Fatalf("Could not create n255x: %v", err)
}
f.Close()
- if !test_helpers.VerifyExistence(wd + n255x) {
+ if !test_helpers.VerifyExistence(t, wd+n255x) {
t.Errorf("n255x is not in directory listing")
}
// Rename long to long (target does not exist)
@@ -502,7 +502,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename n255x to n255y: %v", err)
}
- if !test_helpers.VerifyExistence(wd + n255y) {
+ if !test_helpers.VerifyExistence(t, wd+n255y) {
t.Errorf("n255y is not in directory listing")
}
// Rename long to long (target exists)
@@ -515,7 +515,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename n255x to n255y: %v", err)
}
- if !test_helpers.VerifyExistence(wd + n255y) {
+ if !test_helpers.VerifyExistence(t, wd+n255y) {
t.Errorf("n255y is not in directory listing")
}
// Rename long to short (target does not exist)
@@ -523,7 +523,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename n255y to short: %v", err)
}
- if !test_helpers.VerifyExistence(wd + "short") {
+ if !test_helpers.VerifyExistence(t, wd+"short") {
t.Errorf("short is not in directory listing")
}
// Rename long to short (target exists)
@@ -536,7 +536,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename n255y to short: %v", err)
}
- if !test_helpers.VerifyExistence(wd + "short") {
+ if !test_helpers.VerifyExistence(t, wd+"short") {
t.Errorf("short is not in directory listing")
}
// Rename short to long (target does not exist)
@@ -544,7 +544,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename short to n255x: %v", err)
}
- if !test_helpers.VerifyExistence(wd + n255x) {
+ if !test_helpers.VerifyExistence(t, wd+n255x) {
t.Errorf("255x is not in directory listing II")
}
// Rename short to long (target exists)
@@ -557,7 +557,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not rename short to n255x: %v", err)
}
- if !test_helpers.VerifyExistence(wd + n255x) {
+ if !test_helpers.VerifyExistence(t, wd+n255x) {
t.Errorf("n255x is not in directory listing")
}
// Unlink
@@ -565,7 +565,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatalf("Could not unlink n255x: %v", err)
}
- if test_helpers.VerifyExistence(wd + n255x) {
+ if test_helpers.VerifyExistence(t, wd+n255x) {
t.Errorf("n255x still there after unlink")
}
// Long symlink
@@ -574,7 +574,7 @@ func TestLongNames(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !test_helpers.VerifyExistence(wd + n255s) {
+ if !test_helpers.VerifyExistence(t, wd+n255s) {
t.Errorf("n255s is not in directory listing")
}
err = syscall.Unlink(wd + n255s)
diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go
index 9ebff37..47b8b73 100644
--- a/tests/reverse/correctness_test.go
+++ b/tests/reverse/correctness_test.go
@@ -26,7 +26,7 @@ func TestLongnameStat(t *testing.T) {
}
fd.Close()
path := dirC + "/" + name
- if !test_helpers.VerifyExistence(path) {
+ if !test_helpers.VerifyExistence(t, path) {
t.Fatalf("failed to verify %q", path)
}
test_helpers.VerifySize(t, path, 0)
@@ -106,7 +106,7 @@ func TestSymlinkDentrySize(t *testing.T) {
// gocryptfs.conf
func TestConfigMapping(t *testing.T) {
c := dirB + "/gocryptfs.conf"
- if !test_helpers.VerifyExistence(c) {
+ if !test_helpers.VerifyExistence(t, c) {
t.Errorf("%s missing", c)
}
data, err := ioutil.ReadFile(c)
diff --git a/tests/reverse/exclude_test.go b/tests/reverse/exclude_test.go
index 110a407..b5d0f5b 100644
--- a/tests/reverse/exclude_test.go
+++ b/tests/reverse/exclude_test.go
@@ -118,7 +118,7 @@ func testExclude(t *testing.T, flag string) {
cExclude := encryptExcludeTestPaths(t, sock, pExclude)
// Check that "excluded" paths are not there and "ok" paths are there
for _, v := range cExclude {
- if test_helpers.VerifyExistence(mnt + "/" + v) {
+ if test_helpers.VerifyExistence(t, mnt+"/"+v) {
t.Errorf("File %q is visible, but should be excluded", v)
}
if nametransform.IsLongContent(filepath.Base(v)) {
@@ -126,7 +126,7 @@ func testExclude(t *testing.T, flag string) {
}
}
for _, v := range cOk {
- if !test_helpers.VerifyExistence(mnt + "/" + v) {
+ if !test_helpers.VerifyExistence(t, mnt+"/"+v) {
t.Errorf("File %q is hidden, but should be visible", v)
}
}
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 37c82c1..6119065 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -289,7 +289,8 @@ func TestRename(t *testing.T, plainDir string) {
// VerifyExistence checks in 3 ways that "path" exists:
// stat, open, readdir. Returns true if the path exists, false otherwise.
// Panics if the result is inconsistent.
-func VerifyExistence(path string) bool {
+func VerifyExistence(t *testing.T, path string) bool {
+ t.Helper()
// Check if file can be stat()ed
stat := true
fi, err := os.Stat(path)
@@ -309,12 +310,12 @@ func VerifyExistence(path string) bool {
name := filepath.Base(path)
d, err := os.Open(dir)
if err != nil && open == true {
- log.Panicf("we can open the file but not the parent dir!? err=%v", err)
+ t.Errorf("VerifyExistence: we can open the file but not the parent dir!? err=%v", err)
} else if err == nil {
defer d.Close()
listing, err := d.Readdirnames(0)
if stat && fi.IsDir() && err != nil {
- log.Panicf("It's a directory, but readdirnames failed: %v", err)
+ t.Errorf("VerifyExistence: It's a directory, but readdirnames failed: %v", err)
}
for _, entry := range listing {
if entry == name {
@@ -326,7 +327,7 @@ func VerifyExistence(path string) bool {
if stat == open && open == readdir {
return stat
}
- log.Panicf("inconsistent result on %q: stat=%v open=%v readdir=%v, path=%q", name, stat, open, readdir, path)
+ t.Errorf("VerifyExistence: inconsistent result on %q: stat=%v open=%v readdir=%v, path=%q", name, stat, open, readdir, path)
return false
}