summaryrefslogtreecommitdiff
path: root/tests/matrix/matrix_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-03-05 22:36:58 +0100
committerJakob Unterwurzacher2019-04-08 20:27:13 +0200
commitd851cf805506bdaf979d49cc021216817678f023 (patch)
treeedc231a97670a2b345725ea9e9dd6fb6d7a8254b /tests/matrix/matrix_test.go
parentd22ccf68b21e75a6a2d43a658002b87bd5d0a2a1 (diff)
tests: add TestConcurrentReadCreate, move to new file
https://github.com/rfjakob/gocryptfs/issues/363
Diffstat (limited to 'tests/matrix/matrix_test.go')
-rw-r--r--tests/matrix/matrix_test.go63
1 files changed, 0 insertions, 63 deletions
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index b1d12fa..226dfd8 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -15,9 +15,7 @@ import (
"bytes"
"flag"
"fmt"
- "io"
"io/ioutil"
- "log"
"os"
"os/exec"
"runtime"
@@ -188,67 +186,6 @@ func TestWrite10Tight(t *testing.T) {
}
}
-// https://github.com/rfjakob/gocryptfs/issues/363
-//
-// Note: this test calls log.Fatal() instead of t.Fatal() because apperently,
-// calling t.Fatal() from a goroutine hangs the test.
-func TestConcurrentReadWrite(t *testing.T) {
- var wg sync.WaitGroup
- fn := test_helpers.DefaultPlainDir + "/TestConcurrentReadWrite"
- if f, err := os.Create(fn); err != nil {
- t.Fatal(err)
- } else {
- f.Close()
- }
- buf := make([]byte, 100)
- content := []byte("1234567890")
- threads := 30
- loops := 30
- for i := 0; i < threads; i++ {
- // Reader thread
- wg.Add(1)
- go func() {
- fRd, err := os.Open(fn)
- if err != nil {
- log.Fatal(err)
- }
- for j := 0; j < loops; j++ {
- n, err := fRd.ReadAt(buf, 0)
- if err != nil && err != io.EOF {
- log.Fatal(err)
- }
- if n != 0 && n != 10 {
- log.Fatalf("strange read length: %d", n)
- }
- }
- fRd.Close()
- wg.Done()
- }()
-
- // Writer thread
- wg.Add(1)
- go func() {
- fWr, err := os.OpenFile(fn, os.O_RDWR, 0700)
- if err != nil {
- log.Fatal(err)
- }
- for j := 0; j < loops; j++ {
- err = fWr.Truncate(0)
- if err != nil {
- log.Fatal(err)
- }
- _, err = fWr.WriteAt(content, 0)
- if err != nil {
- log.Fatal(err)
- }
- }
- fWr.Close()
- wg.Done()
- }()
- }
- wg.Wait()
-}
-
// Hint for calculating reference md5sums:
// dd if=/dev/zero count=1 bs=XYZ | md5sum
func TestTruncate(t *testing.T) {