www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

virtualbox.sh (1308B)


      1 #!/bin/sh
      2 set -e
      3 
      4 if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
      5     echo "Usage: $0 operating_system_file"
      6 fi
      7 os_filename="$1"
      8 
      9 vbox_dir="$(./utils/mktemp.sh -d)"
     10 vmname="automatic-os-test-$(date +%s)-$$"
     11 
     12 ln -sf "$(./utils/absolute-path.sh "$os_filename")" "build/virtualbox.img"
     13 VBoxManage createvm --name "$vmname" --register --basefolder "$vbox_dir"
     14 VBoxManage modifyvm "$vmname" --hwvirtex off
     15 VBoxManage modifyvm "$vmname" --nestedpaging off
     16 VBoxManage modifyvm "$vmname" --pae off
     17 VBoxManage storagectl "$vmname" --name 'floppy disk drive' --add floppy --bootable on
     18 VBoxManage storageattach "$vmname" --storagectl 'floppy disk drive' --port 0 --device 0 --type fdd --medium "build/virtualbox.img"
     19 VBoxManage modifyvm "$vmname" --boot1 floppy
     20 VBoxManage startvm "$vmname" --type sdl &
     21 pid=$!
     22 runsikulix -r test/check-gradient.sikuli && exitcode=$? || exitcode=$?
     23 
     24 ./utils/take-screenshots.sh "./deploy-screenshots/$(basename "$0" .sh).png"
     25 
     26 VBoxManage controlvm "$vmname" poweroff
     27 wait $pid
     28 # TODO: should ensure that the cleanup phase is always done even if the test fails.
     29 for i in `seq 10`; do
     30     if VBoxManage unregistervm "$vmname" --delete; then
     31         break
     32     fi
     33     sleep 0.1
     34 done
     35 
     36 # Cleanup: remove temporary files and directories.
     37 rm "/tmp/$vbox_dir" -fr
     38 
     39 exit $exitcode