diff options
author | Jakob Unterwurzacher | 2025-01-18 13:56:51 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2025-01-18 14:13:52 +0100 |
commit | c19f986ba09e675a5139b12bcf2687495f2533dd (patch) | |
tree | 890c52882f5c50f695b47d643d209f53cad2c7f2 /tests | |
parent | 1464f9d1668b9b9aa34c239eb4570c2426f95dd9 (diff) |
tests: reverse: factor out newWorkdir
Will be used in a new test in the next commit.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/reverse/correctness_test.go | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index b335456..8f051d0 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -295,6 +295,23 @@ func TestSeekData(t *testing.T) { f.Close() } +// newWorkdir creates a new empty dir in dirA and returns the full path to it along +// with the corresponding encrypted path in dirB +func newWorkdir(t *testing.T) (workdirA, workdirB string) { + workdirA = dirA + "/" + t.Name() + if err := os.Mkdir(workdirA, 0700); err != nil { + t.Fatal(err) + } + // Find workdir in dirB (=encrypted view) + var st syscall.Stat_t + if err := syscall.Stat(workdirA, &st); err != nil { + t.Fatal(err) + } + workdirB = dirB + "/" + findIno(dirB, st.Ino) + t.Logf("newWorkdir: workdirA=%q workdirB=%q", workdirA, workdirB) + return +} + // gocryptfs.longname.*.name of hardlinked files should not appear hardlinked (as the // contents are different). // @@ -308,28 +325,22 @@ func TestHardlinkedLongname(t *testing.T) { t.Skip() } - workdir := dirA + "/" + t.Name() - if err := os.Mkdir(workdir, 0700); err != nil { - t.Fatal(err) - } - long1 := workdir + "/" + strings.Repeat("x", 200) + workdirA, workdirB := newWorkdir(t) + + long1 := workdirA + "/" + strings.Repeat("x", 200) if err := ioutil.WriteFile(long1, []byte("hello"), 0600); err != nil { t.Fatal(err) } - long2 := workdir + "/" + strings.Repeat("y", 220) - if err := syscall.Link(long1, long2); err != nil { + var long1_stat syscall.Stat_t + if err := syscall.Stat(long1, &long1_stat); err != nil { t.Fatal(err) } - - // Find workdir in encrypted view - var st syscall.Stat_t - if err := syscall.Stat(workdir, &st); err != nil { + long2 := workdirA + "/" + strings.Repeat("y", 220) + if err := syscall.Link(long1, long2); err != nil { t.Fatal(err) } - cWorkdir := dirB + "/" + findIno(dirB, st.Ino) - t.Logf("workdir=%q cWorkdir=%q", workdir, cWorkdir) - matches, err := filepath.Glob(cWorkdir + "/gocryptfs.longname.*.name") + matches, err := filepath.Glob(workdirB + "/gocryptfs.longname.*.name") if err != nil { t.Fatal(err) } |