From 379737bc21bf27dc011b3fb1ef28a4d8ce276763 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Wed, 25 Oct 2017 15:06:48 +0200 Subject: [PATCH] tests/thread_msg: migrate to testrunner --- tests/thread_msg/Makefile | 5 ++++- tests/thread_msg/main.c | 16 +++++++++++++--- tests/thread_msg/tests/01-run.py | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100755 tests/thread_msg/tests/01-run.py diff --git a/tests/thread_msg/Makefile b/tests/thread_msg/Makefile index 5eb9ad1420..a4a810b0e5 100644 --- a/tests/thread_msg/Makefile +++ b/tests/thread_msg/Makefile @@ -1,8 +1,11 @@ APPLICATION = thread_msg include ../Makefile.tests_common -BOARD_INSUFFICIENT_MEMORY := nucleo32-f031 nucleo32-f042 stm32f0discovery +BOARD_INSUFFICIENT_MEMORY := nucleo32-f031 nucleo32-f042 DISABLE_MODULE += auto_init include $(RIOTBASE)/Makefile.include + +test: + tests/01-run.py diff --git a/tests/thread_msg/main.c b/tests/thread_msg/main.c index dcd21699c2..353238746e 100644 --- a/tests/thread_msg/main.c +++ b/tests/thread_msg/main.c @@ -28,7 +28,7 @@ char t1_stack[THREAD_STACKSIZE_MAIN]; char t2_stack[THREAD_STACKSIZE_MAIN]; char t3_stack[THREAD_STACKSIZE_MAIN]; -kernel_pid_t p1, p2, p3; +kernel_pid_t p_main, p1, p2, p3; void *thread1(void *arg) { @@ -47,13 +47,15 @@ void *thread1(void *arg) } puts("THREAD 1 end\n"); + msg_t msg; + msg_send(&msg, p_main); return NULL; } void *thread2(void *arg) { (void) arg; - puts("THREAD 2\n"); + puts("THREAD 2 start\n"); for (int i = 0;; ++i) { msg_t msg, reply; @@ -70,7 +72,7 @@ void *thread2(void *arg) void *thread3(void *arg) { (void) arg; - puts("THREAD 3\n"); + puts("THREAD 3 start\n"); for (int i = 0;; ++i) { msg_t msg; @@ -83,6 +85,7 @@ void *thread3(void *arg) int main(void) { + p_main = sched_active_pid; p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, thread1, NULL, "nr1"); @@ -93,5 +96,12 @@ int main(void) THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, thread3, NULL, "nr3"); puts("THREADS CREATED\n"); + + msg_t msg; + /* Wait until thread 1 is done */ + msg_receive(&msg); + + puts("SUCCESS"); + return 0; } diff --git a/tests/thread_msg/tests/01-run.py b/tests/thread_msg/tests/01-run.py new file mode 100755 index 0000000000..f09411b81c --- /dev/null +++ b/tests/thread_msg/tests/01-run.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) +import testrunner + + +def testfunc(child): + child.expect_exact('THREADS CREATED') + child.expect_exact('THREAD 1 start') + child.expect_exact('THREAD 2 start') + child.expect_exact('THREAD 3 start') + child.expect_exact('THREAD 1 end') + child.expect_exact('SUCCESS') + +if __name__ == "__main__": + sys.exit(testrunner.run(testfunc)) -- GitLab