Skip to content

Commit ce4c2cf

Browse files
rhyshgopherbot
authored andcommitted
trace: re-enable Sync event test
For golang/go#73558 Change-Id: I27bf3916b13af581c68921b3719c330ec4db9827 Reviewed-on: https://go-review.googlesource.com/c/exp/+/669259 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Rhys Hiltner <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 3e021d5 commit ce4c2cf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

trace/flightrecorder_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"context"
1212
"io"
1313
"runtime/trace"
14+
"slices"
1415
"sync"
1516
"sync/atomic"
1617
"testing"
@@ -196,7 +197,6 @@ func TestFlightRecorderLog(t *testing.T) {
196197
}
197198

198199
func TestFlightRecorderOneGeneration(t *testing.T) {
199-
t.Skip("requires update for Go 1.25's additional Sync event, go.dev/issue/73558")
200200
test := func(t *testing.T, fr *FlightRecorder) {
201201
tr := testFlightRecorder(t, fr, func(snapshot func()) {
202202
// Sleep to let a few generations pass.
@@ -210,8 +210,9 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
210210
t.Fatalf("unexpected error creating trace reader: %v", err)
211211
}
212212

213-
// Make sure there's only exactly one Sync event.
214-
sync := 0
213+
// Make sure there are exactly two Sync events: at the start and end.
214+
var syncs []int
215+
evs := 0
215216
for {
216217
ev, err := r.ReadEvent()
217218
if err == io.EOF {
@@ -221,11 +222,13 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
221222
t.Fatalf("unexpected error reading trace: %v", err)
222223
}
223224
if ev.Kind() == EventSync {
224-
sync++
225+
syncs = append(syncs, evs)
225226
}
227+
evs++
226228
}
227-
if sync != 1 {
228-
t.Errorf("expected one sync event, found %d", sync)
229+
if ends := []int{0, evs - 1}; !slices.Equal(syncs, ends) {
230+
t.Errorf("expected two sync events (one at each end of the trace), found %d at %d instead of %d",
231+
len(syncs), syncs[:min(len(syncs), 5)], ends)
229232
}
230233
}
231234
t.Run("SetPeriod", func(t *testing.T) {

0 commit comments

Comments
 (0)