feat: realtime output
This commit is contained in:
@ -240,8 +240,9 @@ func (ka Artifact) Supported(ki distro.KernelInfo) (supported bool, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO too many parameters
|
||||
func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo,
|
||||
outputOnSuccess, endless bool, cBinary,
|
||||
outputOnSuccess, realtimeOutput, endless bool, cBinary,
|
||||
cEndlessStress string, cEndlessTimeout time.Duration,
|
||||
dump func(q *qemu.System, ka Artifact, ki distro.KernelInfo,
|
||||
result *Result)) {
|
||||
@ -340,7 +341,7 @@ 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 {
|
||||
if outputOnSuccess {
|
||||
if outputOnSuccess && !realtimeOutput {
|
||||
slog.Info().Msgf("build success\n%v\n", result.Build.Output)
|
||||
} else {
|
||||
slog.Info().Msg("build success")
|
||||
@ -403,24 +404,37 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo,
|
||||
}
|
||||
|
||||
var qemuTestOutput string
|
||||
q.SetOutputHandler(func(s string) {
|
||||
qemuTestOutput += s + "\n"
|
||||
q.SetQemuOutputHandler(func(s string) {
|
||||
if realtimeOutput {
|
||||
fmt.Printf("kmsg: %s\n", s)
|
||||
} else {
|
||||
qemuTestOutput += s + "\n"
|
||||
}
|
||||
})
|
||||
|
||||
if realtimeOutput {
|
||||
q.SetCommandsOutputHandler(func(s string) {
|
||||
fmt.Printf("test: %s\n", s)
|
||||
})
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
copyArtifactAndTest(slog, q, ka, &result, remoteTest, outputOnSuccess)
|
||||
copyArtifactAndTest(slog, q, ka, &result, remoteTest, outputOnSuccess, realtimeOutput)
|
||||
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 if outputOnSuccess {
|
||||
} else if outputOnSuccess && !realtimeOutput {
|
||||
slog.Info().Msgf("qemu output\n%v\n", qemuTestOutput)
|
||||
}
|
||||
}
|
||||
|
||||
q.CloseOutputHandler()
|
||||
if realtimeOutput {
|
||||
q.CloseCommandsOutputHandler()
|
||||
}
|
||||
q.CloseQemuOutputHandler()
|
||||
|
||||
if !endless {
|
||||
return
|
||||
|
@ -157,9 +157,15 @@ func Build(flog zerolog.Logger, tmp string, ka Artifact,
|
||||
|
||||
c.Args = append(c.Args, "--network", "none")
|
||||
|
||||
c.SetCommandsOutputHandler(func(s string) {
|
||||
fmt.Printf("%s\n", s)
|
||||
})
|
||||
|
||||
output, err = c.Run(outdir, []string{
|
||||
buildCommand + " && chmod -R 777 /work",
|
||||
})
|
||||
|
||||
c.CloseCommandsOutputHandler()
|
||||
} else {
|
||||
cmd := exec.Command("bash", "-c", "cd "+outdir+" && "+
|
||||
buildCommand)
|
||||
@ -281,7 +287,7 @@ func CopyFile(sourcePath, destinationPath string) (err error) {
|
||||
}
|
||||
|
||||
func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact,
|
||||
res *Result, remoteTest string, outputOnSuccess bool) (err error) {
|
||||
res *Result, remoteTest string, outputOnSuccess, realtimeOutput bool) (err error) {
|
||||
|
||||
// Copy all test files to the remote machine
|
||||
for _, f := range ka.TestFiles {
|
||||
@ -346,7 +352,7 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact,
|
||||
return
|
||||
}
|
||||
|
||||
if outputOnSuccess {
|
||||
if outputOnSuccess && !realtimeOutput {
|
||||
slog.Info().Msgf("test success\n%v\n", res.Test.Output)
|
||||
} else {
|
||||
slog.Info().Msg("test success")
|
||||
|
Reference in New Issue
Block a user