blob: 63f50879006acdfa541ae89ec905176b0d62c9cb [file] [log] [blame]
Oliver Smitha3108a32023-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 "(FIXME: isn't built with required config options yet)"
16 echo
17 echo "Or build your own kernel. Make sure to set:"
18 echo " CONFIG_GTP=y"
19 echo " CONFIG_NETNS=y"
20 echo " CONFIG_VETH=y"
21 exit 1
22fi
23
24KERNEL_CMDLINE="root=/dev/ram0 console=ttyS0 panic=-1 init=/init"
25
26set -x
27qemu-system-x86_64 \
28 $MACHINE_ARG \
29 -smp 1 \
30 -m 512M \
31 -no-user-config -nodefaults -display none \
32 -gdb unix:"$DIR"/_gdb.pipe,server=on,wait=off \
33 -no-reboot \
34 -kernel "$DIR"/_linux \
35 -initrd "$DIR"/_initrd.gz \
36 -append "${KERNEL_CMDLINE}" \
37 -serial stdio \
38 -chardev socket,id=charserial1,path="$DIR"/_gdb-serial.pipe,server=on,wait=off \
39 -device isa-serial,chardev=charserial1,id=serial1 \
40 2>&1 | tee "$DIR/_output"
41
42set +x
43if grep -q "QEMU_TEST_SUCCESSFUL" "$DIR/_output"; then
44 echo
45 echo "QEMU tests: successful"
46 echo
47else
48 echo
49 echo "QEMU tests: failed"
50 echo
51 exit 1
52fi