Oliver Smith | a3108a3 | 2023-10-26 15:14:16 +0200 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | DIR="$(cd "$(dirname "$0")" && pwd)" |
| 3 | |
| 4 | if [ -e /dev/kvm ]; then |
| 5 | MACHINE_ARG="-machine pc,accel=kvm" |
| 6 | else |
| 7 | echo "WARNING: /dev/kvm not found, emulation will be slower" |
| 8 | MACHINE_ARG="-machine pc" |
| 9 | fi |
| 10 | |
| 11 | if ! [ -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 |
| 22 | fi |
| 23 | |
| 24 | KERNEL_CMDLINE="root=/dev/ram0 console=ttyS0 panic=-1 init=/init" |
| 25 | |
| 26 | set -x |
| 27 | qemu-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 | |
| 42 | set +x |
| 43 | if grep -q "QEMU_TEST_SUCCESSFUL" "$DIR/_output"; then |
| 44 | echo |
| 45 | echo "QEMU tests: successful" |
| 46 | echo |
| 47 | else |
| 48 | echo |
| 49 | echo "QEMU tests: failed" |
| 50 | echo |
| 51 | exit 1 |
| 52 | fi |