Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
c4rt0 committed Sep 16, 2024
1 parent 857743c commit 05f3bdd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 37 deletions.
51 changes: 50 additions & 1 deletion mantle/cmd/kola/testiso.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,56 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
errchan <- err
}
}()
// check for console badness

go func() {

// errBuf, err := inst.CheckConsoleForBadness(ctx)
// if err == nil {
// if errBuf != "" {
// plog.Info("Badness recognized")
// path := filepath.Join(outdir, "test.txt")
// if err := os.WriteFile(path, []byte(errBuf), 0644); err != nil {
// plog.Errorf("Failed to write to consolefile: %v", err)
// }
// err = platform.ErrInitramfsEmergency
// }
// }
// if err != nil {
// errchan <- err
// }

// }()
// figure out how to get console file from instance
builder := platform.NewMetalQemuBuilderDefault()
if enableUefiSecure {
builder.Firmware = "uefi-secure"
} else if enableUefi {
builder.Firmware = "uefi"
}

if err := os.MkdirAll(outdir, 0755); err != nil {
fmt.Println(err)
}

builder.InheritConsole = console
if !console {
builder.ConsoleFile = filepath.Join(outdir, "console.txt")
}

fmt.Println(builder)
// var inst = *builder.ConsoleFile
// fmt.Println(&inst)
// below something like
// inst.builder.ConsoleFile

// zz, err := inst.CheckConsoleForBadness(ctx)
// fmt.Println(zz,err)

//plus that
// ReadFile(path/tofile...)
// path := filepath.Base(outdir) // returns test name / dir

}()
errBuf, err := inst.CheckConsoleForBadness(ctx)
if err == nil {
if errBuf != "" {
Expand Down
52 changes: 16 additions & 36 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,33 +1919,30 @@ func ScpKolet(machines []platform.Machine) error {


// CheckConsoleText checks console output for badness
func CheckConsoleText(badlines []string) (bool, []string) {
badness := false
newBadlines := []string{}
// input : the console content
// output true if badlines were found and the bad lines.
func CheckConsoleText(input []byte) (bool, []string) {
warnOnly := true
badlines := []string{}

// Ensure there are enough badlines to check
if len(badlines) < 2 {
return badness, badlines // Return early if not enough lines
}
for _, check := range consoleChecks {
if check.skipFlag != nil {
continue
}
match := check.match.FindStringSubmatch(badlines[1])
match := check.match.FindSubmatch(input)
if match != nil {
badline := check.desc
if len(match) > 1 {
// include first subexpression
badline += fmt.Sprintf(" (%v)", match[1])
}
newBadlines = append(newBadlines, badline)
badlines = append(badlines, badline)
if !check.warnOnly {
badness = false
warnOnly = false
}
}
}
badlines = append(badlines, newBadlines...)
return badness, badlines
return warnOnly, badlines
}

// CheckConsole checks some console output for badness and returns short
Expand All @@ -1956,33 +1953,16 @@ func CheckConsoleText(badlines []string) (bool, []string) {
// rerun success.
func CheckConsole(output []byte, t *register.Test) (bool, []string) {
var badlines []string
warnOnly, allowRerunSuccess := true, true
for _, check := range consoleChecks {
if check.skipFlag != nil && t != nil && t.HasFlag(*check.skipFlag) {
continue
}
match := check.match.FindSubmatch(output)
if match != nil {
badline := check.desc
if len(match) > 1 {
// include first subexpression
badline += fmt.Sprintf(" (%s)", match[1])
}
badlines = append(badlines, badline)
if !check.warnOnly {
warnOnly = false
}
if !check.allowRerunSuccess {
allowRerunSuccess = false
}
is_it_err,checkConsole := CheckConsoleText([]string(badlines))
fmt.Printf("%v\n,%v", checkConsole, is_it_err)
}
}
var badness bool
allowRerunSuccess := true

//here pass output to checkconsoleText
badness, badlines = CheckConsoleText(output)

if len(badlines) > 0 && allowRerunSuccess && t != nil {
markTestForRerunSuccess(t, "CheckConsole:")
}
return warnOnly, badlines
return badness, badlines
}

func SetupOutputDir(outputDir, platform string) (string, error) {
Expand Down

0 comments on commit 05f3bdd

Please sign in to comment.