xref: /kvm-unit-tests/x86/run (revision 588887078688358e111e4582ccc23e548f7ad1a6)
1#!/usr/bin/env bash
2
3if [ -z "$KUT_STANDALONE" ]; then
4	if [ ! -f config.mak ]; then
5		echo "run ./configure && make first. See ./configure -h"
6		exit 2
7	fi
8	source config.mak
9	source scripts/arch-run.bash
10fi
11
12set_qemu_accelerator || exit $?
13
14qemu=$(search_qemu_binary) ||
15	exit $?
16
17if ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
18then
19    echo "No Qemu test device support found"
20    exit 2
21fi
22
23if
24	${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null;
25then
26	pci_testdev="-device pci-testdev"
27else
28	pci_testdev=""
29fi
30
31if
32	${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null;
33then
34	pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4"
35else
36	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
37fi
38
39if
40	${qemu} -vnc '?' 2>&1 | grep -F "vnc options" > /dev/null;
41then
42	vnc_none="-vnc none"
43else
44	vnc_none=""
45fi
46
47command="${qemu} --no-reboot -nodefaults $pc_testdev $vnc_none -serial stdio $pci_testdev"
48command+=" -machine accel=$ACCEL$ACCEL_PROPS"
49if [ "${CONFIG_EFI}" != y ]; then
50	command+=" -kernel"
51fi
52command="$(timeout_cmd) $command"
53
54if [ "${CONFIG_EFI}" = y ]; then
55	# Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see
56	# 'scripts/arch-run.bash' for more details). This is because when using
57	# UEFI, the test case binaries are passed to QEMU through the disk
58	# image, not through the '-kernel' flag. And QEMU reports an error if it
59	# gets '-initrd' without a '-kernel'
60	ENVIRON_DEFAULT=n run_qemu ${command} "$@"
61else
62	run_qemu ${command} "$@"
63fi
64