Skip to content
Snippets Groups Projects
Commit 3608a9a6 authored by Sebastian Meiling's avatar Sebastian Meiling
Browse files

tests, thread_flood: update test script and output

parent 08eb6c39
No related branches found
No related tags found
No related merge requests found
/* /*
* 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 * 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 * General Public License v2.1. See the file LICENSE in the top level
...@@ -16,16 +16,19 @@ ...@@ -16,16 +16,19 @@
* Spawns sleeping threads till the scheduler's capacity is exhausted. * Spawns sleeping threads till the scheduler's capacity is exhausted.
* *
* @author Andreas "Paul" Pauli <andreas.pauli@haw-hamburg.de> * @author Andreas "Paul" Pauli <andreas.pauli@haw-hamburg.de>
* @author Sebastian Meiling <s@mlng.net>
* *
* @} * @}
*/ */
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include "thread.h" #include "thread.h"
#include "kernel_types.h"
/* One stack for all threads. DON'T TRY THIS AT HOME!! */ /* 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) static void *thread_func(void *arg)
{ {
...@@ -35,6 +38,7 @@ static void *thread_func(void *arg) ...@@ -35,6 +38,7 @@ static void *thread_func(void *arg)
int main(void) int main(void)
{ {
kernel_pid_t thr_id = KERNEL_PID_UNDEF; kernel_pid_t thr_id = KERNEL_PID_UNDEF;
unsigned thr_cnt = 0;
puts("[START] Spawning threads"); puts("[START] Spawning threads");
do { do {
...@@ -43,11 +47,21 @@ int main(void) ...@@ -43,11 +47,21 @@ int main(void)
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST, THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST,
thread_func, NULL, "dummy"); thread_func, NULL, "dummy");
++thr_cnt;
printf(".");
} while (-EOVERFLOW != thr_id); } while (-EOVERFLOW != thr_id);
puts("");
/* decrease by 1 because last thread_create failed */
--thr_cnt;
if (-EOVERFLOW == thr_id) { /* expect (MAXTHREADS - 2), as main and idle thread take a PID each */
puts("[SUCCESS] Thread creation successfully aborted"); if (thr_cnt == (MAXTHREADS - 2)) {
printf("[SUCCESS]");
}
else {
printf("[ERROR] expected %u,", (MAXTHREADS - 2));
} }
printf(" created %u\n", thr_cnt);
return 0; return 0;
} }
...@@ -9,7 +9,8 @@ import testrunner ...@@ -9,7 +9,8 @@ import testrunner
def testfunc(child): def testfunc(child):
child.expect_exact(u'[START] Spawning threads') 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__": if __name__ == "__main__":
sys.exit(testrunner.run(testfunc)) sys.exit(testrunner.run(testfunc))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment