#!/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))