Skip to content

Commit 0852935

Browse files
committed
syz-cluster: improve boot test logging
Collect trace logs and make them accessible via the web UI.
1 parent 52ed5c9 commit 0852935

File tree

1 file changed

+17
-8
lines changed
  • syz-cluster/workflow/boot-step

1 file changed

+17
-8
lines changed

syz-cluster/workflow/boot-step/main.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
package main
55

66
import (
7+
"bytes"
78
"context"
89
"flag"
910
"fmt"
10-
"log"
11+
"io"
12+
"os"
1113

14+
"github.com/google/syzkaller/pkg/debugtracer"
1215
"github.com/google/syzkaller/pkg/instance"
1316
"github.com/google/syzkaller/pkg/mgrconfig"
1417
"github.com/google/syzkaller/pkg/osutil"
@@ -50,10 +53,16 @@ func main() {
5053
app.Fatalf("failed to upload test result: %v", err)
5154
}
5255

53-
bootedFine, err := runTest(ctx, client)
56+
output := new(bytes.Buffer)
57+
tracer := &debugtracer.GenericTracer{
58+
WithTime: true,
59+
TraceWriter: io.MultiWriter(os.Stdout, output),
60+
}
61+
bootedFine, err := runTest(ctx, client, tracer)
5462
if err != nil {
5563
app.Fatalf("failed to run the boot test: %v", err)
5664
}
65+
testResult.Log = output.Bytes()
5766
if bootedFine {
5867
testResult.Result = api.TestPassed
5968
} else {
@@ -79,7 +88,7 @@ const retryCount = 3
7988
// The base config may have more VMs, but we don't need that many.
8089
const vmCount = 3
8190

82-
func runTest(ctx context.Context, client *api.Client) (bool, error) {
91+
func runTest(ctx context.Context, client *api.Client, tracer debugtracer.DebugTracer) (bool, error) {
8392
cfg, err := fuzzconfig.GenerateBase(&api.FuzzConfig{})
8493
if err != nil {
8594
return false, err
@@ -94,18 +103,18 @@ func runTest(ctx context.Context, client *api.Client) (bool, error) {
94103

95104
var rep *report.Report
96105
for i := 0; i < retryCount; i++ {
97-
log.Printf("starting attempt #%d", i)
106+
tracer.Log("starting attempt #%d", i)
98107
var err error
99108
rep, err = instance.RunSmokeTest(cfg)
100109
if err != nil {
101110
return false, err
102111
} else if rep == nil {
103112
return true, nil
104113
}
105-
log.Printf("attempt failed: %q", rep.Title)
114+
tracer.Log("attempt failed: %q", rep.Title)
106115
}
107116
if *flagFindings {
108-
log.Printf("reporting the finding")
117+
tracer.Log("reporting the finding")
109118
findingErr := client.UploadFinding(ctx, &api.NewFinding{
110119
SessionID: *flagSession,
111120
TestName: *flagTestName,
@@ -117,8 +126,8 @@ func runTest(ctx context.Context, client *api.Client) (bool, error) {
117126
return false, fmt.Errorf("failed to report the finding: %w", findingErr)
118127
}
119128
} else {
120-
log.Printf("report:\n%s", rep.Report)
121-
log.Printf("output:\n%s", rep.Output)
129+
tracer.Log("report:\n%s", rep.Report)
130+
tracer.Log("output:\n%s", rep.Output)
122131
}
123132
return false, nil
124133
}

0 commit comments

Comments
 (0)