4 # Copyright (C) 2013 Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 exec_prefix="@exec_prefix@"
22 initrd="@libdir@/initrd"
25 canonical_arch="$(uname -m | sed 's/i[456]86/i386/')"
29 # Handle command line parsing.
32 echo "qemu-sanity-check [options]"
34 echo " --help Display this help"
35 echo " -i|--initrd=initrd Set location of initramfs"
36 echo " -k|--kernel=vmlinuz Set location of kernel"
37 echo " -q|--qemu=qemu Set location of qemu/KVM binary"
38 # echo " -t|--timeout=timeout Set the timeout"
39 echo " -V|--version Display version and exit"
50 -n 'qemu-sanity-check' -- "$@")
51 if [ $? != 0 ]; then exit 2; fi
76 echo "@PACKAGE_NAME@ @PACKAGE_VERSION@"
84 echo "$0: internal error parsing options: $1"
91 if [ ! -f "$initrd" ]; then
92 echo "$0: cannot find 'initrd', try using --initrd=/path/to/initrd"
93 echo "If you are running qemu-sanity-check without installing, then do:"
94 echo " $0 --initrd=./initrd $@"
95 echo "The default path is '@libdir@/initrd'."
99 # Locate kernel if not specified.
100 if [ -z "$kernel" ]; then
101 kernel="$(ls -vr /boot/vmlinuz-*.$arch | head -1)"
102 if [ -z "$kernel" ]; then
103 echo "$0: cannot find a Linux kernel in /boot"
104 echo "Choose a kernel to test using --kernel=/path/to/vmlinuz"
109 # Locate qemu if not specified.
110 if [ -z "$qemu" ]; then
111 for q in qemu-kvm qemu-system-$canonical_arch qemu kvm; do
112 if "$q" --help >/dev/null 2>&1; then
117 if [ -z "$qemu" ]; then
118 echo "$0: cannot find a qemu binary on the \$PATH"
119 echo "Choose a qemu binary to test using --qemu=/path/to/qemu"
124 # Choose a temporary file for the output.
125 test_output="$(mktemp --suff=.out)"
131 -nographic -nodefconfig -nodefaults \
136 -append "console=ttyS0 panic=1" 2>&1 | tee "$test_output"
139 #if [ $r -eq 124 ]; then
141 # echo "$0: error: test $kernel on $qemu: timed out"
144 if [ $r -ne 0 ]; then
146 echo "$0: error: test $kernel on $qemu: failed"
151 # Verify that userspace was reached.
152 if ! grep -sq "initrd started up OK" "$test_output"; then
154 echo "$0: error: test $kernel on $qemu: init process did not start up"