Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions syz-cluster/workflow/boot-step/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
package main

import (
"bytes"
"context"
"flag"
"fmt"
"log"
"io"
"os"

"github.com/google/syzkaller/pkg/debugtracer"
"github.com/google/syzkaller/pkg/instance"
"github.com/google/syzkaller/pkg/mgrconfig"
"github.com/google/syzkaller/pkg/osutil"
Expand Down Expand Up @@ -50,10 +53,16 @@ func main() {
app.Fatalf("failed to upload test result: %v", err)
}

bootedFine, err := runTest(ctx, client)
output := new(bytes.Buffer)
tracer := &debugtracer.GenericTracer{
WithTime: true,
TraceWriter: io.MultiWriter(os.Stderr, output),
}
bootedFine, err := runTest(ctx, client, tracer)
if err != nil {
app.Fatalf("failed to run the boot test: %v", err)
}
testResult.Log = output.Bytes()
if bootedFine {
testResult.Result = api.TestPassed
} else {
Expand All @@ -79,7 +88,7 @@ const retryCount = 3
// The base config may have more VMs, but we don't need that many.
const vmCount = 3

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

var rep *report.Report
for i := 0; i < retryCount; i++ {
log.Printf("starting attempt #%d", i)
tracer.Log("starting attempt #%d", i)
var err error
rep, err = instance.RunSmokeTest(cfg)
if err != nil {
return false, err
} else if rep == nil {
return true, nil
}
log.Printf("attempt failed: %q", rep.Title)
tracer.Log("attempt failed: %q", rep.Title)
}
if *flagFindings {
log.Printf("reporting the finding")
tracer.Log("reporting the finding")
findingErr := client.UploadFinding(ctx, &api.NewFinding{
SessionID: *flagSession,
TestName: *flagTestName,
Expand All @@ -117,8 +126,8 @@ func runTest(ctx context.Context, client *api.Client) (bool, error) {
return false, fmt.Errorf("failed to report the finding: %w", findingErr)
}
} else {
log.Printf("report:\n%s", rep.Report)
log.Printf("output:\n%s", rep.Output)
tracer.Log("report:\n%s", rep.Report)
tracer.Log("output:\n%s", rep.Output)
}
return false, nil
}