1
0

Add context for testing logs

This commit is contained in:
dump_stack() 2023-03-22 18:32:40 +00:00
parent 2150162e8e
commit 5ece0e0f15
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

15
pew.go
View File

@ -19,6 +19,7 @@ import (
"github.com/otiai10/copy" "github.com/otiai10/copy"
"github.com/remeh/sizedwaitgroup" "github.com/remeh/sizedwaitgroup"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"gopkg.in/logrusorgru/aurora.v2" "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) { res *phasesResult, remoteTest string) (err error) {
switch ka.Type { switch ka.Type {
case config.KernelModule: case config.KernelModule:
res.Run.Output, err = q.CopyAndInsmod(res.BuildArtifact) res.Run.Output, err = q.CopyAndInsmod(res.BuildArtifact)
if err != nil { if err != nil {
log.Error().Err(err).Msg(res.Run.Output) slog.Error().Err(err).Msg(res.Run.Output)
return return
} }
res.Run.Ok = true 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) err = q.CopyFile(f.User, f.Local, f.Remote)
if err != nil { if err != nil {
log.Error().Err(err).Msg("copy test file") slog.Error().Err(err).Msg("copy test file")
return return
} }
} }
res.Test.Output, err = testKernelModule(q, ka, remoteTest) res.Test.Output, err = testKernelModule(q, ka, remoteTest)
if err != nil { if err != nil {
log.Error().Err(err).Msg(res.Test.Output) slog.Error().Err(err).Msg(res.Test.Output)
return return
} }
res.Test.Ok = true res.Test.Ok = true
@ -434,13 +435,13 @@ func copyArtifactAndTest(q *qemu.System, ka config.Artifact,
res.Test.Output, err = testKernelExploit(q, ka, remoteTest, res.Test.Output, err = testKernelExploit(q, ka, remoteTest,
remoteExploit) remoteExploit)
if err != nil { if err != nil {
log.Error().Err(err).Msg(res.Test.Output) slog.Error().Err(err).Msg(res.Test.Output)
return return
} }
res.Run.Ok = true // does not really used res.Run.Ok = true // does not really used
res.Test.Ok = true res.Test.Ok = true
default: default:
log.Fatal().Msg("Unsupported artifact type") slog.Fatal().Msg("Unsupported artifact type")
} }
return return
@ -620,7 +621,7 @@ func testArtifact(swg *sizedwaitgroup.SizedWaitGroup, ka config.Artifact,
} }
start := time.Now() start := time.Now()
copyArtifactAndTest(q, ka, &result, remoteTest) copyArtifactAndTest(slog, q, ka, &result, remoteTest)
slog.Debug().Str("duration", time.Now().Sub(start).String()). slog.Debug().Str("duration", time.Now().Sub(start).String()).
Msg("test completed") Msg("test completed")
} }