cmake: add a simple does-the-os-boot-successfully test
the test will repeated boot the operating system and use the serial log to determine if the boot was successful. if a problem is detected, a debugger is automatically started and attached.
This commit is contained in:
52
arch/x86_64/test/check-results
Normal file
52
arch/x86_64/test/check-results
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim: ft=python
|
||||
import sys
|
||||
|
||||
def log(f, msg):
|
||||
print(msg)
|
||||
f.write(msg)
|
||||
f.write('\n')
|
||||
|
||||
def successful_boot(boot_log, out):
|
||||
nr_panic = boot_log.count("---[ kernel panic")
|
||||
if nr_panic == 1:
|
||||
log(out, "Kernel panic!")
|
||||
return 1
|
||||
if nr_panic > 1:
|
||||
log(out, "Multiple kernel panics!")
|
||||
return 1
|
||||
|
||||
nr_boots = boot_log.count('Mango kernel version')
|
||||
if nr_boots == 0:
|
||||
log(out, "Kernel didn't start!")
|
||||
return 1
|
||||
if nr_boots > 1:
|
||||
log(out, "Kernel rebooted during test!")
|
||||
return 1
|
||||
|
||||
nr_finish = boot_log.count("ld finished")
|
||||
if nr_finish == 0:
|
||||
log(out, "Didn't reach end of boot sequence!")
|
||||
return 1
|
||||
if nr_finish > 1:
|
||||
log(out, "Boot sequence performed multiple times!")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
tests = {
|
||||
'successful-boot': successful_boot,
|
||||
}
|
||||
|
||||
test_name = sys.argv[1]
|
||||
boot_log_path = sys.argv[2]
|
||||
out_path = sys.argv[3]
|
||||
|
||||
boot_log_file = open(boot_log_path, 'r')
|
||||
boot_log = boot_log_file.read()
|
||||
boot_log_file.close()
|
||||
|
||||
out_file = open(out_path, 'a')
|
||||
|
||||
exit(tests[test_name](boot_log, out_file))
|
||||
Reference in New Issue
Block a user