X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=qemu-sanity-check.in;h=3fc9cea48b9828a4a5d197f16c69ad7121e8d13c;hb=d426647b9dc2e98bd65823aebdd554ca6620313a;hp=da4f59a4c345fbf97443d46e9f9d34f2f3badd53;hpb=aee03601ac923906391b438bc4040c4a4265112d;p=qemu-sanity-check.git diff --git a/qemu-sanity-check.in b/qemu-sanity-check.in index da4f59a..3fc9cea 100644 --- a/qemu-sanity-check.in +++ b/qemu-sanity-check.in @@ -24,7 +24,7 @@ initrd="@libdir@/initrd" arch="$(uname -m)" canonical_arch="$(uname -m | sed 's/i[456]86/i386/')" -#timeout=10m +timeout=10m # Handle command line parsing. @@ -35,17 +35,18 @@ function usage { echo " -i|--initrd=initrd Set location of initramfs" echo " -k|--kernel=vmlinuz Set location of kernel" echo " -q|--qemu=qemu Set location of qemu/KVM binary" -# echo " -t|--timeout=timeout Set the timeout" + echo " -t|--timeout=timeout Set the timeout" echo " -V|--version Display version and exit" exit 0 } TEMP=$(getopt \ - -o i:k:q:V \ + -o i:k:q:t:V \ --long help \ --long initrd: \ --long kernel: \ --long qemu: \ + --long timeout: \ --long version \ -n 'qemu-sanity-check' -- "$@") if [ $? != 0 ]; then exit 2; fi @@ -68,10 +69,10 @@ while true; do qemu="$2" shift 2 ;; -# -t|--timeout) -# timeout="$2" -# shift 2 -# ;; + -t|--timeout) + timeout="$2" + shift 2 + ;; -V|--version) echo "@PACKAGE_NAME@ @PACKAGE_VERSION@" exit 0 @@ -88,7 +89,7 @@ while true; do done # Locate initrd. -if [ ! -f "$initrd" ]; then +if [ ! -r "$initrd" ]; then echo "$0: cannot find 'initrd', try using --initrd=/path/to/initrd" echo "If you are running qemu-sanity-check without installing, then do:" echo " $0 --initrd=./initrd $@" @@ -105,6 +106,10 @@ if [ -z "$kernel" ]; then exit 2 fi fi +if [ ! -r "$kernel" ]; then + echo "$0: kernel $kernel is not readable" + exit 2 +fi # Locate qemu if not specified. if [ -z "$qemu" ]; then @@ -124,24 +129,34 @@ fi # Choose a temporary file for the output. test_output="$(mktemp --suff=.out)" -# Run the command -set -x -#timeout "$timeout" -"$qemu" \ - -nographic -nodefconfig -nodefaults \ - -no-reboot \ - -serial stdio \ - -kernel "$kernel" \ - -initrd "$initrd" \ - -append "console=ttyS0 panic=1" 2>&1 | tee "$test_output" +# Generate the parameters for the qemu command. +declare -a argv +i=0 +argv[$((i++))]="$qemu" +argv[$((i++))]="-nographic" +argv[$((i++))]="-nodefconfig" +argv[$((i++))]="-nodefaults" +argv[$((i++))]="-no-reboot" +argv[$((i++))]="-serial" +argv[$((i++))]="file:$test_output" +argv[$((i++))]="-kernel" +argv[$((i++))]="$kernel" +argv[$((i++))]="-initrd" +argv[$((i++))]="$initrd" +argv[$((i++))]="-append" +argv[$((i++))]="console=ttyS0 panic=1" + +#echo "${argv[@]}" + +# Run the command. +timeout "$timeout" "${argv[@]}" r="${PIPESTATUS[0]}" -set +x -#if [ $r -eq 124 ]; then -# cat "$test_output" -# echo "$0: error: test $kernel on $qemu: timed out" -# rm "$test_output" -# exit 1 -if [ $r -ne 0 ]; then +if [ $r -eq 124 ]; then + cat "$test_output" + echo "$0: error: test $kernel on $qemu: timed out" + rm "$test_output" + exit 1 +elif [ $r -ne 0 ]; then cat "$test_output" echo "$0: error: test $kernel on $qemu: failed" rm "$test_output"