1
0
forked from fsfw/fsfw

unittests for rtems working

This commit is contained in:
2023-01-19 14:24:33 +01:00
parent fdfdce2fb0
commit adb8483bb0
5 changed files with 77 additions and 29 deletions

View File

@ -8,6 +8,8 @@
#include "CatchDefinitions.h"
//TODO setClock()
TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") {
SECTION("Test getClock") {
timeval time;
@ -22,7 +24,14 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") {
// We require timeOfDayAsTimeval to be larger than time as it
// was request a few ns later
double difference = timevalOperations::toDouble(timeOfDayAsTimeval - time);
CHECK(difference >= 0.0);
uint32_t ticksPerSecond =Clock:: getTicksPerSecond();
float secondPerTick = 0;
if (ticksPerSecond != 0){
secondPerTick = 1.0 / ticksPerSecond;
}
// In rtems, timevals have microsecond resolution, while TOD has only tick resolution, leading to
// negative differences when comparing "equal" times
CHECK(difference >= -secondPerTick);
CHECK(difference <= 0.005);
// Conversion in the other direction