summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authordzwdz2023-08-15 20:41:38 +0200
committerdzwdz2023-08-15 20:41:38 +0200
commit034a60c19f15f74186bfb902172bf0f1cd356321 (patch)
tree6eee5fd1b7dd18697f40e9de26dec172ba2b6223 /boot
parent070b19e2948b3a03669b0f1888f1661b0d196275 (diff)
build: replace make {boot,test} with a dedicated script
Diffstat (limited to 'boot')
-rwxr-xr-xboot73
1 files changed, 73 insertions, 0 deletions
diff --git a/boot b/boot
new file mode 100755
index 0000000..90c7309
--- /dev/null
+++ b/boot
@@ -0,0 +1,73 @@
+#!/bin/sh
+set -eu
+
+disk() {
+ echo "-drive file=$1,format=raw,media=disk"
+}
+
+if [ -n "${QFLAGS:-}" ]; then
+ echo "QFLAGS in env"
+fi
+QFLAGS="-no-reboot -m 1g -gdb tcp::12366 $(disk out/boot.iso) $(disk out/fs.e2) ${QFLAGS:-}"
+QEMU=qemu-system-x86_64
+
+QDISPLAY="-display none"
+QNET="-nic user,model=rtl8139,mac=52:54:00:ca:77:1a,net=192.168.0.0/24,hostfwd=tcp::12380-192.168.0.11:80,id=n1"
+QKVM="-enable-kvm"
+QTTY="-serial stdio"
+
+DRY_RUN=
+TEST_RUN=
+
+for opt; do
+ case "$opt" in
+ --display|-d)
+ QDISPLAY=
+ ;;
+ --dry-run|-n)
+ DRY_RUN=1
+ ;;
+ --help|-h)
+ echo $0 [opts]
+ sed -ne '/\t-.*)/ {s/)//; s/|/, /g; p}' $0
+ exit
+ ;;
+ --pcap=*)
+ PCAP="${opt#*=}"
+ echo outputting pcap to $PCAP
+ QNET="$QNET -object filter-dump,id=f1,netdev=n1,file=$PCAP"
+ ;;
+ --no-kvm)
+ QKVM=
+ ;;
+ --test|-t)
+ rm -vf out/qemu.in out/qemu.out
+ mkfifo out/qemu.in out/qemu.out
+ TEST_RUN=1
+ QTTY="-serial pipe:out/qemu"
+ POST="cat out/qemu.out"
+ ;;
+ *)
+ echo "unknown option $opt"
+ exit 1
+ ;;
+ esac
+done
+
+CMD="$QEMU $QDISPLAY $QNET $QKVM $QTTY $QFLAGS"
+if [ -n "$DRY_RUN" ]; then
+ echo "$CMD"
+elif [ -n "$TEST_RUN" ]; then
+ echo "$CMD &"
+ $CMD &
+
+ # something eats the first character sent, so let's send a sacrificial newline
+ echo > out/qemu.in
+ # carry on with the tests
+ echo tests > out/qemu.in
+ echo halt > out/qemu.in
+ cat out/qemu.out
+else
+ echo "$CMD"
+ $CMD
+fi