Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests-zt: This test stalls compiled with tests-pkg and tests-nanocoap_cache #18312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unittests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(void)
ztimer_init();
#endif

#ifdef MODULE_XTIMER
#if IS_USED(MODULE_XTIMER) && !IS_USED(MODULE_ZTIMER_XTIMER_COMPAT)
/* auto_init is disabled, but some modules depends on this module being initialized */
xtimer_init();
#endif
Expand Down
6 changes: 6 additions & 0 deletions tests/unittests/tests-zt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# avoid clang warning in tests-ztimer/tests-ztimer-extend.c:141
ifeq (llvm,$(TOOLCHAIN))
CFLAGS += -Wno-gnu-folding-constant
endif

include $(RIOTBASE)/Makefile.base
2 changes: 2 additions & 0 deletions tests/unittests/tests-zt/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USEMODULE += ztimer_core
USEMODULE += ztimer_msec
50 changes: 50 additions & 0 deletions tests/unittests/tests-zt/tests-zt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2022 K F
*
* 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.
*/

/**
* @{
*
* @file
* @brief Unittest entry point for the zt test group
*
* @author kfessel
*/
#include <stdint.h>
#include <ztimer.h>
#include <stdio.h>
#include "embUnit/embUnit.h"

#include "tests-zt.h"

void zt_sleep(void){
uint32_t start = ztimer_now(ZTIMER_MSEC);
puts( "will sleep");
ztimer_sleep(ZTIMER_MSEC,2000);
puts( "done sleep");
uint32_t end = ztimer_now(ZTIMER_MSEC);
TEST_ASSERT_EQUAL_INT(2000, end - start);

}

Test * tests_zt_test(void){

EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(zt_sleep)
};

EMB_UNIT_TESTCALLER(zt_tests, NULL, NULL, fixtures);

return (Test *)&zt_tests;
}

void tests_zt(void)
{
TESTS_RUN(tests_zt_test());

}
/** @} */
37 changes: 37 additions & 0 deletions tests/unittests/tests-zt/tests-zt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 K F
*
* 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.
*/

/**
* @addtogroup unittests
* @{
*
* @file
* @brief Unittests for zt
*
* @author kfessel
*/
#ifndef TESTS_ZT_H
#define TESTS_ZT_H

#include "embUnit.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief The entry point of this test suite.
*/
void tests_zt(void);

#ifdef __cplusplus
}
#endif

#endif /* TESTS_ZT_H */
/** @} */