Update rwmutex_test.go

This commit is contained in:
Nikita Pilnenskiy 2023-04-16 19:51:07 +00:00 committed by Fedor Korotkiy
parent 70dacc6478
commit b47acc1e28

View file

@ -97,6 +97,23 @@ func HammerRWMutex(gomaxprocs, numReaders, numIterations int) {
} }
} }
func TestRWMutexReadWrite(t *testing.T) {
timeout := time.After(5 * time.Second)
done := make(chan bool)
go func() {
rwm := New()
rwm.RLock()
rwm.Lock()
done <- true
}()
select {
case <-timeout:
case <-done:
t.Fatal("Test finished, must be deadlock")
}
}
func TestRWMutex(t *testing.T) { func TestRWMutex(t *testing.T) {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(-1)) defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(-1))
n := 1000 n := 1000