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.
pull/1047/merge
Damien George 2015-01-09 00:03:21 +00:00
rodzic 3990dcfcd7
commit 85e8e2ed5b
4 zmienionych plików z 28 dodań i 17 usunięć

Wyświetl plik

@ -15,7 +15,7 @@ script:
- make -C unix CC=gcc-4.7
- make -C unix-cpy CC=gcc-4.7
- make -C bare-arm
- make -C qemu-arm
- make -C qemu-arm test
- make -C stmhal
- make -C stmhal -B MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1
- make -C stmhal BOARD=STM32F4DISC

Wyświetl plik

@ -12,6 +12,7 @@ CROSS_COMPILE = arm-none-eabi-
INC = -I.
INC += -I..
INC += -I$(BUILD)
INC += -I../tools/tinytest/
CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT) \
@ -33,15 +34,11 @@ endif
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
LDFLAGS= --specs=nano.specs --specs=rdimon.specs -Wl,--gc-sections -Wl,-Map=$(@:.elf=.map)
ifeq ($(RUN_TESTS), 1)
SRC_C = \
test_main.c \
else
SRC_C = \
main.c \
endif
SRC_TEST_C = \
test_main.c \
SRC_S = \
@ -50,15 +47,21 @@ OBJ += $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
ifeq ($(RUN_TESTS), 1)
INC += -I../tools/tinytest/
OBJ += $(BUILD)/tinytest.o
endif
OBJ_TEST =
OBJ_TEST += $(PY_O)
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ_TEST += $(BUILD)/tinytest.o
all: run
run: $(BUILD)/flash.elf
qemu-system-arm -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/flash.elf
run: $(BUILD)/firmware.elf
qemu-system-arm -machine integratorcp -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/firmware.elf
test: $(BUILD)/firmware-test.elf
qemu-system-arm -machine integratorcp -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/firmware-test.elf > $(BUILD)/console.out
$(Q)tail -n2 $(BUILD)/console.out
$(Q)tail -n1 $(BUILD)/console.out | grep -q "status: 0"
.PHONY: $(BUILD)/genhdr/tests.h
@ -70,8 +73,12 @@ $(BUILD)/tinytest.o:
$(Q)$(CC) $(CFLAGS) -DNO_FORKING -o $@ -c ../tools/tinytest/tinytest.c
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
$(BUILD)/flash.elf: $(OBJ)
$(BUILD)/firmware.elf: $(OBJ)
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(Q)$(SIZE) $@
$(BUILD)/firmware-test.elf: $(OBJ_TEST)
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ_TEST) $(LIBS)
$(Q)$(SIZE) $@
include ../py/mkrules.mk

Wyświetl plik

@ -12,8 +12,10 @@
#define MICROPY_HELPER_REPL (0)
#define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_IO (0)
// type definitions for the specific machine

Wyświetl plik

@ -45,12 +45,14 @@ testgroup_member = (
)
## XXX: may be we could have `--without <groups>` argument...
test_dirs = ('basics', 'float', 'import', 'io', 'misc')
# currently these tests are selected because they pass on qemu-arm
test_dirs = ('basics',) # 'float', 'import', 'io', 'misc')
exclude_tests = ('basics/builtin_override.py', 'basics/class_super_object.py', 'basics/memoryview_gc.py',)
output = []
for group in test_dirs:
tests = glob('{}/*.py'.format(group))
tests = [test for test in glob('{}/*.py'.format(group)) if test not in exclude_tests]
output.extend([test_function.format(**script_to_map(test)) for test in tests])
testcase_members = [testcase_member.format(**chew_filename(test)) for test in tests]
output.append(testcase_struct.format(name=group, body='\n'.join(testcase_members)))