From abcec5579d973010292199c424bc4d17d75168d3 Mon Sep 17 00:00:00 2001 From: lecopzer Date: Sat, 17 Mar 2018 18:31:22 +0800 Subject: [PATCH 1/2] tests: Check python version before import Make sure python version is >= 3.5, so that the import file 'runner' can be imported correctly. --- tests/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/__main__.py b/tests/__main__.py index 880fc44..6aec324 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -1,3 +1,8 @@ +import sys +if sys.version_info < (3, 5): + print ("Only support python version >= 3.5") + exit(1) + import argparse import tests.runner as runner from tests.runner import PikoTest From d397f228689d697cbd821ef679f58bbdcec8ef86 Mon Sep 17 00:00:00 2001 From: lecopzer Date: Sat, 17 Mar 2018 19:17:05 +0800 Subject: [PATCH 2/2] Makefile: Fix hardcode of gcc and qemu binary Instead of always exporting $PATH to right qemu/gcc path, make it more flexible. --- Makefile | 2 +- mk/flags.mk | 3 ++- platform/stm32p103/build.mk | 4 ++-- tests/__main__.py | 2 ++ tests/runner.py | 12 ++++++------ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d5a6a1c..41bb495 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ include mk/cmsis.mk prebuild: $(CMSIS)/$(PLAT) check: - $(PYTHON) -m tests -p $(PLAT) + $(PYTHON) -m tests -p $(PLAT) --qemu $(QEMU_SYSTEM_ARM) --cc $(CC) clean: find . -name "*.o" -type f -delete diff --git a/mk/flags.mk b/mk/flags.mk index 2b26454..20a3a6d 100644 --- a/mk/flags.mk +++ b/mk/flags.mk @@ -1,4 +1,4 @@ -CROSS_COMPILE = arm-none-eabi- +CROSS_COMPILE ?= arm-none-eabi- CC = $(CROSS_COMPILE)gcc AS = $(CROSS_COMPILE)as AR = $(CROSS_COMPILE)ar @@ -8,6 +8,7 @@ HOSTCC = gcc WGET = wget # FIXME: check version >= 3.5 PYTHON = python3 +QEMU_SYSTEM_ARM ?= qemu-system-arm # FIXME: configurable via menuconfig or command line CFLAGS_OPT = -Os # -flto diff --git a/platform/stm32p103/build.mk b/platform/stm32p103/build.mk index 71a7232..88b3226 100644 --- a/platform/stm32p103/build.mk +++ b/platform/stm32p103/build.mk @@ -3,7 +3,7 @@ ifeq ($(shell lsb_release -c -s),trusty) endif run: $(NAME).bin - $(Q)qemu-system-arm \ + $(Q)$(QEMU_SYSTEM_ARM) \ -semihosting \ $(REDIRECT_SERIAL) \ -nographic \ @@ -12,7 +12,7 @@ run: $(NAME).bin -kernel $< dbg: $(NAME).bin - $(Q)qemu-system-arm \ + $(Q)$(QEMU_SYSTEM_ARM) \ -semihosting \ $(REDIRECT_SERIAL) \ -nographic \ diff --git a/tests/__main__.py b/tests/__main__.py index 6aec324..e4d92c5 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -16,6 +16,8 @@ help='no output unless one or more tests fail') parser.add_argument('--debug', action='store_true', help='Run test and wait for gdb connect') parser.add_argument('-p', '--platform', default='stm32p103') + parser.add_argument('--qemu', default='qemu-system-arm') + parser.add_argument('--cc', default='arm-none-eabi-gcc') parser.add_argument('--timeout', type=int, default=60) parser.add_argument('--slowest', action='store_true', dest='print_slow', help='print the slowest 10 tests') diff --git a/tests/runner.py b/tests/runner.py index 0d410bf..ccec79d 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -132,8 +132,8 @@ def display_header(self): % (locale.getpreferredencoding(False), sys.getfilesystemencoding())) print() - print_qemu_version() - print_gcc_version() + print_qemu_version(self.ns) + print_gcc_version(self.ns) def accumulate_result(self, test, result): ok, test_time = result @@ -212,8 +212,8 @@ def main(self, tests, ns): sys.exit(0) -def print_qemu_version(): - cmd = ["qemu-system-arm", "--version"] +def print_qemu_version(ns): + cmd = [ns.qemu, "--version"] res = subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) print() @@ -221,8 +221,8 @@ def print_qemu_version(): print() -def print_gcc_version(): - cmd = ["arm-none-eabi-gcc", "--version"] +def print_gcc_version(ns): + cmd = [ns.cc, "--version"] res = subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) print()