@@ -63,7 +63,9 @@ func TestAnalyzeAnnotations(t *testing.T) {
63
63
// TODO: classify taskless spans
64
64
65
65
// Run prog0 and capture the execution trace.
66
- traceProgram (prog0 , "TestAnalyzeAnnotations" )
66
+ if err := traceProgram (prog0 , "TestAnalyzeAnnotations" ); err != nil {
67
+ t .Fatalf ("failed to trace the program: %v" , err )
68
+ }
67
69
68
70
res , err := analyzeAnnotations ()
69
71
if err != nil {
@@ -126,7 +128,9 @@ func prog1() {
126
128
127
129
func TestAnalyzeAnnotationTaskTree (t * testing.T ) {
128
130
// Run prog1 and capture the execution trace.
129
- traceProgram (prog1 , "TestAnalyzeAnnotationTaskTree" )
131
+ if err := traceProgram (prog1 , "TestAnalyzeAnnotationTaskTree" ); err != nil {
132
+ t .Fatalf ("failed to trace the program: %v" , err )
133
+ }
130
134
131
135
res , err := analyzeAnnotations ()
132
136
if err != nil {
@@ -208,12 +212,15 @@ func prog2() (gcTime time.Duration) {
208
212
209
213
func TestAnalyzeAnnotationGC (t * testing.T ) {
210
214
var gcTime time.Duration
211
- traceProgram (func () {
215
+ err := traceProgram (func () {
212
216
oldGC := debug .SetGCPercent (10000 ) // gc, and effectively disable GC
213
217
defer debug .SetGCPercent (oldGC )
214
218
215
219
gcTime = prog2 ()
216
220
}, "TestAnalyzeAnnotationGC" )
221
+ if err != nil {
222
+ t .Fatalf ("failed to trace the program: %v" , err )
223
+ }
217
224
218
225
res , err := analyzeAnnotations ()
219
226
if err != nil {
@@ -241,6 +248,13 @@ func TestAnalyzeAnnotationGC(t *testing.T) {
241
248
case "taskWithGC" :
242
249
if got <= 0 || got >= gcTime {
243
250
t .Errorf ("%s reported %v as overlapping GC time; want (0, %v): %v" , task .name , got , gcTime , task )
251
+ buf := new (bytes.Buffer )
252
+ fmt .Fprintln (buf , "GC Events" )
253
+ for _ , ev := range res .gcEvents {
254
+ fmt .Fprintf (buf , " %s\n " , ev )
255
+ }
256
+ fmt .Fprintf (buf , "%s\n " , task )
257
+ t .Logf ("%s" , buf )
244
258
}
245
259
case "taskWithoutGC" :
246
260
if got != 0 {
@@ -264,7 +278,7 @@ func traceProgram(f func(), name string) error {
264
278
trace .Stop ()
265
279
266
280
saveTrace (buf , name )
267
- res , err := traceparser .Parse (buf , " " )
281
+ res , err := traceparser .Parse (buf , name + ".faketrace " )
268
282
if err != nil {
269
283
return err
270
284
}
0 commit comments