Skip to content

Commit

Permalink
tests: reverse: deduplicate findInum / findIno
Browse files Browse the repository at this point in the history
  • Loading branch information
rfjakob committed May 5, 2024
1 parent 5a2d461 commit bbfbf37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
19 changes: 1 addition & 18 deletions tests/reverse/correctness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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).
//
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions tests/reverse/inomap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package reverse_test

import (
"bytes"
"log"
"os"
"strings"
"syscall"
Expand Down Expand Up @@ -30,6 +31,7 @@ func findIno(dir string, ino uint64) string {
return entry
}
}
log.Panicf("ino %d not found", ino)
return ""
}

Expand Down

0 comments on commit bbfbf37

Please sign in to comment.