diff options
Diffstat (limited to 'syz-ci')
| -rw-r--r-- | syz-ci/jobs.go | 20 | ||||
| -rw-r--r-- | syz-ci/manager.go | 24 | ||||
| -rw-r--r-- | syz-ci/updater.go | 4 |
3 files changed, 29 insertions, 19 deletions
diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go index 203a7a8e3..89276c04e 100644 --- a/syz-ci/jobs.go +++ b/syz-ci/jobs.go @@ -5,6 +5,7 @@ package main import ( "bytes" + "errors" "fmt" "io" "os" @@ -517,7 +518,8 @@ func (jp *JobProcessor) bisect(job *Job, mgrcfg *mgrconfig.Config) error { res, err := bisect.Run(cfg) resp.Log = trace.Bytes() if err != nil { - if _, ok := err.(*bisect.InfraError); ok { + var infraErr *bisect.InfraError + if errors.As(err, &infraErr) { resp.Flags |= dashapi.BisectResultInfraError } return err @@ -735,18 +737,20 @@ func aggregateTestResults(results []instance.EnvTestResult) (*patchTestResult, e continue } anyErr = res.Error - switch err := res.Error.(type) { - case *instance.TestError: + var testError *instance.TestError + var crashError *instance.CrashError + switch { + case errors.As(res.Error, &testError): // We should not put rep into resp.CrashTitle/CrashReport, // because that will be treated as patch not fixing the bug. - if rep := err.Report; rep != nil { + if rep := testError.Report; rep != nil { testErr = fmt.Errorf("%v\n\n%s\n\n%s", rep.Title, rep.Report, rep.Output) } else { - testErr = fmt.Errorf("%v\n\n%s", err.Title, err.Output) + testErr = fmt.Errorf("%v\n\n%s", testError.Title, testError.Output) } - case *instance.CrashError: - if resReport == nil || (len(resReport.report.Report) == 0 && len(err.Report.Report) != 0) { - resReport = &patchTestResult{report: err.Report, rawOutput: res.RawOutput} + case errors.As(res.Error, &crashError): + if resReport == nil || (len(resReport.report.Report) == 0 && len(crashError.Report.Report) != 0) { + resReport = &patchTestResult{report: crashError.Report, rawOutput: res.RawOutput} } } } diff --git a/syz-ci/manager.go b/syz-ci/manager.go index 14dd6114c..13f8768e1 100644 --- a/syz-ci/manager.go +++ b/syz-ci/manager.go @@ -5,6 +5,7 @@ package main import ( "crypto/sha256" + "errors" "fmt" "io" "net/http" @@ -339,14 +340,16 @@ func (mgr *Manager) build(kernelCommit *vcs.Commit) error { rep := &report.Report{ Title: fmt.Sprintf("%v build error", mgr.mgrcfg.RepoAlias), } - switch err1 := err.(type) { - case *build.KernelError: - rep.Report = err1.Report - rep.Output = err1.Output - rep.Recipients = err1.Recipients - case *osutil.VerboseError: - rep.Report = []byte(err1.Title) - rep.Output = err1.Output + var kernelError *build.KernelError + var verboseError *osutil.VerboseError + switch { + case errors.As(err, &kernelError): + rep.Report = kernelError.Report + rep.Output = kernelError.Output + rep.Recipients = kernelError.Recipients + case errors.As(err, &verboseError): + rep.Report = []byte(verboseError.Title) + rep.Output = verboseError.Output default: rep.Report = []byte(err.Error()) } @@ -437,8 +440,9 @@ func (mgr *Manager) testImage(imageDir string, info *BuildInfo) error { continue } failures++ - switch err := res.Error.(type) { - case *instance.TestError: + var err *instance.TestError + switch { + case errors.As(res.Error, &err): if rep := err.Report; rep != nil { what := "test" if err.Boot { diff --git a/syz-ci/updater.go b/syz-ci/updater.go index 1d632ddcd..41d6d48f9 100644 --- a/syz-ci/updater.go +++ b/syz-ci/updater.go @@ -4,6 +4,7 @@ package main import ( + "errors" "fmt" "os" "path/filepath" @@ -297,7 +298,8 @@ func (upd *SyzUpdater) build(commit *vcs.Commit) error { func (upd *SyzUpdater) uploadBuildError(commit *vcs.Commit, buildErr error) { var title string var output []byte - if verbose, ok := buildErr.(*osutil.VerboseError); ok { + var verbose *osutil.VerboseError + if errors.As(buildErr, &verbose) { title = verbose.Title output = verbose.Output } else { |
