Commit e0317ddb authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix races in TestMemoryPressure.

parent f33f1679
...@@ -54,11 +54,11 @@ func TestMemoryPressure(t *testing.T) { ...@@ -54,11 +54,11 @@ func TestMemoryPressure(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("mount failed: %v", err) t.Fatalf("mount failed: %v", err)
} }
state.Debug = VerboseTest()
go state.Loop() go state.Loop()
defer state.Unmount() defer state.Unmount()
state.Debug = VerboseTest()
// Wait for FS to get ready. // Wait for FS to get ready.
os.Lstat(dir) os.Lstat(dir)
...@@ -75,7 +75,12 @@ func TestMemoryPressure(t *testing.T) { ...@@ -75,7 +75,12 @@ func TestMemoryPressure(t *testing.T) {
}(i) }(i)
} }
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
state.reqMu.Lock()
bufs.lock.Lock()
created := bufs.createdBuffers + state.outstandingReadBufs created := bufs.createdBuffers + state.outstandingReadBufs
bufs.lock.Unlock()
state.reqMu.Unlock()
t.Logf("Have %d read bufs", state.outstandingReadBufs) t.Logf("Have %d read bufs", state.outstandingReadBufs)
if created > _MAX_READERS { if created > _MAX_READERS {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment