From 5ece0e0f150f58ee20e83b6ef3a797564dab162a Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Wed, 22 Mar 2023 18:32:40 +0000 Subject: [PATCH] Add context for testing logs --- pew.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pew.go b/pew.go index 1fde278..5695329 100644 --- a/pew.go +++ b/pew.go @@ -19,6 +19,7 @@ import ( "github.com/otiai10/copy" "github.com/remeh/sizedwaitgroup" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "gopkg.in/logrusorgru/aurora.v2" @@ -394,14 +395,14 @@ func dumpResult(q *qemu.System, ka config.Artifact, ki config.KernelInfo, } } -func copyArtifactAndTest(q *qemu.System, ka config.Artifact, +func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka config.Artifact, res *phasesResult, remoteTest string) (err error) { switch ka.Type { case config.KernelModule: res.Run.Output, err = q.CopyAndInsmod(res.BuildArtifact) if err != nil { - log.Error().Err(err).Msg(res.Run.Output) + slog.Error().Err(err).Msg(res.Run.Output) return } res.Run.Ok = true @@ -413,14 +414,14 @@ func copyArtifactAndTest(q *qemu.System, ka config.Artifact, } err = q.CopyFile(f.User, f.Local, f.Remote) if err != nil { - log.Error().Err(err).Msg("copy test file") + slog.Error().Err(err).Msg("copy test file") return } } res.Test.Output, err = testKernelModule(q, ka, remoteTest) if err != nil { - log.Error().Err(err).Msg(res.Test.Output) + slog.Error().Err(err).Msg(res.Test.Output) return } res.Test.Ok = true @@ -434,13 +435,13 @@ func copyArtifactAndTest(q *qemu.System, ka config.Artifact, res.Test.Output, err = testKernelExploit(q, ka, remoteTest, remoteExploit) if err != nil { - log.Error().Err(err).Msg(res.Test.Output) + slog.Error().Err(err).Msg(res.Test.Output) return } res.Run.Ok = true // does not really used res.Test.Ok = true default: - log.Fatal().Msg("Unsupported artifact type") + slog.Fatal().Msg("Unsupported artifact type") } return @@ -620,7 +621,7 @@ func testArtifact(swg *sizedwaitgroup.SizedWaitGroup, ka config.Artifact, } start := time.Now() - copyArtifactAndTest(q, ka, &result, remoteTest) + copyArtifactAndTest(slog, q, ka, &result, remoteTest) slog.Debug().Str("duration", time.Now().Sub(start).String()). Msg("test completed") }