aboutsummaryrefslogtreecommitdiff
path: root/tests/cluster/cluster_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2023-06-05 13:43:23 +0200
committerJakob Unterwurzacher2024-12-04 19:53:15 +0100
commita49beb70ec23731b8bb3a627a1f445ab7a779759 (patch)
treec53c562891630c876604efc2ff7ba0c121a85fa7 /tests/cluster/cluster_test.go
parentf28ba04ef42f32f0383285efe99ec875ae5c8b8f (diff)
tests/cluster: add TestOpenTruncate
This fails right now: 1 jakob@brikett:~/go/src/github.com/rfjakob/gocryptfs/tests/cluster$ go test -run TestOpenTruncate -v === RUN TestOpenTruncate cluster_test.go:235: POSIX compliance issue: non-exlusive create failed with err=file exists doWrite 2898550: corrupt header: ParseHeader: header is all-zero. Header hexdump: 000000000000000000000000000000000000 cluster_test.go:240: iteration 1: WriteAt: write /var/tmp/gocryptfs-test-parent-1026/1896094179/TestOpenTruncate.4202105280.mnt2/foo: input/output error --- FAIL: TestOpenTruncate (0.10s) FAIL exit status 1 FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 0.099s 1 jakob@brikett:~/go/src/github.com/rfjakob/gocryptfs/tests/cluster$ go test -run TestOpenTruncate -v === RUN TestOpenTruncate cluster_test.go:235: POSIX compliance issue: non-exlusive create failed with err=file exists doRead 2898565: corrupt block #0: cipher: message authentication failed ino2898565 fh9: RMW read failed: errno=5 cluster_test.go:240: iteration 8: WriteAt: write /var/tmp/gocryptfs-test-parent-1026/652691834/TestOpenTruncate.281532388.mnt1/foo: input/output error --- FAIL: TestOpenTruncate (0.09s) FAIL exit status 1 FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 0.095s
Diffstat (limited to 'tests/cluster/cluster_test.go')
-rw-r--r--tests/cluster/cluster_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/cluster/cluster_test.go b/tests/cluster/cluster_test.go
index 99a017f..0a24d2d 100644
--- a/tests/cluster/cluster_test.go
+++ b/tests/cluster/cluster_test.go
@@ -185,3 +185,40 @@ func TestConcurrentCreate(t *testing.T) {
go workerThread(mnt2 + "/foo")
wg.Wait()
}
+
+func TestOpenTruncate(t *testing.T) {
+ cDir := test_helpers.InitFS(t)
+ mnt1 := cDir + ".mnt1"
+ mnt2 := cDir + ".mnt2"
+ test_helpers.MountOrFatal(t, cDir, mnt1, "-extpass=echo test", "-wpanic=0", "-sharedstorage")
+ defer test_helpers.UnmountPanic(mnt1)
+ test_helpers.MountOrFatal(t, cDir, mnt2, "-extpass=echo test", "-wpanic=0", "-sharedstorage")
+ defer test_helpers.UnmountPanic(mnt2)
+
+ var wg sync.WaitGroup
+ const loops = 100
+
+ writerThread := func(path string) {
+ defer wg.Done()
+ for i := 0; i < loops; i++ {
+ if t.Failed() {
+ return
+ }
+ f, err := os.Create(path)
+ if err != nil {
+ t.Logf("POSIX compliance issue: non-exlusive create failed with err=%v", errors.Unwrap(err))
+ continue
+ }
+ _, err = f.WriteAt([]byte("foo"), 0)
+ if err != nil {
+ t.Errorf("iteration %d: WriteAt: %v", i, err)
+ }
+ f.Close()
+ }
+ }
+
+ wg.Add(2)
+ go writerThread(mnt1 + "/foo")
+ go writerThread(mnt2 + "/foo")
+ wg.Wait()
+}