Merge remote-tracking branch 'origin/development' into mueller/new-cfdp-update-with-handlers
This commit is contained in:
@ -43,7 +43,7 @@ TEST_CASE("Array List", "[containers]") {
|
||||
for (auto i = 0; i < 20; i++) {
|
||||
REQUIRE(list.insert(i) == static_cast<int>(returnvalue::OK));
|
||||
}
|
||||
REQUIRE(list.insert(20) == static_cast<int>(ArrayList<uint16_t>::FULL));
|
||||
REQUIRE(list.insert(20) == static_cast<int>(containers::LIST_FULL));
|
||||
ArrayList<uint16_t>::Iterator it = list.begin();
|
||||
REQUIRE((*it) == 0);
|
||||
it++;
|
||||
|
@ -31,7 +31,7 @@ TEST_CASE("FixedArrayList Tests", "[containers]") {
|
||||
for (auto i = 1; i < 260; i++) {
|
||||
REQUIRE(list.insert(i) == static_cast<int>(returnvalue::OK));
|
||||
}
|
||||
REQUIRE(list.insert(260) == static_cast<int>(ArrayList<uint32_t, uint16_t>::FULL));
|
||||
REQUIRE(list.insert(260) == static_cast<int>(containers::LIST_FULL));
|
||||
list.clear();
|
||||
REQUIRE(list.size == 0);
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
template class FixedMap<unsigned int, unsigned short>;
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
INFO("FixedMap Tests");
|
||||
|
||||
@ -24,9 +26,9 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
REQUIRE(map.find(i)->second == i + 1);
|
||||
REQUIRE(not map.empty());
|
||||
}
|
||||
REQUIRE(map.insert(0, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(31, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::MAP_FULL));
|
||||
REQUIRE(map.exists(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.insert(0, 0) == static_cast<int>(containers::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(31, 0) == static_cast<int>(containers::MAP_FULL));
|
||||
REQUIRE(map.exists(31) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 30);
|
||||
REQUIRE(map.full());
|
||||
{
|
||||
@ -34,15 +36,14 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
REQUIRE(map.find(5, &ptr) == static_cast<int>(returnvalue::OK));
|
||||
REQUIRE(*ptr == 6);
|
||||
REQUIRE(*(map.findValue(6)) == 7);
|
||||
REQUIRE(map.find(31, &ptr) ==
|
||||
static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.find(31, &ptr) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
}
|
||||
|
||||
REQUIRE(map.getSerializedSize() ==
|
||||
(sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
REQUIRE(map.erase(2) == static_cast<int>(returnvalue::OK));
|
||||
REQUIRE(map.erase(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.exists(2) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.erase(31) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.exists(2) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 29);
|
||||
|
||||
for (auto element : map) {
|
||||
@ -79,8 +80,7 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
REQUIRE(map.insert(37, 38, nullptr) == static_cast<int>(returnvalue::OK));
|
||||
REQUIRE(map.find(37)->second == 38);
|
||||
REQUIRE(map.size() == 2);
|
||||
REQUIRE(map.insert(37, 24, nullptr) ==
|
||||
static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(37, 24, nullptr) == static_cast<int>(containers::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.find(37)->second != 24);
|
||||
REQUIRE(map.size() == 2);
|
||||
};
|
||||
@ -137,7 +137,7 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
FixedMap<uint32_t, uint16_t>::Iterator it;
|
||||
std::pair<uint32_t, uint16_t> pair = std::make_pair(44, 43);
|
||||
it = FixedMap<uint32_t, uint16_t>::Iterator(&pair);
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.find(45) == map.end());
|
||||
size_t toLargeMap = 100;
|
||||
const uint8_t* ptr = reinterpret_cast<uint8_t*>(&toLargeMap);
|
||||
|
@ -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,5 @@
|
||||
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()
|
||||
|
2
unittests/lcov_epilog.html
Normal file
2
unittests/lcov_epilog.html
Normal file
@ -0,0 +1,2 @@
|
||||
<center><a href='https://www.uni-stuttgart.de/impressum'>Impressum</a> <a href='https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html'>Datenschutz</a></center>
|
||||
</body>
|
@ -6,7 +6,7 @@ AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToR
|
||||
AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn)
|
||||
: SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {}
|
||||
|
||||
MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||
MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) const {
|
||||
return returnedQueue;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF {
|
||||
AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn);
|
||||
explicit AcceptsTmMock(MessageQueueId_t queueToReturn);
|
||||
|
||||
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
|
||||
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override;
|
||||
const char* getName() const override;
|
||||
|
||||
MessageQueueId_t returnedQueue;
|
||||
|
@ -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;
|
||||
|
@ -14,11 +14,17 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") {
|
||||
size_t serLen = 0;
|
||||
|
||||
SECTION("Constexpr Helpers") {
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822);
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, true) == 0x1822);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, true) == 0x0822);
|
||||
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, false) == 0x1022);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, false) == 0x0022);
|
||||
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, true) == 0x1fff);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, true) == 0xfff);
|
||||
|
||||
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, false) == 0x17ff);
|
||||
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, false) == 0x7ff);
|
||||
}
|
||||
|
||||
SECTION("Basic Test") {
|
||||
|
Reference in New Issue
Block a user