This repository was archived by the owner on Dec 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1+ // BufferPool is no-op under race detector, so all these tests do not work.
2+ // +build !race
3+
14/*
25 * Copyright The Dragonfly Authors.
36 *
@@ -18,6 +21,7 @@ package pool
1821
1922import (
2023 "fmt"
24+ "runtime"
2125 "testing"
2226
2327 "github.com/stretchr/testify/suite"
@@ -51,6 +55,11 @@ func (s *BufferPoolTestSuite) TestAcquireBuffer() {
5155}
5256
5357func (s * BufferPoolTestSuite ) TestReleaseBuffer () {
58+ // Limit to 1 processor to make sure that the goroutine doesn't migrate
59+ // to another P between AcquireBuffer and ReleaseBuffer calls.
60+ prev := runtime .GOMAXPROCS (1 )
61+ defer runtime .GOMAXPROCS (prev )
62+
5463 buf1 := AcquireBuffer ()
5564 ReleaseBuffer (buf1 )
5665 ReleaseBuffer (nil )
Original file line number Diff line number Diff line change 1+ // WriterPool is no-op under race detector, so all these tests do not work.
2+ // +build !race
3+
14/*
25 * Copyright The Dragonfly Authors.
36 *
@@ -19,13 +22,19 @@ package pool
1922import (
2023 "bytes"
2124 "io/ioutil"
25+ "runtime"
2226 "sync"
2327 "testing"
2428
2529 "github.com/stretchr/testify/require"
2630)
2731
2832func TestWriter (t * testing.T ) {
33+ // Limit to 1 processor to make sure that the goroutine doesn't migrate
34+ // to another P between AcquireWriter and ReleaseWriter calls.
35+ prev := runtime .GOMAXPROCS (1 )
36+ defer runtime .GOMAXPROCS (prev )
37+
2938 tmp := writerPool
3039 writerPool = & sync.Pool {}
3140
You can’t perform that action at this time.
0 commit comments