diff --git a/tests/thread_flood/main.c b/tests/thread_flood/main.c index e1088103ab8f44857a21903df2950dd6a1a18980..bfc58d1c5c40345edd2a33774a20a60a1fc0dbc2 100644 --- a/tests/thread_flood/main.c +++ b/tests/thread_flood/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Hamburg University of Applied Sciences + * Copyright (C) 2015-2017 Hamburg University of Applied Sciences * * 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 @@ -16,16 +16,19 @@ * Spawns sleeping threads till the scheduler's capacity is exhausted. * * @author Andreas "Paul" Pauli <andreas.pauli@haw-hamburg.de> + * @author Sebastian Meiling <s@mlng.net> * * @} */ #include <errno.h> #include <stdio.h> + #include "thread.h" +#include "kernel_types.h" /* One stack for all threads. DON'T TRY THIS AT HOME!! */ -static char dummy_stack[THREAD_STACKSIZE_DEFAULT]; +static char dummy_stack[THREAD_STACKSIZE_IDLE]; static void *thread_func(void *arg) { @@ -35,6 +38,7 @@ static void *thread_func(void *arg) int main(void) { kernel_pid_t thr_id = KERNEL_PID_UNDEF; + unsigned thr_cnt = 0; puts("[START] Spawning threads"); do { @@ -43,11 +47,21 @@ int main(void) THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST, thread_func, NULL, "dummy"); + ++thr_cnt; + printf("."); } while (-EOVERFLOW != thr_id); + puts(""); + /* decrease by 1 because last thread_create failed */ + --thr_cnt; - if (-EOVERFLOW == thr_id) { - puts("[SUCCESS] Thread creation successfully aborted"); + /* expect (MAXTHREADS - 2), as main and idle thread take a PID each */ + if (thr_cnt == (MAXTHREADS - 2)) { + printf("[SUCCESS]"); + } + else { + printf("[ERROR] expected %u,", (MAXTHREADS - 2)); } + printf(" created %u\n", thr_cnt); return 0; } diff --git a/tests/thread_flood/tests/01-run.py b/tests/thread_flood/tests/01-run.py index 29d6411230eef0da7ec16ab9556deb270d7721f1..4cc744e010f58452e52835d443d41db02151e3e5 100755 --- a/tests/thread_flood/tests/01-run.py +++ b/tests/thread_flood/tests/01-run.py @@ -9,7 +9,8 @@ import testrunner def testfunc(child): child.expect_exact(u'[START] Spawning threads') - child.expect_exact(u'[SUCCESS] Thread creation') + child.expect(r'\.+') + child.expect(r'\[SUCCESS\] created \d+') if __name__ == "__main__": sys.exit(testrunner.run(testfunc))