Merge remote-tracking branch 'upstream/development' into develop_update
This commit is contained in:
@ -56,61 +56,65 @@ TEST_CASE("TimevalTest", "[timevalOperations]") {
|
||||
}
|
||||
SECTION("Operators") {
|
||||
timeval t1;
|
||||
t1.tv_sec = 1648227422;
|
||||
t1.tv_usec = 123456;
|
||||
timeval t2;
|
||||
t2.tv_sec = 1648227422;
|
||||
t2.tv_usec = 123456;
|
||||
timeval t3 = t1 - t2;
|
||||
REQUIRE(t3.tv_sec == 0);
|
||||
REQUIRE(t3.tv_usec == 0);
|
||||
timeval t4 = t1 - t3;
|
||||
REQUIRE(t4.tv_sec == 1648227422);
|
||||
REQUIRE(t4.tv_usec == 123456);
|
||||
timeval t5 = t3 - t1;
|
||||
REQUIRE(t5.tv_sec == -1648227422);
|
||||
REQUIRE(t5.tv_usec == -123456);
|
||||
if (sizeof(t1.tv_sec) == 8) {
|
||||
t1.tv_sec = 1648227422;
|
||||
t1.tv_usec = 123456;
|
||||
timeval t2;
|
||||
t2.tv_sec = 1648227422;
|
||||
t2.tv_usec = 123456;
|
||||
timeval t3 = t1 - t2;
|
||||
REQUIRE(t3.tv_sec == 0);
|
||||
REQUIRE(t3.tv_usec == 0);
|
||||
timeval t4 = t1 - t3;
|
||||
REQUIRE(t4.tv_sec == 1648227422);
|
||||
REQUIRE(t4.tv_usec == 123456);
|
||||
timeval t5 = t3 - t1;
|
||||
REQUIRE(t5.tv_sec == -1648227422);
|
||||
REQUIRE(t5.tv_usec == -123456);
|
||||
|
||||
timeval t6;
|
||||
t6.tv_sec = 1648227400;
|
||||
t6.tv_usec = 999999;
|
||||
timeval t6;
|
||||
t6.tv_sec = 1648227400;
|
||||
t6.tv_usec = 999999;
|
||||
|
||||
timeval t7 = t6 + t1;
|
||||
REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull));
|
||||
REQUIRE(t7.tv_usec == 123455);
|
||||
timeval t7 = t6 + t1;
|
||||
// Overflow test
|
||||
REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull));
|
||||
|
||||
timeval t8 = t1 - t6;
|
||||
REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1);
|
||||
REQUIRE(t8.tv_usec == 123457);
|
||||
REQUIRE(t7.tv_usec == 123455);
|
||||
|
||||
double scalar = 2;
|
||||
timeval t9 = t1 * scalar;
|
||||
REQUIRE(t9.tv_sec == 3296454844);
|
||||
REQUIRE(t9.tv_usec == 246912);
|
||||
timeval t10 = scalar * t1;
|
||||
REQUIRE(t10.tv_sec == 3296454844);
|
||||
REQUIRE(t10.tv_usec == 246912);
|
||||
timeval t11 = t6 * scalar;
|
||||
REQUIRE(t11.tv_sec == (3296454800 + 1));
|
||||
REQUIRE(t11.tv_usec == 999998);
|
||||
timeval t8 = t1 - t6;
|
||||
REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1);
|
||||
REQUIRE(t8.tv_usec == 123457);
|
||||
|
||||
timeval t12 = t1 / scalar;
|
||||
REQUIRE(t12.tv_sec == 824113711);
|
||||
REQUIRE(t12.tv_usec == 61728);
|
||||
double scalar = 2;
|
||||
timeval t9 = t1 * scalar;
|
||||
REQUIRE(t9.tv_sec == 3296454844);
|
||||
REQUIRE(t9.tv_usec == 246912);
|
||||
timeval t10 = scalar * t1;
|
||||
REQUIRE(t10.tv_sec == 3296454844);
|
||||
REQUIRE(t10.tv_usec == 246912);
|
||||
timeval t11 = t6 * scalar;
|
||||
REQUIRE(t11.tv_sec == (3296454800 + 1));
|
||||
REQUIRE(t11.tv_usec == 999998);
|
||||
|
||||
timeval t13 = t6 / scalar;
|
||||
REQUIRE(t13.tv_sec == 824113700);
|
||||
// Rounding issue
|
||||
REQUIRE(t13.tv_usec == 499999);
|
||||
timeval t12 = t1 / scalar;
|
||||
REQUIRE(t12.tv_sec == 824113711);
|
||||
REQUIRE(t12.tv_usec == 61728);
|
||||
|
||||
double scalar2 = t9 / t1;
|
||||
REQUIRE(scalar2 == Catch::Approx(2.0));
|
||||
double scalar3 = t1 / t6;
|
||||
REQUIRE(scalar3 == Catch::Approx(1.000000013));
|
||||
double scalar4 = t3 / t1;
|
||||
REQUIRE(scalar4 == Catch::Approx(0));
|
||||
double scalar5 = t12 / t1;
|
||||
REQUIRE(scalar5 == Catch::Approx(0.5));
|
||||
timeval t13 = t6 / scalar;
|
||||
REQUIRE(t13.tv_sec == 824113700);
|
||||
// Rounding issue
|
||||
REQUIRE(t13.tv_usec == 499999);
|
||||
|
||||
double scalar2 = t9 / t1;
|
||||
REQUIRE(scalar2 == Catch::Approx(2.0));
|
||||
double scalar3 = t1 / t6;
|
||||
REQUIRE(scalar3 == Catch::Approx(1.000000013));
|
||||
double scalar4 = t3 / t1;
|
||||
REQUIRE(scalar4 == Catch::Approx(0));
|
||||
double scalar5 = t12 / t1;
|
||||
REQUIRE(scalar5 == Catch::Approx(0.5));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("timevalOperations::toTimeval") {
|
||||
|
@ -1,2 +1,7 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp
|
||||
testHostFilesystem.cpp testFsMock.cpp)
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE testHostFilesystem.cpp testFsMock.cpp)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
testCommandExecutor.cpp
|
||||
)
|
||||
endif()
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "StorageManagerMock.h"
|
||||
|
||||
ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data,
|
||||
size_t size, bool ignoreFault) {
|
||||
size_t size) {
|
||||
if (nextAddDataCallFails.first) {
|
||||
return nextAddDataCallFails.second;
|
||||
}
|
||||
return LocalPool::addData(storageId, data, size, ignoreFault);
|
||||
return LocalPool::addData(storageId, data, size);
|
||||
}
|
||||
ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) {
|
||||
if (nextDeleteDataCallFails.first) {
|
||||
@ -36,11 +36,11 @@ ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t
|
||||
}
|
||||
|
||||
ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size,
|
||||
uint8_t **p_data, bool ignoreFault) {
|
||||
uint8_t **p_data) {
|
||||
if (nextFreeElementCallFails.first) {
|
||||
return nextFreeElementCallFails.second;
|
||||
}
|
||||
return LocalPool::getFreeElement(storageId, size, p_data, ignoreFault);
|
||||
return LocalPool::getFreeElement(storageId, size, p_data);
|
||||
}
|
||||
|
||||
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const {
|
||||
|
@ -8,15 +8,13 @@ class StorageManagerMock : public LocalPool {
|
||||
public:
|
||||
StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig &poolConfig);
|
||||
|
||||
ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size,
|
||||
bool ignoreFault) override;
|
||||
ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size) override;
|
||||
ReturnValue_t deleteData(store_address_t packet_id) override;
|
||||
ReturnValue_t deleteData(uint8_t *buffer, size_t size, store_address_t *storeId) override;
|
||||
ReturnValue_t getData(store_address_t packet_id, const uint8_t **packet_ptr,
|
||||
size_t *size) override;
|
||||
ReturnValue_t modifyData(store_address_t packet_id, uint8_t **packet_ptr, size_t *size) override;
|
||||
ReturnValue_t getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data,
|
||||
bool ignoreFault) override;
|
||||
ReturnValue_t getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data) override;
|
||||
[[nodiscard]] bool hasDataAtId(store_address_t storeId) const override;
|
||||
void clearStore() override;
|
||||
void clearSubPool(uint8_t poolIndex) override;
|
||||
|
Reference in New Issue
Block a user