refactor: debug logging
This commit is contained in:
parent
67ffa2347a
commit
d43cd36858
@ -299,6 +299,7 @@ func (q *System) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
q.Log.Debug().Msg("start qemu")
|
||||||
err = q.cmd.Start()
|
err = q.cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -326,6 +327,7 @@ func (q *System) Start() (err error) {
|
|||||||
go func() {
|
go func() {
|
||||||
q.exitErr = q.cmd.Wait()
|
q.exitErr = q.cmd.Wait()
|
||||||
q.Died = true
|
q.Died = true
|
||||||
|
q.Log.Debug().Msg("qemu died")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
time.Sleep(time.Second / 10) // wait for immediately die
|
time.Sleep(time.Second / 10) // wait for immediately die
|
||||||
@ -347,6 +349,8 @@ func (q *System) Start() (err error) {
|
|||||||
|
|
||||||
// Stop qemu process
|
// Stop qemu process
|
||||||
func (q *System) Stop() {
|
func (q *System) Stop() {
|
||||||
|
q.Log.Debug().Msg("stop qemu process")
|
||||||
|
|
||||||
// 1 00/01 01 01 SOH (Ctrl-A) START OF HEADING
|
// 1 00/01 01 01 SOH (Ctrl-A) START OF HEADING
|
||||||
fmt.Fprintf(q.pipe.stdin, "%cx", 1)
|
fmt.Fprintf(q.pipe.stdin, "%cx", 1)
|
||||||
// wait for die
|
// wait for die
|
||||||
@ -359,6 +363,8 @@ func (q *System) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *System) WaitForSSH(timeout time.Duration) error {
|
func (q *System) WaitForSSH(timeout time.Duration) error {
|
||||||
|
q.Log.Debug().Msg("wait for ssh")
|
||||||
|
|
||||||
for start := time.Now(); time.Since(start) < timeout; {
|
for start := time.Now(); time.Since(start) < timeout; {
|
||||||
time.Sleep(time.Second / 4)
|
time.Sleep(time.Second / 4)
|
||||||
|
|
||||||
@ -368,18 +374,21 @@ func (q *System) WaitForSSH(timeout time.Duration) error {
|
|||||||
|
|
||||||
client, err := q.ssh("root")
|
client, err := q.ssh("root")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
q.Log.Debug().Err(err).Msg("")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
session, err := client.NewSession()
|
session, err := client.NewSession()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Close()
|
client.Close()
|
||||||
|
q.Log.Debug().Err(err).Msg("")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = session.CombinedOutput("echo")
|
_, err = session.CombinedOutput("echo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Close()
|
client.Close()
|
||||||
|
q.Log.Debug().Err(err).Msg("")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ func TestSystemCopyFile(t *testing.T) {
|
|||||||
shaRemote = strings.Split(shaRemote, " ")[0]
|
shaRemote = strings.Split(shaRemote, " ")[0]
|
||||||
|
|
||||||
if shaLocal != shaRemote {
|
if shaLocal != shaRemote {
|
||||||
t.Fatal(fmt.Sprintf("Broken file (%s instead of %s)",
|
t.Fatalf("Broken file (%s instead of %s)",
|
||||||
shaRemote, shaLocal))
|
shaRemote, shaLocal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user