blob: 35bf75627963baf5d767b8cf5705da405968f54c [file] [log] [blame]
Oliver Smitha560cf32023-10-26 15:14:16 +02001#!/bin/sh -e
2DIR="$(cd "$(dirname "$0")" && pwd)"
3
4if [ -e /dev/kvm ]; then
5 MACHINE_ARG="-machine pc,accel=kvm"
6else
7 echo "WARNING: /dev/kvm not found, emulation will be slower"
8 MACHINE_ARG="-machine pc"
9fi
10
11if ! [ -e "$DIR"/_linux ]; then
12 echo "ERROR: linux kernel not found: $DIR/_linux"
13 echo "Put a kernel there, either download it from the Osmocom jenkins:"
14 echo "$ make -C tests qemu-download-kernel"
15 echo
16 echo "Or build your own kernel. Make sure to set:"
17 echo " CONFIG_GTP=y"
18 echo " CONFIG_NET_NS=y"
19 echo " CONFIG_VETH=y"
20 exit 1
21fi
22
23KERNEL_CMDLINE="root=/dev/ram0 console=ttyS0 panic=-1 init=/init"
24
25set -x
26qemu-system-x86_64 \
27 $MACHINE_ARG \
28 -smp 1 \
29 -m 512M \
30 -no-user-config -nodefaults -display none \
31 -gdb unix:"$DIR"/_gdb.pipe,server=on,wait=off \
32 -no-reboot \
33 -kernel "$DIR"/_linux \
34 -initrd "$DIR"/_initrd.gz \
35 -append "${KERNEL_CMDLINE}" \
36 -serial stdio \
37 -chardev socket,id=charserial1,path="$DIR"/_gdb-serial.pipe,server=on,wait=off \
38 -device isa-serial,chardev=charserial1,id=serial1 \
39 2>&1 | tee "$DIR/_output"
40
41set +x
42if grep -q "QEMU_TEST_SUCCESSFUL" "$DIR/_output"; then
43 echo
44 echo "QEMU tests: successful"
45 echo
46else
47 echo
48 echo "QEMU tests: failed"
49 echo
50 exit 1
51fi