xref: /kvm-unit-tests/x86/run (revision db9c4e1c8c2ab14af6a61d62604b7754b808833f)
11b7dd7d3SSergey Bronnikov#!/usr/bin/env bash
2928ec374SMichael S. Tsirkin
357ab5a6dSThomas Huthif [ -z "$KUT_STANDALONE" ]; then
4786bfc8dSAndrew Jones	if [ ! -f config.mak ]; then
5786bfc8dSAndrew Jones		echo "run ./configure && make first. See ./configure -h"
6786bfc8dSAndrew Jones		exit 2
7786bfc8dSAndrew Jones	fi
8786bfc8dSAndrew Jones	source config.mak
9786bfc8dSAndrew Jones	source scripts/arch-run.bash
10*db9c4e1cSAlexandru Elisei	source scripts/vmm.bash
11786bfc8dSAndrew Jonesfi
12b2a2aa5dSAndrew Jones
1301e047d0SGavin Shanset_qemu_accelerator || exit $?
1423505cedSRadim Krčmář
15fcf4e0d9SRadim Krčmářqemu=$(search_qemu_binary) ||
16fcf4e0d9SRadim Krčmář	exit $?
17b895b967SBandan Das
18eff4e220SBalamuruhan Sif ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
19b895b967SBandan Dasthen
20b895b967SBandan Das    echo "No Qemu test device support found"
21a3831260SAndrew Jones    exit 2
22928ec374SMichael S. Tsirkinfi
23928ec374SMichael S. Tsirkin
24ec3c77fbSRen, Yongjieif
25740001b3SRen, Yongjie	${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null;
265292dbf7SMichael S. Tsirkinthen
275292dbf7SMichael S. Tsirkin	pci_testdev="-device pci-testdev"
285292dbf7SMichael S. Tsirkinelse
295292dbf7SMichael S. Tsirkin	pci_testdev=""
305292dbf7SMichael S. Tsirkinfi
315292dbf7SMichael S. Tsirkin
32928ec374SMichael S. Tsirkinif
33740001b3SRen, Yongjie	${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null;
34928ec374SMichael S. Tsirkinthen
355292dbf7SMichael S. Tsirkin	pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4"
36928ec374SMichael S. Tsirkinelse
375292dbf7SMichael S. Tsirkin	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
38928ec374SMichael S. Tsirkinfi
3909142098SKevin Wolf
40e6137187SSean Christophersoncommand="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev"
4101e047d0SGavin Shancommand+=" -machine accel=$ACCEL$ACCEL_PROPS"
42c98ce6e0SAlexandru Eliseiif [ "${CONFIG_EFI}" != y ]; then
43ad5fb883SZixuan Wang	command+=" -kernel"
44ad5fb883SZixuan Wangfi
45fd149358SAndrew Jonescommand="$(timeout_cmd) $command"
4692a1afcbSAndrew Jones
47c98ce6e0SAlexandru Eliseiif [ "${CONFIG_EFI}" = y ]; then
48ad5fb883SZixuan Wang	# Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see
49ad5fb883SZixuan Wang	# 'scripts/arch-run.bash' for more details). This is because when using
50ad5fb883SZixuan Wang	# UEFI, the test case binaries are passed to QEMU through the disk
51ad5fb883SZixuan Wang	# image, not through the '-kernel' flag. And QEMU reports an error if it
52ad5fb883SZixuan Wang	# gets '-initrd' without a '-kernel'
53*db9c4e1cSAlexandru Elisei	ENVIRON_DEFAULT=n run_test ${command} "$@"
54ad5fb883SZixuan Wangelse
55*db9c4e1cSAlexandru Elisei	run_test ${command} "$@"
56ad5fb883SZixuan Wangfi
57