1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/cpp11_thread: Use ztimer64_usec instead of xtimer

This commit is contained in:
MrKevinWeiss 2023-03-09 14:00:53 +01:00
parent 8e7407e5f6
commit 4795965ac2
No known key found for this signature in database
GPG Key ID: 4B69974722CBEEAE
3 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,7 @@
include ../Makefile.tests_common
USEMODULE += cpp11-compat
USEMODULE += xtimer
USEMODULE += ztimer64_usec
USEMODULE += timex
include $(RIOTBASE)/Makefile.include

View File

@ -1,3 +1,3 @@
CONFIG_MODULE_CPP11-COMPAT=y
CONFIG_MODULE_TIMEX=y
CONFIG_MODULE_XTIMER=y
CONFIG_ZTIMER64_USEC=y

View File

@ -22,6 +22,8 @@
#include <cstdio>
#include <system_error>
#include "timex.h"
#include "ztimer64.h"
#include "riot/mutex.hpp"
#include "riot/chrono.hpp"
#include "riot/thread.hpp"
@ -123,9 +125,9 @@ int main() {
puts("Testing sleep_for ...");
{
timex_t before, after;
xtimer_now_timex(&before);
before = timex_from_uint64(ztimer64_now(ZTIMER64_USEC));
this_thread::sleep_for(chrono::seconds(1));
xtimer_now_timex(&after);
after = timex_from_uint64(ztimer64_now(ZTIMER64_USEC));
auto diff = timex_sub(after, before);
expect(diff.seconds >= 1);
}
@ -136,9 +138,9 @@ int main() {
puts("Testing sleep_until ...");
{
timex_t before, after;
xtimer_now_timex(&before);
before = timex_from_uint64(ztimer64_now(ZTIMER64_USEC));
this_thread::sleep_until(riot::now() += chrono::seconds(1));
xtimer_now_timex(&after);
after = timex_from_uint64(ztimer64_now(ZTIMER64_USEC));
auto diff = timex_sub(after, before);
expect(diff.seconds >= 1);
}