1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

tests/periph_rtt: increase test coverage

Previously, the test didn't cover `rtt_set_counter()` and
`rtt_get_alarm`. This fixes the issue.
This commit is contained in:
Marian Buschsieweke 2021-03-03 17:08:30 +01:00
parent ab89234040
commit c6e50adc6a
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
4 changed files with 36 additions and 1 deletions

12
tests/periph_rtt/Kconfig Normal file
View File

@ -0,0 +1,12 @@
# Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg
#
# 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.
#
config APPLICATION
bool
default y
imply MODULE_PERIPH_RTT_SET_COUNTER
depends on TEST_KCONFIG

View File

@ -2,6 +2,7 @@ BOARD ?= samr21-xpro
include ../Makefile.tests_common
FEATURES_REQUIRED = periph_rtt
FEATURES_OPTIONAL += periph_rtt_set_counter
DISABLE_MODULE += periph_init_rtt

View File

@ -75,10 +75,32 @@ int main(void)
uint32_t now = rtt_get_counter();
printf("RTT now: %" PRIu32 "\n", now);
if (IS_USED(MODULE_PERIPH_RTT_SET_COUNTER)) {
puts("Setting RTT timer to 1337");
rtt_set_counter(1337);
now = rtt_get_counter();
printf("RTT now: %" PRIu32 "\n", now);
if ((now < 1337) || (now > 1337 + (1 * RTT_FREQUENCY + 999) / 1000)) {
puts("ERROR: rtt_set_counter() failed (off by more than 1 ms)");
return 1;
}
else {
puts("rtt_set_counter() PASSED");
}
}
last = (now + TICKS_TO_WAIT) & RTT_MAX_VALUE;
printf("Setting initial alarm to now + 5 s (%" PRIu32 ")\n", last);
rtt_set_alarm(last, cb, 0);
if (rtt_get_alarm() != last) {
puts("Error: rtt_get_alarm() not working");
return 1;
}
else {
puts("rtt_get_alarm() PASSED");
}
puts("Done setting up the RTT, wait for many Hellos");
return 0;
}

View File

@ -25,8 +25,8 @@ def testfunc(child):
child.expect(r'RTT now: \d+')
child.expect(r'Setting initial alarm to now \+ {} s \(\d+\)'
.format(period))
child.expect_exact('Done setting up the RTT, wait for many Hellos')
start = time.time()
child.expect_exact('Done setting up the RTT, wait for many Hellos')
for _ in range(MAX_HELLOS):
child.expect_exact('Hello\r\n', timeout=period + 1)