@@ -675,59 +675,85 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
675675 err = platform .ErrInitramfsEmergency
676676 }
677677 }
678+ }()
679+ go func () {
680+ err := inst .Wait ()
681+ // only one Wait() gets process data, so also manually check for signal
682+ plog .Debugf ("qemu exited err=%v" , err )
683+ if err == nil && inst .Signaled () {
684+ err = errors .New ("process killed" )
685+ }
678686 if err != nil {
679- errchan <- err
687+ errchan <- errors . Wrapf ( err , "QEMU unexpectedly exited while awaiting completion" )
680688 }
689+ time .Sleep (1 * time .Minute )
690+ errchan <- fmt .Errorf ("QEMU exited; timed out waiting for completion" )
681691 }()
682- }
683- go func () {
684- err := inst .Wait ()
685- // only one Wait() gets process data, so also manually check for signal
686- plog .Debugf ("qemu exited err=%v" , err )
687- if err == nil && inst .Signaled () {
688- err = errors .New ("process killed" )
689- }
690- if err != nil {
691- errchan <- errors .Wrapf (err , "QEMU unexpectedly exited while awaiting completion" )
692- }
693- time .Sleep (1 * time .Minute )
694- errchan <- fmt .Errorf ("QEMU exited; timed out waiting for completion" )
695- }()
696- go func () {
697- r := bufio .NewReader (qchan )
698- for _ , exp := range expected {
699- l , err := r .ReadString ('\n' )
700- if err != nil {
701- if err == io .EOF {
702- // this may be from QEMU getting killed or exiting; wait a bit
703- // to give a chance for .Wait() above to feed the channel with a
704- // better error
705- time .Sleep (1 * time .Second )
706- errchan <- fmt .Errorf ("Got EOF from completion channel, %s expected" , exp )
707- } else {
708- errchan <- errors .Wrapf (err , "reading from completion channel" )
692+ go func () {
693+ r := bufio .NewReader (qchan )
694+ for _ , exp := range expected {
695+ l , err := r .ReadString ('\n' )
696+ if err != nil {
697+ if err == io .EOF {
698+ // this may be from QEMU getting killed or exiting; wait a bit
699+ // to give a chance for .Wait() above to feed the channel with a
700+ // better error
701+ time .Sleep (1 * time .Second )
702+ errchan <- fmt .Errorf ("Got EOF from completion channel, %s expected" , exp )
703+ } else {
704+ errchan <- errors .Wrapf (err , "reading from completion channel" )
705+ }
706+ return
707+ }
708+ line := strings .TrimSpace (l )
709+ if line != exp {
710+ errchan <- fmt .Errorf ("Unexpected string from completion channel: %s expected: %s" , line , exp )
711+ return
709712 }
710- return
713+ plog . Debugf ( "Matched expected message %s" , exp )
711714 }
712- line := strings .TrimSpace (l )
713- if line != exp {
714- errchan <- fmt .Errorf ("Unexpected string from completion channel: %s expected: %s" , line , exp )
715- return
715+ plog .Debugf ("Matched all expected messages" )
716+ // OK!
717+ errchan <- nil
718+ }()
719+ go func () {
720+ //check for error when switching boot order
721+ if booterrchan != nil {
722+ if err := <- booterrchan ; err != nil {
723+ errchan <- err
724+ }
716725 }
717- plog .Debugf ("Matched expected message %s" , exp )
718- }
719- plog .Debugf ("Matched all expected messages" )
720- // OK!
721- errchan <- nil
722- }()
723- go func () {
724- //check for error when switching boot order
725- if booterrchan != nil {
726- if err := <- booterrchan ; err != nil {
727- errchan <- err
726+ }()
727+ go func () {
728+ err := <- errchan
729+ if err == nil {
730+ // No error so far, check the console and journal files
731+ files := []string {filepath .Join (outdir , "console.txt" ), filepath .Join (outdir , "journal.txt" )}
732+ for _ , file := range files {
733+ // Read the contents of the file
734+ fileContent , err := inst .ReadFile (file )
735+ if err != nil {
736+ fmt .Printf ("error reading file %s: %v\n " , file , err )
737+ return
738+ }
739+ // Check for badness with CheckConsole
740+ warnOnly , badlines := kola .CheckConsole ([]byte (fileContent ), nil )
741+ if len (badlines ) > 0 {
742+ err = fmt .Errorf ("errors found in console file: %v" , badlines )
743+ for _ , badline := range badlines {
744+ if err != nil {
745+ fmt .Printf ("badness detected in console file: %v\n " , badline )
746+ }
747+ }
748+ errchan <- err
749+ } else if warnOnly {
750+ fmt .Println ("warnings found in console file" )
751+ continue
752+ }
753+ }
728754 }
729- }
730- }()
755+ }()
756+ }
731757 err := <- errchan
732758 return time .Since (start ), err
733759}
0 commit comments