-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/event_periodic_callback: add test for periodic callback
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include ../Makefile.tests_common | ||
|
||
USEMODULE += event_periodic_callback | ||
USEMODULE += ztimer_msec | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
BOARD_INSUFFICIENT_MEMORY := \ | ||
nucleo-l011k4 \ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2022 ML!PA Consulting GmbH | ||
* | ||
* 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 Periodic Callback test application | ||
* | ||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "event/periodic_callback.h" | ||
|
||
static void _event_cb(void *ctx) | ||
{ | ||
puts(ctx); | ||
} | ||
|
||
int main(void) | ||
{ | ||
event_periodic_callback_t a, b, c; | ||
|
||
event_periodic_callback_init(&a, ZTIMER_MSEC, EVENT_PRIO_MEDIUM, _event_cb, "event A"); | ||
event_periodic_callback_init(&b, ZTIMER_MSEC, EVENT_PRIO_MEDIUM, _event_cb, "event B"); | ||
event_periodic_callback_init(&c, ZTIMER_MSEC, EVENT_PRIO_MEDIUM, _event_cb, "event C"); | ||
|
||
event_periodic_callback_set_count(&a, 6); | ||
event_periodic_callback_set_count(&b, 3); | ||
event_periodic_callback_set_count(&c, 2); | ||
|
||
event_periodic_callback_start(&a, 502); | ||
event_periodic_callback_start(&b, 1001); | ||
event_periodic_callback_start(&c, 1500); | ||
|
||
ztimer_sleep(ZTIMER_MSEC, 3020); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
from testrunner import run | ||
|
||
|
||
def testfunc(child): | ||
child.expect_exact("event A") | ||
child.expect_exact("event B") | ||
child.expect_exact("event A") | ||
child.expect_exact("event C") | ||
child.expect_exact("event A") | ||
child.expect_exact("event B") | ||
child.expect_exact("event A") | ||
child.expect_exact("event A") | ||
child.expect_exact("event C") | ||
child.expect_exact("event B") | ||
child.expect_exact("event A") | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(run(testfunc)) |