diff --git a/tests/mutex_unlock_and_sleep/Makefile b/tests/mutex_unlock_and_sleep/Makefile index 19eb537f4fbda5a9d4a9ef3abdcf55e52c2a6a8d..113dd5f61468614b25d9b0bb280a07261daf9c7c 100644 --- a/tests/mutex_unlock_and_sleep/Makefile +++ b/tests/mutex_unlock_and_sleep/Makefile @@ -1,7 +1,8 @@ include ../Makefile.tests_common -BOARD_INSUFFICIENT_MEMORY := nucleo32-f031 - DISABLE_MODULE += auto_init include $(RIOTBASE)/Makefile.include + +test: + tests/01-run.py diff --git a/tests/mutex_unlock_and_sleep/main.c b/tests/mutex_unlock_and_sleep/main.c index 96389b2cd796c524e3d322e7d56b5032013e5af0..43f9404cbdf5cdefe76a2159aaf63c6e4d5e12b9 100644 --- a/tests/mutex_unlock_and_sleep/main.c +++ b/tests/mutex_unlock_and_sleep/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Hamburg University of Applied Siences (HAW) + * Copyright (C) 2014-2017 HAW Hamburg * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -14,7 +14,7 @@ * @brief simple test application for atomic mutex unlocking and sleeping * * @author Martin Landsmann <martin.landsmann@haw-hamburg.de> - * + * @author Sebastian Meiling <s@mlng.net> * @} */ @@ -23,10 +23,10 @@ #include "mutex.h" static mutex_t mutex = MUTEX_INIT; -static volatile int indicator, count; +static volatile int indicator; static kernel_pid_t main_pid; +static char stack[THREAD_STACKSIZE_DEFAULT]; -static char stack[THREAD_STACKSIZE_MAIN]; static void *second_thread(void *arg) { (void) arg; @@ -41,9 +41,9 @@ static void *second_thread(void *arg) int main(void) { - indicator = 0; - count = 0; + uint32_t count = 0; + indicator = 0; main_pid = thread_getpid(); kernel_pid_t second_pid = thread_create(stack, @@ -60,15 +60,13 @@ int main(void) indicator++; count++; - if (indicator > 1 || indicator < -1) { - printf("Error, threads did not sleep properly. [indicator: %d]\n", indicator); - return -1; + if ((indicator > 1) || (indicator < -1)) { + printf("[ERROR] threads did not sleep properly (%d).\n", indicator); + return 1; } - if ((count % 100000) == 0) { - printf("Still alive alternated [count: %dk] times.\n", count / 1000); + printf("[ALIVE] alternated %"PRIu32"k times.\n", (count / 1000)); } - mutex_unlock_and_sleep(&mutex); } } diff --git a/tests/mutex_unlock_and_sleep/tests/01-run.py b/tests/mutex_unlock_and_sleep/tests/01-run.py new file mode 100755 index 0000000000000000000000000000000000000000..eb74e3799a358d2e3585033a945b1d7174cf7d89 --- /dev/null +++ b/tests/mutex_unlock_and_sleep/tests/01-run.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2017 HAW Hamburg +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import os +import sys + +sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) +import testrunner + + +def testfunc(child): + for i in range(20): + child.expect(r"\[ALIVE\] alternated \d+k times.") + +if __name__ == "__main__": + sys.exit(testrunner.run(testfunc))