Skip to content

Commit

Permalink
testiso.go: Add check for bad console/journal lines
Browse files Browse the repository at this point in the history
After tests are complete this checks for bad lines in the
console.txt and journal.txt files.

Ref: #3788

Co-authored-by: Dusty Mabe <[email protected]>
  • Loading branch information
c4rt0 and dustymabe committed Nov 12, 2024
1 parent 6813e3f commit 58df48e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion mantle/cmd/kola/testiso.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,47 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
}
}()
err := <-errchan
return time.Since(start), err
elapsed := time.Since(start)
if err == nil {
// No error so far, check the console and journal files
consoleFile := filepath.Join(outdir, "console.txt")
journalFile := filepath.Join(outdir, "journal.txt")
files := []string{consoleFile, journalFile}
for _, file := range files {
fileName := filepath.Base(file)
// Check if the file exists
_, err := os.Stat(file)
if os.IsNotExist(err) {
fmt.Printf("The file: %v does not exist\n", fileName)
continue
} else if err != nil {
fmt.Println(err)
return elapsed, err
}
// Read the contents of the file
fileContent, err := os.ReadFile(file)
if err != nil {
fmt.Println(err)
return elapsed, err
}
// Check for badness with CheckConsole
warnOnly, badlines := kola.CheckConsole([]byte(fileContent), nil)
if len(badlines) > 0 {
for _, badline := range badlines {
if warnOnly {
plog.Errorf("bad log line detected: %v", badline)
} else {
plog.Warningf("bad log line detected: %v", badline)
}
}
if !warnOnly {
err = fmt.Errorf("errors found in log files")
return elapsed, err
}
}
}
}
return elapsed, err
}

func printResult(test string, duration time.Duration, err error) bool {
Expand Down

0 comments on commit 58df48e

Please sign in to comment.