wgengine/magicsock: fix data race in TestSetDERPMapDoReStun
SetDERPMap spawns a goroutine that calls ReSTUN, which logs via the test logger. If the test returns before that goroutine logs, the goroutine races with testing cleanup. Use tstest.WhileTestRunningLogger so the goroutine's logf call becomes a no-op once the test finishes. Fixes #19829 Change-Id: I1097f98e40ffd1c5dd7fb7a715c918255853e3c6 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
7ebca58042
commit
2703f91174
@@ -106,7 +106,9 @@ func TestSetDERPMapDoReStun(t *testing.T) {
|
||||
|
||||
bus := eventbustest.NewBus(t)
|
||||
ht := health.NewTracker(bus)
|
||||
c := newConn(t.Logf)
|
||||
// Use WhileTestRunningLogger so the goroutine spawned by setDERPMap
|
||||
// (which calls ReSTUN, which logs) doesn't race with test cleanup.
|
||||
c := newConn(tstest.WhileTestRunningLogger(t))
|
||||
ec := bus.Client("magicsock.Conn.Test")
|
||||
c.eventClient = ec
|
||||
c.homeDERPChangedPub = eventbus.Publish[HomeDERPChanged](ec)
|
||||
|
||||
Reference in New Issue
Block a user