gui: a test bounding allocations skips its bound under -race
Under -race sync.Pool lets a quarter of what is put in it go, so json's encoders and regexp's matchers are made again: four gui tests bounding what a path allocates went red under -race atfd70def82, and at the base before it. TestProviderInfoReadsTheListOnce measured a row at 88 MB against 13 MB without -race, all in catalog.FamilyOf's regexps. raceOn (as internal/gateway has it) now skips the bound in TestStateWriteGrowsNoBufferItsSize, TestProvidersWriteGrowsNoBufferItsSize, TestJSONRowsNotHeldWhole and TestProviderInfoReadsTheListOnce (after its row checks). Without -race they run as before. Run on mote at this tree: - gofmt, go vet ./internal/gui, GOOS=windows and GOOS=linux go vet -tags nogui: ok. - The four tests without -race: PASS. - go test -race ./internal/gui: only TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949) red, which are red without -race too. Picked onto7da5b34aa(sessions, gateway); not run again there.
This commit is contained in:
@@ -54,6 +54,9 @@ func TestProviderInfoReadsTheListOnce(t *testing.T) {
|
||||
t.Fatalf("exposed %d of %d, first %+v", got.Exposed, len(p.Exposed()), got.Models[0])
|
||||
}
|
||||
|
||||
if raceOn {
|
||||
t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates")
|
||||
}
|
||||
bytesPer := func(f func()) uint64 {
|
||||
f()
|
||||
var a, b runtime.MemStats
|
||||
|
||||
@@ -51,6 +51,9 @@ func TestProvidersWrittenAsEncoded(t *testing.T) {
|
||||
// buffer to its size: 27 MB of what forty polls allocated. Each provider
|
||||
// is encoded alone now.
|
||||
func TestProvidersWriteGrowsNoBufferItsSize(t *testing.T) {
|
||||
if raceOn {
|
||||
t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates")
|
||||
}
|
||||
s := bigProviders()
|
||||
w := &sinkWriter{}
|
||||
writeProvidersJSON(w, s) // json's encoders, warmed
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//go:build !race
|
||||
|
||||
package gui
|
||||
|
||||
const raceOn = false
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build race
|
||||
|
||||
package gui
|
||||
|
||||
// raceOn says the tests run under -race, where sync.Pool lets a quarter of
|
||||
// what is put in it go (json's encoders, regexp's matchers), so a test of
|
||||
// how much a path allocates skips its bound.
|
||||
const raceOn = true
|
||||
@@ -88,6 +88,9 @@ func TestStateWrittenAsEncoded(t *testing.T) {
|
||||
// and for keepState's sum, growing a buffer to its size each time: 68 MB
|
||||
// of what twenty polls allocated. Each agent is encoded once now, alone.
|
||||
func TestStateWriteGrowsNoBufferItsSize(t *testing.T) {
|
||||
if raceOn {
|
||||
t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates")
|
||||
}
|
||||
s := bigState()
|
||||
w := &sinkWriter{}
|
||||
writeStateJSON(w, s) // json's encoders, warmed
|
||||
|
||||
@@ -87,6 +87,9 @@ func TestSameAnswerNotHeldWhole(t *testing.T) {
|
||||
// writeJSONRows holds no answer-sized buffer: the list goes out a row at a
|
||||
// time, and the whole answer was 25 MB of a warm start's live heap (#2278).
|
||||
func TestJSONRowsNotHeldWhole(t *testing.T) {
|
||||
if raceOn {
|
||||
t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates")
|
||||
}
|
||||
big := string(bytes.Repeat([]byte("x"), 64<<10))
|
||||
rows := make([]rowsBufRow, 64)
|
||||
for i := range rows {
|
||||
|
||||
Reference in New Issue
Block a user