os-test-framework/test/virtualbox.sh
2018-06-30 18:32:54 +02:00

36 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -e
os_file="example-os/os.sh"
img_file="$(mktemp --suffix=".img")"
vbox_dir="$(mktemp -d --suffix="_vbox")"
vmname="automatic-os-test-$(date +%s)-$$"
ln -sf "$(readlink -f "$os_file")" "$img_file"
VBoxManage createvm --name "$vmname" --register --basefolder "$vbox_dir"
VBoxManage modifyvm "$vmname" --hwvirtex off
VBoxManage modifyvm "$vmname" --nestedpaging off
VBoxManage modifyvm "$vmname" --pae off
VBoxManage storagectl "$vmname" --name 'floppy disk drive' --add floppy --bootable on
VBoxManage storageattach "$vmname" --storagectl 'floppy disk drive' --port 0 --device 0 --type fdd --medium "$img_file"
VBoxManage modifyvm "$vmname" --boot1 floppy
VBoxManage startvm "$vmname" --type sdl &
pid=$!
runsikulix -r test/check-gradient.sikuli
./utils/take-screenshots.sh "./deploy-screenshots/$(basename "$0" .sh).png"
VBoxManage controlvm "$vmname" poweroff
wait $pid
# TODO: should ensure that the cleanup phase is always done even if the test fails.
for i in `seq 10`; do
if VBoxManage unregistervm "$vmname" --delete; then
break
fi
sleep 0.1
done
# Cleanup: remove temporary files and directories.
rm "$img_file"
rm "/tmp/$vbox_dir" -fr