aboutsummaryrefslogtreecommitdiff
path: root/ports/zephyr
diff options
context:
space:
mode:
authorPaul Sokolovsky2017-12-15 12:10:39 +0200
committerPaul Sokolovsky2017-12-15 12:10:39 +0200
commit6b19520a743ddafcdd1881582d4c90a9ea068610 (patch)
tree454cb55fe93f52c5ed9af1e5701dd02cde9c848f /ports/zephyr
parent103eeffcd925891867916c6f7d23dcbb098c59fe (diff)
zephyr: Add support for binary with builtin testsuite.
If TEST is defined, file it refers to will be used as the testsuite source (should be generated with tools/tinytest-codegen.py). "make-bin-testsuite" script is introduce to build such a binary.
Diffstat (limited to 'ports/zephyr')
-rw-r--r--ports/zephyr/main.c15
-rwxr-xr-xports/zephyr/make-bin-testsuite20
-rw-r--r--ports/zephyr/mpconfigport_bin_testsuite.h31
3 files changed, 66 insertions, 0 deletions
diff --git a/ports/zephyr/main.c b/ports/zephyr/main.c
index d6ddc65cc..8c64fdcee 100644
--- a/ports/zephyr/main.c
+++ b/ports/zephyr/main.c
@@ -41,6 +41,13 @@
#include "lib/utils/pyexec.h"
#include "lib/mp-readline/readline.h"
+#ifdef TEST
+#include "lib/upytesthelper/upytesthelper.h"
+#include "lib/tinytest/tinytest.c"
+#include "lib/upytesthelper/upytesthelper.c"
+#include TEST
+#endif
+
static char *stack_top;
static char heap[MICROPY_HEAP_SIZE];
@@ -95,6 +102,14 @@ int real_main(void) {
init_zephyr();
+ #ifdef TEST
+ static const char *argv[] = {"test"};
+ upytest_set_heap(heap, heap + sizeof(heap));
+ int r = tinytest_main(1, argv, groups);
+ printf("status: %d\n", r);
+ return 0;
+ #endif
+
soft_reset:
#if MICROPY_ENABLE_GC
gc_init(heap, heap + sizeof(heap));
diff --git a/ports/zephyr/make-bin-testsuite b/ports/zephyr/make-bin-testsuite
new file mode 100755
index 000000000..f6aeb83f8
--- /dev/null
+++ b/ports/zephyr/make-bin-testsuite
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# This is a wrapper for make to build a binary with builtin testsuite.
+# It should be run just like make (i.e. extra vars can be passed on the
+# command line, etc.), e.g.:
+#
+# ./make-bin-testsuite BOARD=qemu_cortex_m3
+# ./make-bin-testsuite BOARD=qemu_cortex_m3 run
+#
+
+(cd ../../tests; ./run-tests --write-exp)
+(cd ../../tests; ./run-tests --list-tests --target=minimal \
+ -e async -e intbig -e int_big -e builtin_help -e memstats -e bytes_compare3 -e class_reverse_op \
+ -e /set -e frozenset -e complex -e const -e native -e viper \
+ -e 'float_divmod\.' -e float_parse_doubleprec -e float/true_value -e float/types \
+ | ../tools/tinytest-codegen.py --stdin) > bin-testsuite.c
+
+make \
+ CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_bin_testsuite.h>" -DTEST=\"bin-testsuite.c\" -DNO_FORKING' \
+ "$@"
diff --git a/ports/zephyr/mpconfigport_bin_testsuite.h b/ports/zephyr/mpconfigport_bin_testsuite.h
new file mode 100644
index 000000000..684b4f41c
--- /dev/null
+++ b/ports/zephyr/mpconfigport_bin_testsuite.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Linaro Limited
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "mpconfigport.h"
+
+#ifdef TEST
+#include "lib/upytesthelper/upytesthelper.h"
+#define MP_PLAT_PRINT_STRN(str, len) upytest_output(str, len)
+#endif