xref: /kvm-unit-tests/arm/run (revision d3aacb4f57d05f74f2030dbe12e7dfd6aa1b273d)
1#!/bin/bash
2
3if [ ! -f config.mak ]; then
4	echo run ./configure first. See ./configure -h
5	exit 2
6fi
7source config.mak
8
9qemu="${QEMU:-qemu-system-arm}"
10qpath=$(which $qemu 2>/dev/null)
11
12if [ -z "$qpath" ]; then
13	echo $qemu not found.
14	exit 2
15fi
16
17if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
18	echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting."
19	exit 2
20fi
21
22M='-machine virt'
23
24if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then
25	echo "$qpath doesn't support virtio-console for chr-testdev. Exiting."
26	exit 2
27fi
28
29if $qemu $M -chardev testdev,id=id -kernel . 2>&1 \
30		| grep backend > /dev/null; then
31	echo "$qpath doesn't support chr-testdev. Exiting."
32	exit 2
33fi
34
35M='-machine virt,accel=kvm:tcg'
36chr_testdev='-device virtio-serial-device'
37chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
38
39command="$qemu $M -cpu $PROCESSOR $chr_testdev"
40command+=" -display none -serial stdio -kernel"
41
42echo $command "$@"
43$command "$@"
44ret=$?
45echo Return value from qemu: $ret
46exit $ret
47