Skip to content

Commit 85e8e2e

Browse files
committed
qemu-arm: Add 'test' target to Makefile to run and verify test suite.
Replaces RUN_TEST=1 definition; now "make test" in qemu-arm directory will run tests/basics/ and check that they all succeed. This patch also enables the test on Travis CI.
1 parent 3990dcf commit 85e8e2e

4 files changed

Lines changed: 28 additions & 17 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ script:
1515
- make -C unix CC=gcc-4.7
1616
- make -C unix-cpy CC=gcc-4.7
1717
- make -C bare-arm
18-
- make -C qemu-arm
18+
- make -C qemu-arm test
1919
- make -C stmhal
2020
- make -C stmhal -B MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1
2121
- make -C stmhal BOARD=STM32F4DISC

qemu-arm/Makefile

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CROSS_COMPILE = arm-none-eabi-
1212
INC = -I.
1313
INC += -I..
1414
INC += -I$(BUILD)
15+
INC += -I../tools/tinytest/
1516

1617
CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3
1718
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT) \
@@ -33,15 +34,11 @@ endif
3334
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
3435
LDFLAGS= --specs=nano.specs --specs=rdimon.specs -Wl,--gc-sections -Wl,-Map=$(@:.elf=.map)
3536

36-
ifeq ($(RUN_TESTS), 1)
37-
SRC_C = \
38-
test_main.c \
39-
40-
else
4137
SRC_C = \
4238
main.c \
4339

44-
endif
40+
SRC_TEST_C = \
41+
test_main.c \
4542

4643
SRC_S = \
4744

@@ -50,15 +47,21 @@ OBJ += $(PY_O)
5047
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
5148
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
5249

53-
ifeq ($(RUN_TESTS), 1)
54-
INC += -I../tools/tinytest/
55-
OBJ += $(BUILD)/tinytest.o
56-
endif
50+
OBJ_TEST =
51+
OBJ_TEST += $(PY_O)
52+
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
53+
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
54+
OBJ_TEST += $(BUILD)/tinytest.o
5755

5856
all: run
5957

60-
run: $(BUILD)/flash.elf
61-
qemu-system-arm -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/flash.elf
58+
run: $(BUILD)/firmware.elf
59+
qemu-system-arm -machine integratorcp -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/firmware.elf
60+
61+
test: $(BUILD)/firmware-test.elf
62+
qemu-system-arm -machine integratorcp -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/firmware-test.elf > $(BUILD)/console.out
63+
$(Q)tail -n2 $(BUILD)/console.out
64+
$(Q)tail -n1 $(BUILD)/console.out | grep -q "status: 0"
6265

6366
.PHONY: $(BUILD)/genhdr/tests.h
6467

@@ -70,8 +73,12 @@ $(BUILD)/tinytest.o:
7073
$(Q)$(CC) $(CFLAGS) -DNO_FORKING -o $@ -c ../tools/tinytest/tinytest.c
7174

7275
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
73-
$(BUILD)/flash.elf: $(OBJ)
76+
$(BUILD)/firmware.elf: $(OBJ)
7477
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
7578
$(Q)$(SIZE) $@
7679

80+
$(BUILD)/firmware-test.elf: $(OBJ_TEST)
81+
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ_TEST) $(LIBS)
82+
$(Q)$(SIZE) $@
83+
7784
include ../py/mkrules.mk

qemu-arm/mpconfigport.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#define MICROPY_HELPER_REPL (0)
1313
#define MICROPY_HELPER_LEXER_UNIX (0)
1414
#define MICROPY_ENABLE_SOURCE_LINE (0)
15-
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
15+
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
1616
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
17+
#define MICROPY_PY_BUILTINS_FROZENSET (1)
18+
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
1719
#define MICROPY_PY_IO (0)
1820

1921
// type definitions for the specific machine

tools/tinytest-codegen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ def script_to_map(t):
4545
)
4646

4747
## XXX: may be we could have `--without <groups>` argument...
48-
test_dirs = ('basics', 'float', 'import', 'io', 'misc')
48+
# currently these tests are selected because they pass on qemu-arm
49+
test_dirs = ('basics',) # 'float', 'import', 'io', 'misc')
50+
exclude_tests = ('basics/builtin_override.py', 'basics/class_super_object.py', 'basics/memoryview_gc.py',)
4951

5052
output = []
5153

5254
for group in test_dirs:
53-
tests = glob('{}/*.py'.format(group))
55+
tests = [test for test in glob('{}/*.py'.format(group)) if test not in exclude_tests]
5456
output.extend([test_function.format(**script_to_map(test)) for test in tests])
5557
testcase_members = [testcase_member.format(**chew_filename(test)) for test in tests]
5658
output.append(testcase_struct.format(name=group, body='\n'.join(testcase_members)))

0 commit comments

Comments
 (0)