qemu-arm: Add testing of frozen native modules.
- Split 'qemu-arm' from 'unix' for generating tests. - Add frozen module to the qemu-arm test build. - Add test that reproduces the requirement to half-word align native function data.
This commit is contained in:
committed by
Damien George
parent
4ab5156c01
commit
0bd1eb80ff
@@ -114,6 +114,14 @@ OBJ = $(OBJ_COMMON) $(OBJ_RUN) $(OBJ_TEST)
|
||||
# List of sources for qstr extraction
|
||||
SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C) $(LIB_SRC_C)
|
||||
|
||||
ifneq ($(FROZEN_MPY_DIR),)
|
||||
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
||||
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
|
||||
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
||||
MPY_CROSS_FLAGS += -march=armv7m
|
||||
endif
|
||||
|
||||
all: run
|
||||
|
||||
run: $(BUILD)/firmware.elf
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
LIB_SRC_C = lib/upytesthelper/upytesthelper.c
|
||||
|
||||
FROZEN_MPY_DIR ?= test-frzmpy
|
||||
|
||||
include Makefile
|
||||
|
||||
CFLAGS += -DTEST
|
||||
@@ -8,7 +10,7 @@ CFLAGS += -DTEST
|
||||
|
||||
$(BUILD)/test_main.o: $(BUILD)/genhdr/tests.h
|
||||
$(BUILD)/genhdr/tests.h:
|
||||
(cd $(TOP)/tests; ./run-tests --write-exp)
|
||||
(cd $(TOP)/tests; ./run-tests --target=qemu-arm --write-exp)
|
||||
$(Q)echo "Generating $@";(cd $(TOP)/tests; ../tools/tinytest-codegen.py) > $@
|
||||
|
||||
$(BUILD)/tinytest.o:
|
||||
@@ -18,7 +20,8 @@ $(BUILD)/firmware-test.elf: $(OBJ_COMMON) $(OBJ_TEST)
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
# Note: Using timeout(1) to handle cases where qemu hangs (e.g. this can happen with alignment errors).
|
||||
test: $(BUILD)/firmware-test.elf
|
||||
qemu-system-arm -machine $(BOARD) $(QEMU_EXTRA) -nographic -monitor null -semihosting -kernel $< > $(BUILD)/console.out
|
||||
timeout --foreground -k 5s 30s qemu-system-arm -machine $(BOARD) $(QEMU_EXTRA) -nographic -monitor null -semihosting -kernel $< > $(BUILD)/console.out
|
||||
$(Q)tail -n2 $(BUILD)/console.out
|
||||
$(Q)tail -n1 $(BUILD)/console.out | grep -q "status: 0"
|
||||
|
||||
13
ports/qemu-arm/test-frzmpy/native_frozen_align.py
Normal file
13
ports/qemu-arm/test-frzmpy/native_frozen_align.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import micropython
|
||||
|
||||
@micropython.native
|
||||
def native_x(x):
|
||||
print(x + 1)
|
||||
|
||||
@micropython.native
|
||||
def native_y(x):
|
||||
print(x + 1)
|
||||
|
||||
@micropython.native
|
||||
def native_z(x):
|
||||
print(x + 1)
|
||||
Reference in New Issue
Block a user