1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/thread_exit/main.c
Francisco Molina 416c048737 tests: add test_utils_interactive_sync when possible
- Define test_utils_interactive_sync as DEFAULT_MODULE in Makefile.tests_common
- For tests disabling autoinit, add test_utils_interactive_sync to main
- Add DISABLE_MODULE += test_utils_interactive_sync for tests requiring
  sudo,  `tests/shell`, `tests/minimal` and `tests/stdin`
- Add shell_commands to tests/periph_wdt and tests/struct_tm_utility to
  pull `r` and `s` commands
- Remove includes and usage in `tests/main.c` for tests that where
  already using test_utils_interactive_sync
2019-11-27 15:07:42 +01:00

101 lines
2.0 KiB
C

/*
* Copyright (C) 2013 INRIA
*
* 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.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Thread test application
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*
* @}
*/
#include <stdio.h>
#include "thread.h"
#include "test_utils/interactive_sync.h"
char second_thread_stack[THREAD_STACKSIZE_MAIN];
char third_thread_stack[THREAD_STACKSIZE_MAIN];
void *fourth_thread(void *arg)
{
(void) arg;
puts("4th: starting");
puts("4th: exiting");
return NULL;
}
void *third_thread(void *arg)
{
(void) arg;
puts("3rd: starting");
puts("3rd: exiting");
return NULL;
}
void *second_thread(void *arg)
{
(void) arg;
puts("2nd: starting");
if ((thread_create(
third_thread_stack,
sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 2,
THREAD_CREATE_STACKTEST,
third_thread,
NULL,
"nr3")
) == -1) {
puts("2nd: Error creating 3rd thread.");
}
/* thread should have returned already */
if ((thread_create(
third_thread_stack,
sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
fourth_thread,
NULL,
"nr4")
) == -1) {
puts("2nd: Error creating 4th thread.");
}
puts("2nd: exiting");
return NULL;
}
int main(void)
{
test_utils_interactive_sync();
puts("main: starting");
if ((thread_create(
second_thread_stack,
sizeof(second_thread_stack),
THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread,
NULL,
"nr2")
) == -1) {
puts("main: Error creating 2nd thread.");
}
puts("main: exiting");
return 0;
}