aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/trace
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-12-11 18:02:36 +0000
committerMichael Knyszek <mknyszek@google.com>2025-12-11 10:37:14 -0800
commit89614ad264803558cfa36d460d431f7cbd4bae47 (patch)
treee3997129ada427ea6921ea71728b3b5ed65dbf75 /src/runtime/trace
parentbb2337f24c8d774ef122e2251f02c5e512c77a55 (diff)
downloadgo-89614ad264803558cfa36d460d431f7cbd4bae47.tar.xz
runtime/trace: fix broken TestSubscribers
Currently we don't break out of the loop on a failure. This is leading to timeouts trying to parse a broken trace over and over, forever. But there's another issue where when we try to dump the trace, we pass only the unread portion of the bytes.Buffer. Change-Id: I1a338eea08eaf7f592fb7dd2a736a6fe0728c62d Reviewed-on: https://go-review.googlesource.com/c/go/+/729320 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/trace')
-rw-r--r--src/runtime/trace/subscribe_test.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/runtime/trace/subscribe_test.go b/src/runtime/trace/subscribe_test.go
index 6378c3401a..869ab0e75b 100644
--- a/src/runtime/trace/subscribe_test.go
+++ b/src/runtime/trace/subscribe_test.go
@@ -16,15 +16,15 @@ import (
)
func TestSubscribers(t *testing.T) {
- validate := func(t *testing.T, source string, tr *bytes.Buffer) {
+ validate := func(t *testing.T, source string, tr []byte) {
defer func() {
if t.Failed() {
- testtrace.Dump(t, "trace", tr.Bytes(), *dumpTraces)
+ testtrace.Dump(t, "trace", tr, *dumpTraces)
}
}()
// Prepare to read the trace snapshot.
- r, err := inttrace.NewReader(tr)
+ r, err := inttrace.NewReader(bytes.NewReader(tr))
if err != nil {
t.Errorf("unexpected error creating trace reader for %s: %v", source, err)
return
@@ -45,9 +45,11 @@ func TestSubscribers(t *testing.T) {
}
if err != nil {
t.Errorf("unexpected error reading trace for %s: %v", source, err)
+ break
}
if err := v.Event(ev); err != nil {
t.Errorf("event validation failed: %s", err)
+ break
}
if ev.Kind() == inttrace.EventSync {
syncs = append(syncs, evs)
@@ -64,8 +66,8 @@ func TestSubscribers(t *testing.T) {
}
validateTraces := func(t *testing.T, trace, frTrace *bytes.Buffer) {
- validate(t, "tracer", trace)
- validate(t, "flightRecorder", frTrace)
+ validate(t, "tracer", trace.Bytes())
+ validate(t, "flightRecorder", frTrace.Bytes())
}
startFlightRecorder := func(t *testing.T) *trace.FlightRecorder {
fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{})