From ecf88732938de7996d7d8f705fc9f9d9bed0850e Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Sat, 20 Dec 2025 09:26:02 +0100 Subject: [PATCH] qemu/Makefile: Allow overriding the test natmods list. This commit modifies the QEMU port makefile to let the user provide their own list of natmods to test as part of "test_natmod". The makefile now will replace the list of natmods to test with the contents of the "TEST_NATMODS" command line variable, so if there's a specific subset of natmods causing problems test runs can be limited to that very subset. "TEST_NATMODS" accepts a whitespace-separated list of natmod names for which there are available matching tests in "tests/extmod" (eg. make test_natmod TEST_NATMODS="btree heapq"). Signed-off-by: Alessandro Gatti --- ports/qemu/Makefile | 5 ++++- ports/qemu/README.md | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/qemu/Makefile b/ports/qemu/Makefile index c8ce3de872..3bc46ffefd 100644 --- a/ports/qemu/Makefile +++ b/ports/qemu/Makefile @@ -164,6 +164,9 @@ QEMU_DEBUG_ARGS ?= -s QEMU_ARGS += -S $(QEMU_DEBUG_ARGS) $(QEMU_DEBUG_EXTRA) endif +# Allow selecting a subset of natmods to test. +TEST_NATMODS ?= btree deflate framebuf heapq random_basic re + INC += -I. INC += -I$(TOP) INC += -I$(BUILD) @@ -265,7 +268,7 @@ test_full: $(BUILD)/firmware.elf test_natmod: $(BUILD)/firmware.elf $(eval DIRNAME=ports/$(notdir $(CURDIR))) cd $(TOP)/tests && \ - for natmod in btree deflate framebuf heapq random_basic re; do \ + for natmod in $(TEST_NATMODS); do \ ./run-natmodtests.py -t execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../$(DIRNAME)/$<" $(RUN_TESTS_EXTRA) extmod/$$natmod*.py; \ done diff --git a/ports/qemu/README.md b/ports/qemu/README.md index a7134d0eb8..0f53c00008 100644 --- a/ports/qemu/README.md +++ b/ports/qemu/README.md @@ -167,5 +167,8 @@ The following options can be specified on the `make` command line: - `QEMU_DEBUG_ARGS`: defaults to `-s` (gdb on TCP port 1234), but can be overridden with different qemu gdb arguments. - `QEMU_DEBUG_EXTRA`: extra options to pass to qemu when `QEMU_DEBUG=1` is used. +- `TEST_NATMODS`: pass an optional list of space-separated names of natmods to test, + so only the given subset of example natmods will be used by `test_natmod` (for + example, `make test_natmod TEST_NATMODS="btree heapq re"`). - `MICROPY_HEAP_SIZE`: pass in an optional value (in bytes) for overriding the GC heap size used by the port.