From 02080bfb6c67d8ce70d427deb846857d89ff17a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Wed, 2 Apr 2025 10:08:32 +0200 Subject: [PATCH] qeneth: Move Infix test templates from qeneth to Infix --- test/env | 1 + test/qeneth | 2 +- test/templates/inc/infix-disk.mustache | 4 +++ test/templates/inc/infix-usb.mustache | 9 +++++++ test/templates/infix-bios-x86_64.mustache | 26 ++++++++++++++++++ test/templates/infix-kernel-x86_64.mustache | 30 +++++++++++++++++++++ test/templates/infix-x86_64.mustache | 29 ++++++++++++++++++++ 7 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 test/templates/inc/infix-disk.mustache create mode 100644 test/templates/inc/infix-usb.mustache create mode 100644 test/templates/infix-bios-x86_64.mustache create mode 100644 test/templates/infix-kernel-x86_64.mustache create mode 100644 test/templates/infix-x86_64.mustache diff --git a/test/env b/test/env index f79f1ba5..10eed98f 100755 --- a/test/env +++ b/test/env @@ -232,6 +232,7 @@ if [ "$containerize" ]; then --env INFAMY_EXTRA_ARGS="$INFAMY_EXTRA_ARGS" \ --env PROMPT_DIRTRIM="$ixdir" \ --env NINEPM_PROJ_CONFIG="$NINEPM_PROJ_CONFIG" \ + --env QENETH_PATH="$testdir/templates:$testdir" \ --env PS1="$(build_ps1)" \ $extra_env \ --expose 9001-9010 --publish-all \ diff --git a/test/qeneth b/test/qeneth index f1ff8c23..332a376b 160000 --- a/test/qeneth +++ b/test/qeneth @@ -1 +1 @@ -Subproject commit f1ff8c235d16a9e9945392140100cd0b28dda2c5 +Subproject commit 332a376bc000fbd9a1eccf6ecd5e54307421e7ab diff --git a/test/templates/inc/infix-disk.mustache b/test/templates/inc/infix-disk.mustache new file mode 100644 index 00000000..4e9f2ace --- /dev/null +++ b/test/templates/inc/infix-disk.mustache @@ -0,0 +1,4 @@ +if [ ! -e {{name}}.disk ]; then + qemu-img create -f raw {{name}}.disk 16M >/dev/null + mkfs.ext4 -q -L cfg {{name}}.disk +fi diff --git a/test/templates/inc/infix-usb.mustache b/test/templates/inc/infix-usb.mustache new file mode 100644 index 00000000..9dabb2ca --- /dev/null +++ b/test/templates/inc/infix-usb.mustache @@ -0,0 +1,9 @@ +usb_cmd="" + +if [ -n "{{qn_usb}}" ]; then + if ! [ -f {{qn_usb}} ]; then + dd if=/dev/zero of={{qn_usb}} bs=8M count=1 >/dev/null 2>&1 + mkfs.vfat {{qn_usb}} >/dev/null 2>&1 + fi + usb_cmd=" -drive if=none,id=usbstick,format=raw,file={{qn_usb}} -usb -device usb-ehci,id=ehci -device usb-storage,bus=ehci.0,drive=usbstick " +fi diff --git a/test/templates/infix-bios-x86_64.mustache b/test/templates/infix-bios-x86_64.mustache new file mode 100644 index 00000000..09a87e0c --- /dev/null +++ b/test/templates/infix-bios-x86_64.mustache @@ -0,0 +1,26 @@ +#!/bin/sh + +con=hvc0 +tty -s && con=hvc2 + +img={{#qn_image}}{{qn_image}}{{/qn_image}}{{^qn_image}}infix-x86_64-disk.img{{/qn_image}} +bios={{#qn_bios}}{{qn_bios}}{{/qn_bios}}{{^qn_bios}}OVMF.fd{{/qn_bios}} +{{> inc/infix-usb}} + +origimg=$(realpath $img) +qemu-img create -f qcow2 -o backing_file=$origimg -F qcow2 {{name}}.qcow2 + +truncate -s 0 $imgdir/{{name}}.mactab +{{#links}} +echo "{{qn_name}} {{qn_mac}}" >>$imgdir/{{name}}.mactab +{{/links}} + +exec qemu-system-x86_64 -M pc,accel=kvm:tcg -cpu max \ + -m {{#qn_mem}}{{qn_mem}}{{/qn_mem}}{{^qn_mem}}256M{{/qn_mem}} \ +{{> ../qeneth/templates/inc/qemu-links}} + -fw_cfg name=opt/mactab,file=$imgdir/{{name}}.mactab \ + -bios $bios \ + -drive file={{name}}.qcow2,if=virtio,format=qcow2,bus=0,unit=1 \ + $usb_cmd \ +{{> ../qeneth/templates/inc/infix-common}} +{{> ../qeneth/templates/inc/qemu-console}} diff --git a/test/templates/infix-kernel-x86_64.mustache b/test/templates/infix-kernel-x86_64.mustache new file mode 100644 index 00000000..e64a79c3 --- /dev/null +++ b/test/templates/infix-kernel-x86_64.mustache @@ -0,0 +1,30 @@ +#!/bin/sh + +con=hvc0 +tty -s && con=hvc2 + +img={{#qn_image}}{{qn_image}}{{/qn_image}}{{^qn_image}}infix-x86_64.img{{/qn_image}} +imgsz=$((($(stat -Lc %s $img) + 1023) >> 10)) +imgdir=./.$(realpath $img | sed -e s:/:-:g) + +unsquashfs -n -f -d $imgdir $img boot/bzImage >/dev/null + + +{{> inc/infix-disk}} +{{> inc/infix-usb}} + +truncate -s 0 $imgdir/{{name}}.mactab +{{#links}} +echo "{{qn_name}} {{qn_mac}}" >>$imgdir/{{name}}.mactab +{{/links}} + +exec qemu-system-x86_64 -M pc,accel=kvm:tcg -cpu max \ + -m {{#qn_mem}}{{qn_mem}}{{/qn_mem}}{{^qn_mem}}384M{{/qn_mem}} \ + -kernel "bzImage" -initrd $img \ + -append "root=/dev/ram0 ramdisk_size=$imgsz console=$con,115200 $append {{qn_append}}" \ + -drive file={{name}}.disk,if=virtio,format=raw,bus=0,unit=1 \ +{{> ../qeneth/templates/inc/qemu-links}} + -fw_cfg name=opt/mactab,file=$imgdir/{{name}}.mactab \ + $usb_cmd \ +{{> ../qeneth/templates/inc/infix-common}} +{{> ../qeneth/templates/inc/qemu-console}} diff --git a/test/templates/infix-x86_64.mustache b/test/templates/infix-x86_64.mustache new file mode 100644 index 00000000..b7971a28 --- /dev/null +++ b/test/templates/infix-x86_64.mustache @@ -0,0 +1,29 @@ +#!/bin/sh + +con=hvc0 +tty -s && con=hvc2 + +img={{#qn_image}}{{qn_image}}{{/qn_image}}{{^qn_image}}infix-x86_64.img{{/qn_image}} +imgsz=$((($(stat -Lc %s $img) + 1023) >> 10)) +imgdir=./.$(realpath $img | sed -e s:/:-:g) + +unsquashfs -n -f -d $imgdir $img boot/bzImage >/dev/null + + +{{> inc/infix-disk}} +{{> inc/infix-usb}} + +truncate -s 0 $imgdir/{{name}}.mactab +{{#links}} +echo "{{qn_name}} {{qn_mac}}" >>$imgdir/{{name}}.mactab +{{/links}} + +exec qemu-system-x86_64 -M pc,accel=kvm:tcg -cpu max \ + -m {{#qn_mem}}{{qn_mem}}{{/qn_mem}}{{^qn_mem}}384M{{/qn_mem}} \ + -kernel $imgdir/boot/bzImage -initrd $img \ + -append "root=/dev/ram0 ramdisk_size=$imgsz console=$con,115200 $append {{qn_append}}" \ + -drive file={{name}}.disk,if=virtio,format=raw,bus=0,unit=1 \ +{{> inc/qemu-links}} + -fw_cfg name=opt/mactab,file=$imgdir/{{name}}.mactab \ + $usb_cmd \ +{{> inc/infix-common}}