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:
69
arch/x86_64/test/successful-boot
Executable file
69
arch/x86_64/test/successful-boot
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# vim: ft=bash
|
||||
|
||||
|
||||
log_dir="test-results/successful-boot"
|
||||
rm -rf $log_dir
|
||||
mkdir -p $log_dir
|
||||
|
||||
logfile="$log_dir/main.log"
|
||||
|
||||
log() {
|
||||
if [ -n "$logfile" ]; then
|
||||
printf '%s\n' "$@" >> "$logfile"
|
||||
fi
|
||||
|
||||
printf '%s\n' "$@"
|
||||
}
|
||||
|
||||
log "Running boot test. Press Ctrl+\\ to stop."
|
||||
|
||||
declare -i result
|
||||
declare -i count
|
||||
declare -i pass
|
||||
declare -i fail
|
||||
count=0
|
||||
pass=0
|
||||
fail=0
|
||||
python=$1
|
||||
validation_script=$2
|
||||
qemu=$3
|
||||
kernel=$4
|
||||
initrd=$5
|
||||
|
||||
while true; do
|
||||
log "Test $count"
|
||||
result_file="$log_dir/$count.log"
|
||||
$qemu \
|
||||
-kernel $kernel \
|
||||
-initrd $initrd \
|
||||
-serial file:$result_file \
|
||||
-cpu qemu64,+rdrand \
|
||||
--append kernel.early-console=ttyS0 -s > /dev/null &
|
||||
qemu_id=$!
|
||||
|
||||
sleep 1.2
|
||||
|
||||
$python $validation_script successful-boot $result_file $logfile
|
||||
result=$?
|
||||
|
||||
count=$count+1
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
pass=$pass+1
|
||||
else
|
||||
mv $result_file "$result_file.FAIL"
|
||||
fail=$fail+1
|
||||
lldb \
|
||||
-o "file kernel/mango_kernel.debug" \
|
||||
-o "gdb-remote localhost:1234"
|
||||
fi
|
||||
|
||||
kill -INT $qemu_id
|
||||
|
||||
log "---------------"
|
||||
log "Total tests: $count"
|
||||
log "Pass: $pass"
|
||||
log "Fail: $fail"
|
||||
log "---------------"
|
||||
done
|
||||
Reference in New Issue
Block a user