From fee3b44c6e4cb910c27f0df8baad0f334874bad7 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Mon, 7 Oct 2024 20:59:16 +0000 Subject: [PATCH] feat: parameter to display the output of successful stages --- artifact/artifact.go | 12 ++++++++---- artifact/process.go | 8 ++++++-- cmd/pew.go | 4 +++- daemon/process.go | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/artifact/artifact.go b/artifact/artifact.go index 16eecfb..5cac7c2 100644 --- a/artifact/artifact.go +++ b/artifact/artifact.go @@ -241,7 +241,7 @@ func (ka Artifact) Supported(ki distro.KernelInfo) (supported bool, err error) { } func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo, - endless bool, cBinary, + outputOnSuccess, endless bool, cBinary, cEndlessStress string, cEndlessTimeout time.Duration, dump func(q *qemu.System, ka Artifact, ki distro.KernelInfo, result *Result)) { @@ -340,7 +340,11 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo, slog.Error().Err(err).Msgf("build failure\n%v\n", result.Build.Output) return } else { - slog.Info().Msgf("build success\n%v\n", result.Build.Output) + if outputOnSuccess { + slog.Info().Msgf("build success\n%v\n", result.Build.Output) + } else { + slog.Info().Msg("build success") + } } result.Build.Ok = true } else { @@ -404,14 +408,14 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo, }) start := time.Now() - copyArtifactAndTest(slog, q, ka, &result, remoteTest) + copyArtifactAndTest(slog, q, ka, &result, remoteTest, outputOnSuccess) slog.Debug().Str("duration", time.Since(start).String()). Msgf("test completed (success: %v)", result.Test.Ok) if result.Build.Ok { if !result.Run.Ok || !result.Test.Ok { slog.Error().Msgf("qemu output\n%v\n", qemuTestOutput) - } else { + } else if outputOnSuccess { slog.Info().Msgf("qemu output\n%v\n", qemuTestOutput) } } diff --git a/artifact/process.go b/artifact/process.go index 80b360d..b7d4b18 100644 --- a/artifact/process.go +++ b/artifact/process.go @@ -281,7 +281,7 @@ func CopyFile(sourcePath, destinationPath string) (err error) { } func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact, - res *Result, remoteTest string) (err error) { + res *Result, remoteTest string, outputOnSuccess bool) (err error) { // Copy all test files to the remote machine for _, f := range ka.TestFiles { @@ -346,7 +346,11 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact, return } - slog.Info().Msgf("test success\n%v\n", res.Test.Output) + if outputOnSuccess { + slog.Info().Msgf("test success\n%v\n", res.Test.Output) + } else { + slog.Info().Msg("test success") + } _, err = q.Command("root", "echo") if err != nil { diff --git a/cmd/pew.go b/cmd/pew.go index 3315ea7..2ff2883 100644 --- a/cmd/pew.go +++ b/cmd/pew.go @@ -87,6 +87,8 @@ type PewCmd struct { Threshold float64 `help:"reliablity threshold for exit code" default:"1.00"` IncludeInternalErrors bool `help:"count internal errors as part of the success rate"` + OutputOnSuccess bool `help:"show output on success"` + Endless bool `help:"endless tests"` EndlessTimeout time.Duration `help:"timeout between tests" default:"1m"` EndlessStress string `help:"endless stress script" type:"existingfile"` @@ -445,7 +447,7 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup, Str("kernel", ki.KernelRelease). Logger() - ka.Process(slog, ki, + ka.Process(slog, ki, cmd.OutputOnSuccess, cmd.Endless, cmd.Binary, cmd.EndlessStress, cmd.EndlessTimeout, func(q *qemu.System, ka artifact.Artifact, ki distro.KernelInfo, result *artifact.Result) { dumpResult(q, ka, ki, result, cmd.Dist, cmd.Tag, cmd.Binary, cmd.DB) diff --git a/daemon/process.go b/daemon/process.go index bb0b4de..b7572d4 100644 --- a/daemon/process.go +++ b/daemon/process.go @@ -131,7 +131,7 @@ func (pj *jobProcessor) Process(res *Resources) (err error) { var result *artifact.Result var dq *qemu.System - pj.job.Artifact.Process(pj.log, pj.job.Target, false, "", "", 0, + pj.job.Artifact.Process(pj.log, pj.job.Target, false, false, "", "", 0, func(q *qemu.System, ka artifact.Artifact, ki distro.KernelInfo, res *artifact.Result) {