aboutsummaryrefslogtreecommitdiff
path: root/tests/defaults
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-05-01 18:36:25 +0200
committerJakob Unterwurzacher2017-05-01 18:44:03 +0200
commit9768376bd1961a5aa0fbf7f08de0601322664fc3 (patch)
treea4698b5b4e5eca19822c6e7f5ed746836a18a828 /tests/defaults
parent9ab11aa4d775f7c1242e8b044cc2f8957cc2c784 (diff)
tests: add TestXfs124
This test reproduces the problem xfstests generic/124 uncovered. The warning itself is harmless, but we should either (1) add locking so that this cannot happen anymore or (2) drop the warning. Currently fails: $ go test -v === RUN Test1980Tar --- PASS: Test1980Tar (0.00s) === RUN TestCtlSock --- PASS: TestCtlSock (0.10s) === RUN TestOpenTruncateRead --- PASS: TestOpenTruncateRead (0.00s) === RUN TestWORead --- PASS: TestWORead (0.00s) === RUN TestXfs124 cipherSize 18 == header size: interrupted write? -wpanic turns this warning into a panic: cipherSize 18 == header size: interrupted write?
Diffstat (limited to 'tests/defaults')
-rw-r--r--tests/defaults/main_test.go64
1 files changed, 63 insertions, 1 deletions
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 8c1b7e3..2ea9e12 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -3,8 +3,11 @@ package defaults
import (
"bytes"
+ "io"
"os"
"os/exec"
+ "runtime"
+ "sync"
"syscall"
"testing"
@@ -117,7 +120,7 @@ func TestOpenTruncateRead(t *testing.T) {
}
}
-// TestWORead tries to read from a write-only file.
+// TestWORead tries to read from a write-only FD.
func TestWORead(t *testing.T) {
fn := test_helpers.DefaultPlainDir + "/TestWORead"
fd, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, 0600)
@@ -131,3 +134,62 @@ func TestWORead(t *testing.T) {
t.Error("Reading from write-only file should fail, but did not")
}
}
+
+// xfstests generic/124 triggers this warning:
+// cipherSize 18 == header size: interrupted write?
+// This test reproduces the problem.
+func TestXfs124(t *testing.T) {
+ // GOMAXPROCS=8 and N=5000 seem to reliably trigger the problem. With N=1000,
+ // the test passes sometimes.
+ runtime.GOMAXPROCS(8)
+ N := 5000
+
+ fn := test_helpers.DefaultPlainDir + "/TestXfs124"
+ fd, err := os.Create(fn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer fd.Close()
+
+ var wg sync.WaitGroup
+ wg.Add(2)
+
+ go func() {
+ buf := make([]byte, 10)
+ var err2 error
+ for i := 0; i < N; i++ {
+ err2 = fd.Truncate(0)
+ if err2 != nil {
+ panic(err2)
+ }
+ _, err2 = fd.WriteAt(buf, 0)
+ if err2 != nil {
+ panic(err2)
+ }
+ }
+ wg.Done()
+ }()
+
+ fd2, err := os.Open(fn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer fd2.Close()
+
+ go func() {
+ buf := make([]byte, 10)
+ var err3 error
+ for i := 0; i < N; i++ {
+ _, err3 = fd2.ReadAt(buf, 0)
+ if err3 == io.EOF {
+ continue
+ }
+ if err3 != nil {
+ panic(err3)
+ }
+ }
+ wg.Done()
+ }()
+
+ wg.Wait()
+}