Applied clang format
This commit is contained in:
parent
10398855a9
commit
665d8cd479
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#include "fsfw/ipc/MutexGuard.h"
|
||||||
#include "fsfw/platform.h"
|
#include "fsfw/platform.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/ipc/MutexGuard.h"
|
|
||||||
|
|
||||||
#if defined(PLATFORM_WIN)
|
#if defined(PLATFORM_WIN)
|
||||||
#include <sysinfoapi.h>
|
#include <sysinfoapi.h>
|
||||||
@ -125,8 +125,8 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
|||||||
auto seconds = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
auto seconds = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
||||||
auto fraction = now - seconds;
|
auto fraction = now - seconds;
|
||||||
time_t tt = SystemClock::to_time_t(now);
|
time_t tt = SystemClock::to_time_t(now);
|
||||||
ReturnValue_t result = checkOrCreateClockMutex();
|
ReturnValue_t result = checkOrCreateClockMutex();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
MutexGuard helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
|
||||||
#include "fsfw/ipc/MutexGuard.h"
|
#include "fsfw/ipc/MutexGuard.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
uint32_t Clock::getTicksPerSecond(void) {
|
uint32_t Clock::getTicksPerSecond(void) {
|
||||||
uint32_t ticks = sysconf(_SC_CLK_TCK);
|
uint32_t ticks = sysconf(_SC_CLK_TCK);
|
||||||
@ -116,7 +116,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
ReturnValue_t result = checkOrCreateClockMutex();
|
ReturnValue_t result = checkOrCreateClockMutex();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
MutexGuard helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "fsfw/ipc/MutexGuard.h"
|
#include "fsfw/ipc/MutexGuard.h"
|
||||||
#include "fsfw/osal/rtems/RtemsBasic.h"
|
#include "fsfw/osal/rtems/RtemsBasic.h"
|
||||||
|
|
||||||
|
|
||||||
uint32_t Clock::getTicksPerSecond(void) {
|
uint32_t Clock::getTicksPerSecond(void) {
|
||||||
rtems_interval ticks_per_second = rtems_clock_get_ticks_per_second();
|
rtems_interval ticks_per_second = rtems_clock_get_ticks_per_second();
|
||||||
return static_cast<uint32_t>(ticks_per_second);
|
return static_cast<uint32_t>(ticks_per_second);
|
||||||
|
@ -39,7 +39,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
||||||
if(not leapSecondsSet){
|
if (not leapSecondsSet) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
|
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -58,7 +58,7 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t*
|
|||||||
// in the Windows CRT is incompatible with the C standard but this should not be an issue for
|
// in the Windows CRT is incompatible with the C standard but this should not be an issue for
|
||||||
// this implementation
|
// this implementation
|
||||||
ReturnValue_t result = checkOrCreateClockMutex();
|
ReturnValue_t result = checkOrCreateClockMutex();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
MutexGuard helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "fsfw/FSFWVersion.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include "fsfw/FSFWVersion.h"
|
||||||
|
|
||||||
#ifdef major
|
#ifdef major
|
||||||
#undef major
|
#undef major
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@ class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator>(const Version& v1, const Version& v2) {
|
friend bool operator>(const Version& v1, const Version& v2) {
|
||||||
return not (v1 < v2) and not (v1 == v2);
|
return not(v1 < v2) and not(v1 == v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); }
|
friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); }
|
||||||
|
@ -1,125 +1,124 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <catch2/catch_approx.hpp>
|
|
||||||
|
|
||||||
#include <fsfw/globalfunctions/timevalOperations.h>
|
#include <fsfw/globalfunctions/timevalOperations.h>
|
||||||
|
|
||||||
|
#include <catch2/catch_approx.hpp>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "fsfw_tests/unit/CatchDefinitions.h"
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
TEST_CASE("TimevalTest", "[timevalOperations]"){
|
TEST_CASE("TimevalTest", "[timevalOperations]") {
|
||||||
SECTION("Comparison"){
|
SECTION("Comparison") {
|
||||||
timeval t1;
|
timeval t1;
|
||||||
t1.tv_sec = 1648227422;
|
t1.tv_sec = 1648227422;
|
||||||
t1.tv_usec = 123456;
|
t1.tv_usec = 123456;
|
||||||
timeval t2;
|
timeval t2;
|
||||||
t2.tv_sec = 1648227422;
|
t2.tv_sec = 1648227422;
|
||||||
t2.tv_usec = 123456;
|
t2.tv_usec = 123456;
|
||||||
REQUIRE(t1 == t2);
|
REQUIRE(t1 == t2);
|
||||||
REQUIRE(t2 == t1);
|
REQUIRE(t2 == t1);
|
||||||
REQUIRE_FALSE(t1 != t2);
|
REQUIRE_FALSE(t1 != t2);
|
||||||
REQUIRE_FALSE(t2 != t1);
|
REQUIRE_FALSE(t2 != t1);
|
||||||
REQUIRE(t1 <= t2);
|
REQUIRE(t1 <= t2);
|
||||||
REQUIRE(t2 <= t1);
|
REQUIRE(t2 <= t1);
|
||||||
REQUIRE(t1 >= t2);
|
REQUIRE(t1 >= t2);
|
||||||
REQUIRE(t2 >= t1);
|
REQUIRE(t2 >= t1);
|
||||||
REQUIRE_FALSE(t1 < t2);
|
REQUIRE_FALSE(t1 < t2);
|
||||||
REQUIRE_FALSE(t2 < t1);
|
REQUIRE_FALSE(t2 < t1);
|
||||||
REQUIRE_FALSE(t1 > t2);
|
REQUIRE_FALSE(t1 > t2);
|
||||||
REQUIRE_FALSE(t2 > t1);
|
REQUIRE_FALSE(t2 > t1);
|
||||||
|
|
||||||
timeval t3;
|
timeval t3;
|
||||||
t3.tv_sec = 1648227422;
|
t3.tv_sec = 1648227422;
|
||||||
t3.tv_usec = 123457;
|
t3.tv_usec = 123457;
|
||||||
REQUIRE_FALSE(t1 == t3);
|
REQUIRE_FALSE(t1 == t3);
|
||||||
REQUIRE(t1 != t3);
|
REQUIRE(t1 != t3);
|
||||||
REQUIRE(t1 <= t3);
|
REQUIRE(t1 <= t3);
|
||||||
REQUIRE_FALSE(t3 <= t1);
|
REQUIRE_FALSE(t3 <= t1);
|
||||||
REQUIRE_FALSE(t1 >= t3);
|
REQUIRE_FALSE(t1 >= t3);
|
||||||
REQUIRE(t3 >= t1);
|
REQUIRE(t3 >= t1);
|
||||||
REQUIRE(t1 < t3);
|
REQUIRE(t1 < t3);
|
||||||
REQUIRE_FALSE(t3 < t1);
|
REQUIRE_FALSE(t3 < t1);
|
||||||
REQUIRE_FALSE(t1 > t3);
|
REQUIRE_FALSE(t1 > t3);
|
||||||
REQUIRE(t3 > t1);
|
REQUIRE(t3 > t1);
|
||||||
|
|
||||||
timeval t4;
|
timeval t4;
|
||||||
t4.tv_sec = 1648227423;
|
t4.tv_sec = 1648227423;
|
||||||
t4.tv_usec = 123456;
|
t4.tv_usec = 123456;
|
||||||
REQUIRE_FALSE(t1 == t4);
|
REQUIRE_FALSE(t1 == t4);
|
||||||
REQUIRE(t1 != t4);
|
REQUIRE(t1 != t4);
|
||||||
REQUIRE(t1 <= t4);
|
REQUIRE(t1 <= t4);
|
||||||
REQUIRE_FALSE(t4 <= t1);
|
REQUIRE_FALSE(t4 <= t1);
|
||||||
REQUIRE_FALSE(t1 >= t4);
|
REQUIRE_FALSE(t1 >= t4);
|
||||||
REQUIRE(t4 >= t1);
|
REQUIRE(t4 >= t1);
|
||||||
REQUIRE(t1 < t4);
|
REQUIRE(t1 < t4);
|
||||||
REQUIRE_FALSE(t4 < t1);
|
REQUIRE_FALSE(t4 < t1);
|
||||||
REQUIRE_FALSE(t1 > t4);
|
REQUIRE_FALSE(t1 > t4);
|
||||||
REQUIRE(t4 > t1);
|
REQUIRE(t4 > t1);
|
||||||
}
|
}
|
||||||
SECTION("Operators"){
|
SECTION("Operators") {
|
||||||
timeval t1;
|
timeval t1;
|
||||||
t1.tv_sec = 1648227422;
|
t1.tv_sec = 1648227422;
|
||||||
t1.tv_usec = 123456;
|
t1.tv_usec = 123456;
|
||||||
timeval t2;
|
timeval t2;
|
||||||
t2.tv_sec = 1648227422;
|
t2.tv_sec = 1648227422;
|
||||||
t2.tv_usec = 123456;
|
t2.tv_usec = 123456;
|
||||||
timeval t3 = t1 - t2;
|
timeval t3 = t1 - t2;
|
||||||
REQUIRE(t3.tv_sec == 0);
|
REQUIRE(t3.tv_sec == 0);
|
||||||
REQUIRE(t3.tv_usec == 0);
|
REQUIRE(t3.tv_usec == 0);
|
||||||
timeval t4 = t1 - t3;
|
timeval t4 = t1 - t3;
|
||||||
REQUIRE(t4.tv_sec == 1648227422);
|
REQUIRE(t4.tv_sec == 1648227422);
|
||||||
REQUIRE(t4.tv_usec == 123456);
|
REQUIRE(t4.tv_usec == 123456);
|
||||||
timeval t5 = t3 - t1;
|
timeval t5 = t3 - t1;
|
||||||
REQUIRE(t5.tv_sec == -1648227422);
|
REQUIRE(t5.tv_sec == -1648227422);
|
||||||
REQUIRE(t5.tv_usec == -123456);
|
REQUIRE(t5.tv_usec == -123456);
|
||||||
|
|
||||||
timeval t6;
|
timeval t6;
|
||||||
t6.tv_sec = 1648227400;
|
t6.tv_sec = 1648227400;
|
||||||
t6.tv_usec = 999999;
|
t6.tv_usec = 999999;
|
||||||
|
|
||||||
timeval t7 = t6 + t1;
|
timeval t7 = t6 + t1;
|
||||||
REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull));
|
REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull));
|
||||||
REQUIRE(t7.tv_usec == 123455);
|
REQUIRE(t7.tv_usec == 123455);
|
||||||
|
|
||||||
timeval t8 = t1 - t6;
|
timeval t8 = t1 - t6;
|
||||||
REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1);
|
REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1);
|
||||||
REQUIRE(t8.tv_usec == 123457);
|
REQUIRE(t8.tv_usec == 123457);
|
||||||
|
|
||||||
double scalar = 2;
|
double scalar = 2;
|
||||||
timeval t9 = t1 * scalar;
|
timeval t9 = t1 * scalar;
|
||||||
REQUIRE(t9.tv_sec == 3296454844);
|
REQUIRE(t9.tv_sec == 3296454844);
|
||||||
REQUIRE(t9.tv_usec == 246912);
|
REQUIRE(t9.tv_usec == 246912);
|
||||||
timeval t10 = scalar * t1;
|
timeval t10 = scalar * t1;
|
||||||
REQUIRE(t10.tv_sec == 3296454844);
|
REQUIRE(t10.tv_sec == 3296454844);
|
||||||
REQUIRE(t10.tv_usec == 246912);
|
REQUIRE(t10.tv_usec == 246912);
|
||||||
timeval t11 = t6 * scalar;
|
timeval t11 = t6 * scalar;
|
||||||
REQUIRE(t11.tv_sec == (3296454800 + 1));
|
REQUIRE(t11.tv_sec == (3296454800 + 1));
|
||||||
REQUIRE(t11.tv_usec == 999998);
|
REQUIRE(t11.tv_usec == 999998);
|
||||||
|
|
||||||
timeval t12 = t1 / scalar;
|
timeval t12 = t1 / scalar;
|
||||||
REQUIRE(t12.tv_sec == 824113711);
|
REQUIRE(t12.tv_sec == 824113711);
|
||||||
REQUIRE(t12.tv_usec == 61728);
|
REQUIRE(t12.tv_usec == 61728);
|
||||||
|
|
||||||
timeval t13 = t6 / scalar;
|
timeval t13 = t6 / scalar;
|
||||||
REQUIRE(t13.tv_sec == 824113700);
|
REQUIRE(t13.tv_sec == 824113700);
|
||||||
// Rounding issue
|
// Rounding issue
|
||||||
REQUIRE(t13.tv_usec == 499999);
|
REQUIRE(t13.tv_usec == 499999);
|
||||||
|
|
||||||
double scalar2 = t9 / t1;
|
double scalar2 = t9 / t1;
|
||||||
REQUIRE(scalar2 == Catch::Approx(2.0));
|
REQUIRE(scalar2 == Catch::Approx(2.0));
|
||||||
double scalar3 = t1 / t6;
|
double scalar3 = t1 / t6;
|
||||||
REQUIRE(scalar3 == Catch::Approx(1.000000013));
|
REQUIRE(scalar3 == Catch::Approx(1.000000013));
|
||||||
double scalar4 = t3 / t1;
|
double scalar4 = t3 / t1;
|
||||||
REQUIRE(scalar4 == Catch::Approx(0));
|
REQUIRE(scalar4 == Catch::Approx(0));
|
||||||
double scalar5 = t12 / t1;
|
double scalar5 = t12 / t1;
|
||||||
REQUIRE(scalar5 == Catch::Approx(0.5));
|
REQUIRE(scalar5 == Catch::Approx(0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("timevalOperations::toTimeval"){
|
|
||||||
double seconds = 1648227422.123456;
|
|
||||||
timeval t1 = timevalOperations::toTimeval(seconds);
|
|
||||||
REQUIRE(t1.tv_sec == 1648227422);
|
|
||||||
// Allow 1 usec rounding tolerance
|
|
||||||
REQUIRE(t1.tv_usec >= 123455);
|
|
||||||
REQUIRE(t1.tv_usec <= 123457);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
SECTION("timevalOperations::toTimeval") {
|
||||||
|
double seconds = 1648227422.123456;
|
||||||
|
timeval t1 = timevalOperations::toTimeval(seconds);
|
||||||
|
REQUIRE(t1.tv_sec == 1648227422);
|
||||||
|
// Allow 1 usec rounding tolerance
|
||||||
|
REQUIRE(t1.tv_usec >= 123455);
|
||||||
|
REQUIRE(t1.tv_usec <= 123457);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,92 +1,92 @@
|
|||||||
#include <fsfw/timemanager/Clock.h>
|
|
||||||
#include <fsfw/globalfunctions/timevalOperations.h>
|
#include <fsfw/globalfunctions/timevalOperations.h>
|
||||||
|
#include <fsfw/timemanager/Clock.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <catch2/catch_approx.hpp>
|
#include <catch2/catch_approx.hpp>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "fsfw_tests/unit/CatchDefinitions.h"
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]"){
|
TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") {
|
||||||
SECTION("Test getClock"){
|
SECTION("Test getClock") {
|
||||||
timeval time;
|
timeval time;
|
||||||
ReturnValue_t result = Clock::getClock_timeval(&time);
|
ReturnValue_t result = Clock::getClock_timeval(&time);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
Clock::TimeOfDay_t timeOfDay;
|
Clock::TimeOfDay_t timeOfDay;
|
||||||
result = Clock::getDateAndTime(&timeOfDay);
|
result = Clock::getDateAndTime(&timeOfDay);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
timeval timeOfDayAsTimeval;
|
timeval timeOfDayAsTimeval;
|
||||||
result = Clock::convertTimeOfDayToTimeval(&timeOfDay, &timeOfDayAsTimeval);
|
result = Clock::convertTimeOfDayToTimeval(&timeOfDay, &timeOfDayAsTimeval);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
// We require timeOfDayAsTimeval to be larger than time as it
|
// We require timeOfDayAsTimeval to be larger than time as it
|
||||||
// was request a few ns later
|
// was request a few ns later
|
||||||
double difference = timevalOperations::toDouble(timeOfDayAsTimeval-time);
|
double difference = timevalOperations::toDouble(timeOfDayAsTimeval - time);
|
||||||
CHECK(difference>=0.0);
|
CHECK(difference >= 0.0);
|
||||||
CHECK(difference<=0.005);
|
CHECK(difference <= 0.005);
|
||||||
|
|
||||||
// Conversion in the other direction
|
// Conversion in the other direction
|
||||||
Clock::TimeOfDay_t timevalAsTimeOfDay;
|
Clock::TimeOfDay_t timevalAsTimeOfDay;
|
||||||
result = Clock::convertTimevalToTimeOfDay(&time, &timevalAsTimeOfDay);
|
result = Clock::convertTimevalToTimeOfDay(&time, &timevalAsTimeOfDay);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
CHECK(timevalAsTimeOfDay.year <= timeOfDay.year);
|
CHECK(timevalAsTimeOfDay.year <= timeOfDay.year);
|
||||||
// TODO We should write TimeOfDay operators!
|
// TODO We should write TimeOfDay operators!
|
||||||
}
|
}
|
||||||
SECTION("Leap seconds"){
|
SECTION("Leap seconds") {
|
||||||
uint16_t leapSeconds = 0;
|
uint16_t leapSeconds = 0;
|
||||||
ReturnValue_t result = Clock::getLeapSeconds(&leapSeconds);
|
ReturnValue_t result = Clock::getLeapSeconds(&leapSeconds);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED);
|
||||||
REQUIRE(leapSeconds == 0);
|
REQUIRE(leapSeconds == 0);
|
||||||
result = Clock::setLeapSeconds(18);
|
result = Clock::setLeapSeconds(18);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
result = Clock::getLeapSeconds(&leapSeconds);
|
result = Clock::getLeapSeconds(&leapSeconds);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
REQUIRE(leapSeconds == 18);
|
REQUIRE(leapSeconds == 18);
|
||||||
}
|
}
|
||||||
SECTION("usec Test"){
|
SECTION("usec Test") {
|
||||||
timeval timeAsTimeval;
|
timeval timeAsTimeval;
|
||||||
ReturnValue_t result = Clock::getClock_timeval(&timeAsTimeval);
|
ReturnValue_t result = Clock::getClock_timeval(&timeAsTimeval);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
uint64_t timeAsUsec = 0;
|
uint64_t timeAsUsec = 0;
|
||||||
result = Clock::getClock_usecs(&timeAsUsec);
|
result = Clock::getClock_usecs(&timeAsUsec);
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
double timeAsUsecDouble = static_cast<double>(timeAsUsec)/1000000.0;
|
double timeAsUsecDouble = static_cast<double>(timeAsUsec) / 1000000.0;
|
||||||
timeval timeAsUsecTimeval = timevalOperations::toTimeval(timeAsUsecDouble);
|
timeval timeAsUsecTimeval = timevalOperations::toTimeval(timeAsUsecDouble);
|
||||||
double difference = timevalOperations::toDouble(timeAsTimeval - timeAsUsecTimeval);
|
double difference = timevalOperations::toDouble(timeAsTimeval - timeAsUsecTimeval);
|
||||||
// We accept 5 ms difference
|
// We accept 5 ms difference
|
||||||
CHECK(abs(difference) <= 0.005);
|
CHECK(abs(difference) <= 0.005);
|
||||||
uint64_t timevalAsUint64 = static_cast<uint64_t>(timeAsTimeval.tv_sec)*1000000ull + static_cast<uint64_t>(timeAsTimeval.tv_usec);
|
uint64_t timevalAsUint64 = static_cast<uint64_t>(timeAsTimeval.tv_sec) * 1000000ull +
|
||||||
if(timeAsUsec > timevalAsUint64){
|
static_cast<uint64_t>(timeAsTimeval.tv_usec);
|
||||||
// This should not be the case but we can see some rounding issue sometimes
|
if (timeAsUsec > timevalAsUint64) {
|
||||||
// This is the case if used in valgrind. This might indicate an other issue
|
// This should not be the case but we can see some rounding issue sometimes
|
||||||
CHECK((timeAsUsec - timevalAsUint64)>=0);
|
// This is the case if used in valgrind. This might indicate an other issue
|
||||||
CHECK((timeAsUsec - timevalAsUint64)<=(5*1000));
|
CHECK((timeAsUsec - timevalAsUint64) >= 0);
|
||||||
}else{
|
CHECK((timeAsUsec - timevalAsUint64) <= (5 * 1000));
|
||||||
CHECK((timevalAsUint64 - timeAsUsec)>=0);
|
} else {
|
||||||
CHECK((timevalAsUint64 - timeAsUsec)<=(5*1000));
|
CHECK((timevalAsUint64 - timeAsUsec) >= 0);
|
||||||
}
|
CHECK((timevalAsUint64 - timeAsUsec) <= (5 * 1000));
|
||||||
|
|
||||||
}
|
|
||||||
SECTION("Test j2000"){
|
|
||||||
double j2000;
|
|
||||||
timeval time;
|
|
||||||
time.tv_sec = 1648208539;
|
|
||||||
time.tv_usec = 0;
|
|
||||||
ReturnValue_t result = Clock::convertTimevalToJD2000(time, &j2000);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
double correctJ2000 = 2459663.98772 - 2451545.0;
|
|
||||||
CHECK(j2000 == Catch::Approx(correctJ2000).margin(1.2*1e-8));
|
|
||||||
}
|
|
||||||
SECTION("Convert to TT"){
|
|
||||||
timeval utcTime;
|
|
||||||
utcTime.tv_sec = 1648208539;
|
|
||||||
utcTime.tv_usec = 999000;
|
|
||||||
timeval tt;
|
|
||||||
ReturnValue_t result = Clock::setLeapSeconds(27);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
result = Clock::convertUTCToTT(utcTime, &tt);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
CHECK(tt.tv_usec == 183000);
|
|
||||||
// The plus 1 is a own forced overflow of usecs
|
|
||||||
CHECK(tt.tv_sec == (1648208539 + 27 + 10 + 32 + 1));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
SECTION("Test j2000") {
|
||||||
|
double j2000;
|
||||||
|
timeval time;
|
||||||
|
time.tv_sec = 1648208539;
|
||||||
|
time.tv_usec = 0;
|
||||||
|
ReturnValue_t result = Clock::convertTimevalToJD2000(time, &j2000);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
double correctJ2000 = 2459663.98772 - 2451545.0;
|
||||||
|
CHECK(j2000 == Catch::Approx(correctJ2000).margin(1.2 * 1e-8));
|
||||||
|
}
|
||||||
|
SECTION("Convert to TT") {
|
||||||
|
timeval utcTime;
|
||||||
|
utcTime.tv_sec = 1648208539;
|
||||||
|
utcTime.tv_usec = 999000;
|
||||||
|
timeval tt;
|
||||||
|
ReturnValue_t result = Clock::setLeapSeconds(27);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
result = Clock::convertUTCToTT(utcTime, &tt);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
CHECK(tt.tv_usec == 183000);
|
||||||
|
// The plus 1 is a own forced overflow of usecs
|
||||||
|
CHECK(tt.tv_sec == (1648208539 + 27 + 10 + 32 + 1));
|
||||||
|
}
|
||||||
}
|
}
|
@ -120,8 +120,6 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") {
|
|||||||
CHECK(cdsTime.msDay_l == 0xC5);
|
CHECK(cdsTime.msDay_l == 0xC5);
|
||||||
CHECK(cdsTime.msDay_ll == 0xC3);
|
CHECK(cdsTime.msDay_ll == 0xC3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Conversion back to timeval
|
// Conversion back to timeval
|
||||||
timeval timeReturnAsTimeval;
|
timeval timeReturnAsTimeval;
|
||||||
result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime);
|
result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime);
|
||||||
|
@ -17,15 +17,15 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
|||||||
fsfw::Version v1 = fsfw::Version(1, 1, 1);
|
fsfw::Version v1 = fsfw::Version(1, 1, 1);
|
||||||
fsfw::Version v2 = fsfw::Version(1, 1, 1);
|
fsfw::Version v2 = fsfw::Version(1, 1, 1);
|
||||||
REQUIRE(v1 == v2);
|
REQUIRE(v1 == v2);
|
||||||
REQUIRE(not (v1 < v2));
|
REQUIRE(not(v1 < v2));
|
||||||
REQUIRE(not (v1 > v2));
|
REQUIRE(not(v1 > v2));
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
v1.revision -= 1;
|
v1.revision -= 1;
|
||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 > v2));
|
REQUIRE(not(v1 > v2));
|
||||||
REQUIRE(not (v1 >= v2));
|
REQUIRE(not(v1 >= v2));
|
||||||
REQUIRE(v1 < v2);
|
REQUIRE(v1 < v2);
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
v1.revision += 1;
|
v1.revision += 1;
|
||||||
@ -33,60 +33,60 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
|||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(v1 < v2);
|
REQUIRE(v1 < v2);
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 > v2));
|
REQUIRE(not(v1 > v2));
|
||||||
REQUIRE(not (v1 >= v2));
|
REQUIRE(not(v1 >= v2));
|
||||||
v1.minor += 1;
|
v1.minor += 1;
|
||||||
v1.major -= 1;
|
v1.major -= 1;
|
||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(v1 < v2);
|
REQUIRE(v1 < v2);
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 > v2));
|
REQUIRE(not(v1 > v2));
|
||||||
REQUIRE(not (v1 >= v2));
|
REQUIRE(not(v1 >= v2));
|
||||||
v1.major += 1;
|
v1.major += 1;
|
||||||
REQUIRE(v1 == v2);
|
REQUIRE(v1 == v2);
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
REQUIRE(not (v1 != v2));
|
REQUIRE(not(v1 != v2));
|
||||||
REQUIRE(not (v1 > v2));
|
REQUIRE(not(v1 > v2));
|
||||||
REQUIRE(not (v1 < v2));
|
REQUIRE(not(v1 < v2));
|
||||||
v1.major += 1;
|
v1.major += 1;
|
||||||
v1.minor -= 1;
|
v1.minor -= 1;
|
||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(v1 > v2);
|
REQUIRE(v1 > v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 < v2));
|
REQUIRE(not(v1 < v2));
|
||||||
REQUIRE(not (v1 <= v2));
|
REQUIRE(not(v1 <= v2));
|
||||||
v1.major -= 1;
|
v1.major -= 1;
|
||||||
v1.minor += 2;
|
v1.minor += 2;
|
||||||
v1.revision -= 1;
|
v1.revision -= 1;
|
||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(v1 > v2);
|
REQUIRE(v1 > v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 < v2));
|
REQUIRE(not(v1 < v2));
|
||||||
REQUIRE(not (v1 <= v2));
|
REQUIRE(not(v1 <= v2));
|
||||||
v1.minor -= 1;
|
v1.minor -= 1;
|
||||||
v1.revision += 2;
|
v1.revision += 2;
|
||||||
REQUIRE(v1 != v2);
|
REQUIRE(v1 != v2);
|
||||||
REQUIRE(v1 > v2);
|
REQUIRE(v1 > v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
REQUIRE(not (v1 == v2));
|
REQUIRE(not(v1 == v2));
|
||||||
REQUIRE(not (v1 < v2));
|
REQUIRE(not(v1 < v2));
|
||||||
REQUIRE(not (v1 <= v2));
|
REQUIRE(not(v1 <= v2));
|
||||||
v1.revision -= 1;
|
v1.revision -= 1;
|
||||||
REQUIRE(v1 == v2);
|
REQUIRE(v1 == v2);
|
||||||
REQUIRE(v1 <= v2);
|
REQUIRE(v1 <= v2);
|
||||||
REQUIRE(v1 >= v2);
|
REQUIRE(v1 >= v2);
|
||||||
REQUIRE(not (v1 != v2));
|
REQUIRE(not(v1 != v2));
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "v" << fsfw::FSFW_VERSION << std::endl;
|
sif::info << "v" << fsfw::FSFW_VERSION << std::endl;
|
||||||
#endif
|
#endif
|
||||||
char verString[10] = {};
|
char verString[10] = {};
|
||||||
fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString));
|
fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString));
|
||||||
#if FSFW_DISABLE_PRINTOUT == 0
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
printf("v%s\n",verString);
|
printf("v%s\n", verString);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user