On July 4, 2026 4:58:42 AM GMT+01:00, Damien Zammit <[email protected]>
wrote:
>This enables qemu unit tests to run on gnumach as xen dom0.
>However, it will skip running the tests if xen binary is missing.
>Therefore, the test suite will not fail if not intending to test xen.
>This is useful, for example on CI where we want to see a pass status
>for most of the tests without fully testing xen which is difficult to
>execute.
>
>This should make debugging easier for anyone interested in progressing
>the xen dom0 port of gnumach.
>---
> tests/Makefrag.am           |  5 +----
> tests/grub.cfg.xen.template |  5 +++++
> tests/run-qemu.sh.template  |  8 +++++++-
> tests/test-multiboot.in     |  6 ++++++
> tests/user-qemu.mk          | 29 ++++++++++++++++++++++++++++-
> 5 files changed, 47 insertions(+), 6 deletions(-)
> create mode 100644 tests/grub.cfg.xen.template
>
>diff --git a/tests/Makefrag.am b/tests/Makefrag.am
>index ef5616a6..087aa2e2 100644
>--- a/tests/Makefrag.am
>+++ b/tests/Makefrag.am
>@@ -20,8 +20,6 @@
> # Tests.
> #
> 
>-if !PLATFORM_xen
>-
> # Let user specify a kernel to test
> GNUMACH ?= gnumach
> export GNUMACH
>@@ -37,6 +35,7 @@ TESTS += \
> EXTRA_DIST += \
>       tests/README \
>       tests/grub.cfg.single.template \
>+      tests/grub.cfg.xen.template \
>       tests/run-qemu.sh.template \
>       tests/include/syscalls.h \
>       tests/include/testlib.h \
>@@ -50,5 +49,3 @@ EXTRA_DIST += \
> 
> clean-local: $(USER_TESTS_CLEAN)
>       rm -fr tests/include-mach tests/test-multiboot tests/errlist.c 
> tests/mig-out
>-
>-endif # !PLATFORM_xen
>diff --git a/tests/grub.cfg.xen.template b/tests/grub.cfg.xen.template
>new file mode 100644
>index 00000000..083c4166
>--- /dev/null
>+++ b/tests/grub.cfg.xen.template
>@@ -0,0 +1,5 @@
>+echo TEST_START_MARKER
>+multiboot /boot/xen dom0_mem=2000M,max:2000M console=com1 noreboot
>+module /boot/gnumach GNUMACHARGS
>+module /boot/BOOTMODULE BOOTMODULE '${host-port}' '${device-port}' 
>'$(task-create)' '$(task-resume)'
>+boot
>diff --git a/tests/run-qemu.sh.template b/tests/run-qemu.sh.template
>index a7ec426f..2fd558ad 100644
>--- a/tests/run-qemu.sh.template
>+++ b/tests/run-qemu.sh.template
>@@ -21,8 +21,14 @@ cmd="QEMU_BIN QEMU_OPTS -cdrom tests/test-TESTNAME.iso"
> log="tests/test-TESTNAME.raw"
> 
> echo "temp log $log"
>+
>+if PLATFORM_XEN && [ ! -e 'XEN_BIN' ]; then
>+    echo "skipping, XEN_BIN not found for xen tests"
>+    exit 77
>+fi
>+
> if which QEMU_BIN >/dev/null ; then
>-    if ! timeout -v --foreground --kill-after=3 60s $cmd \
>+    if ! timeout -v --foreground --kill-after=3 120s $cmd \
>             | tee $log | sed -n "/TEST_START_MARKER/"',$p' ; then
>         exit 10  # timeout
>     fi
>diff --git a/tests/test-multiboot.in b/tests/test-multiboot.in
>index 7693ab93..cc0f8d77 100644
>--- a/tests/test-multiboot.in
>+++ b/tests/test-multiboot.in
>@@ -18,6 +18,12 @@
> # with this program; if not, write to the Free Software Foundation, Inc.,
> # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> 
>+if $PLATFORM_XEN
>+then
>+  # ignore this test
>+  exit 77
>+fi
>+
> [ -n "$GNUMACH" ] || GNUMACH=gnumach
> if grub-file --help > /dev/null 2>&1
> then grub-file --is-x86-multiboot $GNUMACH
>diff --git a/tests/user-qemu.mk b/tests/user-qemu.mk
>index 7893c7d2..a01e1ead 100644
>--- a/tests/user-qemu.mk
>+++ b/tests/user-qemu.mk
>@@ -173,11 +173,18 @@ tests/module-%: $(srcdir)/tests/test-%.c $(SRC_TESTLIB) 
>$(MACH_TESTINSTALL)
> # packaging of qemu bootable image and test runner
> #
> 
>+XEN_BIN ?= /usr/share/xen/xen
> GRUB_MKRESCUE ?= grub-mkrescue
> GNUMACH_ARGS = console=com0
>-QEMU_OPTS = -m 2047 -nographic -no-reboot -boot d
>+QEMU_OPTS = -m 2047 -nographic -no-reboot -monitor none -serial stdio -boot d
> QEMU_GDB_PORT ?= 1234
> 
>+if PLATFORM_xen
>+PLATFORM_XEN = true
>+QEMU_BIN = qemu-system-x86_64
>+QEMU_OPTS += -cpu core2duo-v1
>+else
>+PLATFORM_XEN = false
> if HOST_ix86
> QEMU_BIN = qemu-system-i386
> QEMU_OPTS += -cpu pentium3-v1
>@@ -186,10 +193,27 @@ if HOST_x86_64
> QEMU_BIN = qemu-system-x86_64
> QEMU_OPTS += -cpu core2duo-v1
> endif
>+endif
>+
> if enable_smp
> QEMU_OPTS += -smp 2
> endif
> 
>+if PLATFORM_xen
>+tests/test-%.iso: tests/module-% $(GNUMACH) 
>$(srcdir)/tests/grub.cfg.xen.template
>+      rm -rf $(builddir)/tests/isofiles-$*
>+      mkdir -p $(builddir)/tests/isofiles-$*/boot/grub/
>+      < $(srcdir)/tests/grub.cfg.xen.template         \
>+              sed -e "s|BOOTMODULE|$(notdir $<)|g"            \
>+                  -e "s/GNUMACHARGS/$(GNUMACH_ARGS)/g"        \
>+                  -e "s/TEST_START_MARKER/$(TEST_START_MARKER)/g"     \
>+              >$(builddir)/tests/isofiles-$*/boot/grub/grub.cfg
>+      cp $(GNUMACH) $(builddir)/tests/isofiles-$*/boot/gnumach
>+      if [ -e "$(XEN_BIN)" ]; then cp $(XEN_BIN) 
>$(builddir)/tests/isofiles-$*/boot/xen; fi
>+      cp $< $(builddir)/tests/isofiles-$*/boot/
>+      $(GRUB_MKRESCUE) -o $@ $(builddir)/tests/isofiles-$*
>+      rm -rf $(builddir)/tests/isofiles-$*
>+else
> tests/test-%.iso: tests/module-% $(GNUMACH)
> $(srcdir)/tests/grub.cfg.single.template
>       rm -rf $(builddir)/tests/isofiles-$*
>       mkdir -p $(builddir)/tests/isofiles-$*/boot/grub/
>@@ -202,12 +226,15 @@ tests/test-%.iso: tests/module-% $(GNUMACH) 
>$(srcdir)/tests/grub.cfg.single.temp
>       cp $< $(builddir)/tests/isofiles-$*/boot/
>       $(GRUB_MKRESCUE) -o $@ $(builddir)/tests/isofiles-$*
>       rm -rf $(builddir)/tests/isofiles-$*
>+endif
> 
> tests/test-%: tests/test-%.iso $(srcdir)/tests/run-qemu.sh.template
>       < $(srcdir)/tests/run-qemu.sh.template                  \
>               sed -e "s|TESTNAME|$(subst tests/test-,,$@)|g"  \
>                   -e "s/QEMU_OPTS/$(QEMU_OPTS)/g"             \
>                   -e "s/QEMU_BIN/$(QEMU_BIN)/g"                       \
>+                  -e "s|XEN_BIN|$(XEN_BIN)|g"                         \
>+                  -e "s/PLATFORM_XEN/$(PLATFORM_XEN)/g"               \
>                   -e "s/TEST_START_MARKER/$(TEST_START_MARKER)/g"     \
>                   -e "s/TEST_SUCCESS_MARKER/$(TEST_SUCCESS_MARKER)/g" \
>                   -e "s/TEST_FAILURE_MARKER/$(TEST_FAILURE_MARKER)/g" \
>

Nice! LGTM.


Thanks!

Reply via email to