aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2024-05-05 22:42:47 +0200
committerJakob Unterwurzacher2024-05-05 22:42:47 +0200
commitbbfbf37bd73f4aac333c7a65f80d5d977a548e20 (patch)
treec4d29a36819048959c3271cd27ef516ab2eb6420
parent5a2d4614ed75d4b32e0f45e93a225f8e1b7350c9 (diff)
tests: reverse: deduplicate findInum / findIno
-rw-r--r--tests/reverse/correctness_test.go19
-rw-r--r--tests/reverse/inomap_test.go2
2 files changed, 3 insertions, 18 deletions
diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go
index 8747a11..930048f 100644
--- a/tests/reverse/correctness_test.go
+++ b/tests/reverse/correctness_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io/ioutil"
- "log"
"os"
"path/filepath"
"strings"
@@ -296,22 +295,6 @@ func TestSeekData(t *testing.T) {
f.Close()
}
-func findInum(dir string, inum uint64) (name string) {
- entries, err := os.ReadDir(dir)
- if err != nil {
- panic(err)
- }
- for _, e := range entries {
- info, _ := e.Info()
- st := info.Sys().(*syscall.Stat_t)
- if st.Ino == inum {
- return dir + "/" + e.Name()
- }
- }
- log.Panicf("inum %d not found", inum)
- return ""
-}
-
// gocryptfs.longname.*.name of hardlinked files should not appear hardlinked (as the
// contents are different).
//
@@ -339,7 +322,7 @@ func TestHardlinkedLongname(t *testing.T) {
if err := syscall.Stat(workdir, &st); err != nil {
t.Fatal(err)
}
- cWorkdir := findInum(dirB, st.Ino)
+ cWorkdir := dirB + "/" + findIno(dirB, st.Ino)
t.Logf("workdir=%q cWorkdir=%q", workdir, cWorkdir)
matches, err := filepath.Glob(cWorkdir + "/gocryptfs.longname.*.name")
diff --git a/tests/reverse/inomap_test.go b/tests/reverse/inomap_test.go
index a79ddd2..aadb782 100644
--- a/tests/reverse/inomap_test.go
+++ b/tests/reverse/inomap_test.go
@@ -2,6 +2,7 @@ package reverse_test
import (
"bytes"
+ "log"
"os"
"strings"
"syscall"
@@ -30,6 +31,7 @@ func findIno(dir string, ino uint64) string {
return entry
}
}
+ log.Panicf("ino %d not found", ino)
return ""
}