feat: show relevant qemu output
This commit is contained in:
parent
7cb5877fd0
commit
a852e2d9e9
@ -337,10 +337,10 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo,
|
|||||||
slog.Debug().Str("duration", time.Since(start).String()).
|
slog.Debug().Str("duration", time.Since(start).String()).
|
||||||
Msg("build done")
|
Msg("build done")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error().Err(err).Msg("build")
|
slog.Error().Err(err).Msgf("build failure\n%v\n", result.Build.Output)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
slog.Info().Err(err).Msg("build success")
|
slog.Info().Msgf("build success\n%v\n", result.Build.Output)
|
||||||
}
|
}
|
||||||
result.Build.Ok = true
|
result.Build.Ok = true
|
||||||
} else {
|
} else {
|
||||||
@ -398,11 +398,26 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var qemuTestOutput string
|
||||||
|
q.SetOutputHandler(func(s string) {
|
||||||
|
qemuTestOutput += s + "\n"
|
||||||
|
})
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
copyArtifactAndTest(slog, q, ka, &result, remoteTest)
|
copyArtifactAndTest(slog, q, ka, &result, remoteTest)
|
||||||
slog.Debug().Str("duration", time.Since(start).String()).
|
slog.Debug().Str("duration", time.Since(start).String()).
|
||||||
Msgf("test completed (success: %v)", result.Test.Ok)
|
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 {
|
||||||
|
slog.Info().Msgf("qemu output\n%v\n", qemuTestOutput)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
q.CloseOutputHandler()
|
||||||
|
|
||||||
if !endless {
|
if !endless {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,6 @@ func (c Container) Run(workdir string, cmds []string) (out string, err error) {
|
|||||||
|
|
||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flog.Error().Msg(out)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,11 @@ type System struct {
|
|||||||
|
|
||||||
Stdout, Stderr string
|
Stdout, Stderr string
|
||||||
|
|
||||||
|
output struct {
|
||||||
|
listener chan string
|
||||||
|
mu sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
// accessible after qemu is closed
|
// accessible after qemu is closed
|
||||||
exitErr error
|
exitErr error
|
||||||
|
|
||||||
@ -138,6 +143,41 @@ func NewSystem(arch arch, kernel Kernel, drivePath string) (q *System, err error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// q.SetOutputHandler(func(s string) { fmt.Println(s) })
|
||||||
|
// defer q.CloseOutputHandler()
|
||||||
|
func (q *System) SetOutputHandler(handler func(s string)) {
|
||||||
|
q.output.mu.Lock()
|
||||||
|
defer q.output.mu.Unlock()
|
||||||
|
|
||||||
|
q.output.listener = make(chan string)
|
||||||
|
|
||||||
|
go func(l chan string) {
|
||||||
|
for m := range l {
|
||||||
|
handler(m)
|
||||||
|
}
|
||||||
|
}(q.output.listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *System) CloseOutputHandler() {
|
||||||
|
q.output.mu.Lock()
|
||||||
|
defer q.output.mu.Unlock()
|
||||||
|
|
||||||
|
close(q.output.listener)
|
||||||
|
q.output.listener = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *System) handleOutput(m string) {
|
||||||
|
if q.output.listener == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
q.output.mu.Lock()
|
||||||
|
defer q.output.mu.Unlock()
|
||||||
|
|
||||||
|
if q.output.listener != nil {
|
||||||
|
q.output.listener <- m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (q *System) SetSSHAddrPort(addr string, port int) (err error) {
|
func (q *System) SetSSHAddrPort(addr string, port int) (err error) {
|
||||||
// TODO validate
|
// TODO validate
|
||||||
q.SSH.AddrPort = fmt.Sprintf("%s:%d", addr, port)
|
q.SSH.AddrPort = fmt.Sprintf("%s:%d", addr, port)
|
||||||
@ -313,6 +353,7 @@ func (q *System) Start() (err error) {
|
|||||||
scanner := bufio.NewScanner(q.pipe.stdout)
|
scanner := bufio.NewScanner(q.pipe.stdout)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
m := scanner.Text()
|
m := scanner.Text()
|
||||||
|
q.handleOutput(m)
|
||||||
q.Stdout += m + "\n"
|
q.Stdout += m + "\n"
|
||||||
q.Log.Trace().Str("stdout", m).Msg("qemu")
|
q.Log.Trace().Str("stdout", m).Msg("qemu")
|
||||||
go q.checkOopsPanic(m)
|
go q.checkOopsPanic(m)
|
||||||
@ -323,6 +364,7 @@ func (q *System) Start() (err error) {
|
|||||||
scanner := bufio.NewScanner(q.pipe.stderr)
|
scanner := bufio.NewScanner(q.pipe.stderr)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
m := scanner.Text()
|
m := scanner.Text()
|
||||||
|
q.handleOutput(m)
|
||||||
q.Stderr += m + "\n"
|
q.Stderr += m + "\n"
|
||||||
q.Log.Trace().Str("stderr", m).Msg("qemu")
|
q.Log.Trace().Str("stderr", m).Msg("qemu")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user