Fix rwmutex test

This commit is contained in:
Fedor Korotkiy 2023-04-17 14:03:06 +04:00
parent b47acc1e28
commit 91fdec209b

View file

@ -5,6 +5,7 @@ import (
"runtime" "runtime"
"sync/atomic" "sync/atomic"
"testing" "testing"
"time"
) )
func parallelReader(m *RWMutex, clocked, cunlock, cdone chan bool) { func parallelReader(m *RWMutex, clocked, cunlock, cdone chan bool) {
@ -98,7 +99,6 @@ func HammerRWMutex(gomaxprocs, numReaders, numIterations int) {
} }
func TestRWMutexReadWrite(t *testing.T) { func TestRWMutexReadWrite(t *testing.T) {
timeout := time.After(5 * time.Second)
done := make(chan bool) done := make(chan bool)
go func() { go func() {
rwm := New() rwm := New()
@ -108,7 +108,7 @@ func TestRWMutexReadWrite(t *testing.T) {
}() }()
select { select {
case <-timeout: case <-time.After(time.Second):
case <-done: case <-done:
t.Fatal("Test finished, must be deadlock") t.Fatal("Test finished, must be deadlock")
} }