mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: Add event_thread tests for shared thread
This commit is contained in:
parent
c6211cc6c2
commit
10471a33b3
5
tests/event_thread_shared/Makefile
Normal file
5
tests/event_thread_shared/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += event_thread
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
3
tests/event_thread_shared/Makefile.ci
Normal file
3
tests/event_thread_shared/Makefile.ci
Normal file
@ -0,0 +1,3 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l011k4 \
|
||||
#
|
59
tests/event_thread_shared/main.c
Normal file
59
tests/event_thread_shared/main.c
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2020 Freie Universität Berlin
|
||||
* 2020 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 Event threads test application
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "event/thread.h"
|
||||
|
||||
static void _handler_high(event_t *event) {
|
||||
(void)event;
|
||||
puts("high");
|
||||
}
|
||||
|
||||
static event_t event_high = { .handler=_handler_high };
|
||||
|
||||
static void _handler_medium(event_t *event) {
|
||||
(void)event;
|
||||
event_post(EVENT_PRIO_HIGHEST, &event_high);
|
||||
puts("medium");
|
||||
}
|
||||
|
||||
static event_t event_medium = { .handler=_handler_medium };
|
||||
|
||||
static void _handler_low(event_t *event) {
|
||||
(void)event;
|
||||
event_post(EVENT_PRIO_MEDIUM, &event_medium);
|
||||
event_post(EVENT_PRIO_HIGHEST, &event_high);
|
||||
puts("low");
|
||||
}
|
||||
|
||||
static event_t event_low = { .handler=_handler_low };
|
||||
|
||||
int main(void)
|
||||
{
|
||||
event_post(EVENT_PRIO_LOWEST, &event_low);
|
||||
|
||||
puts("main done");
|
||||
|
||||
return 0;
|
||||
}
|
16
tests/event_thread_shared/tests/01-run.py
Executable file
16
tests/event_thread_shared/tests/01-run.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact('low\r\n')
|
||||
child.expect_exact('high\r\n')
|
||||
child.expect_exact('medium\r\n')
|
||||
child.expect_exact('high\r\n')
|
||||
child.expect_exact('main done\r\n')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
Loading…
Reference in New Issue
Block a user