some fixes for master
This commit is contained in:
parent
c8fd698b3a
commit
97f6dace26
@ -1,5 +1,5 @@
|
|||||||
|
#include "CatchDefinitions.h"
|
||||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||||
#include <fsfw/unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
StorageManagerIF* tglob::getIpcStoreHandle() {
|
StorageManagerIF* tglob::getIpcStoreHandle() {
|
||||||
if(objectManager != nullptr) {
|
if(objectManager != nullptr) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_
|
||||||
|
#define FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_
|
||||||
|
|
||||||
#include <fsfw/ipc/messageQueueDefinitions.h>
|
#include <fsfw/ipc/messageQueueDefinitions.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
@ -17,3 +18,4 @@ namespace tglob {
|
|||||||
StorageManagerIF* getIpcStoreHandle();
|
StorageManagerIF* getIpcStoreHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
|
||||||
#include "../config/cdatapool/dataPoolInit.h"
|
#include <testcfg/cdatapool/dataPoolInit.h>
|
||||||
#include "../config/objects/Factory.h"
|
#include <testcfg/objects/Factory.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef GCOV
|
#ifdef GCOV
|
||||||
@ -11,15 +11,15 @@
|
|||||||
#include "../../objectmanager/ObjectManager.h"
|
#include "../../objectmanager/ObjectManager.h"
|
||||||
#include "../../objectmanager/ObjectManagerIF.h"
|
#include "../../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../../storagemanager/StorageManagerIF.h"
|
#include "../../storagemanager/StorageManagerIF.h"
|
||||||
#include "../../datapoolglob/GlobalDataPool.h"
|
#include "../../datapool/DataPool.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
|
|
||||||
/* Global instantiations normally done in main.cpp */
|
/* Global instantiations normally done in main.cpp */
|
||||||
/* Initialize Data Pool */
|
/* Initialize Data Pool */
|
||||||
namespace glob {
|
//namespace glob {
|
||||||
GlobalDataPool dataPool(datapool::dataPoolInit);
|
DataPool dataPool(datapool::dataPoolInit);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
namespace sif {
|
namespace sif {
|
||||||
|
@ -1,296 +1,296 @@
|
|||||||
#include "CatchDefinitions.h"
|
//#include "CatchDefinitions.h"
|
||||||
|
//
|
||||||
#include <config/objects/Factory.h>
|
//#include <config/objects/Factory.h>
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
//#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/storagemanager/LocalPool.h>
|
//#include <fsfw/storagemanager/LocalPool.h>
|
||||||
|
//
|
||||||
#include <catch.hpp>
|
//#include <catch.hpp>
|
||||||
#include <CatchDefinitions.h>
|
//#include <CatchDefinitions.h>
|
||||||
|
//
|
||||||
#include <cstring>
|
//#include <cstring>
|
||||||
|
//
|
||||||
|
//
|
||||||
TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
|
//TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
|
||||||
// uint16_t numberOfElements[1] = {1};
|
//// uint16_t numberOfElements[1] = {1};
|
||||||
// uint16_t sizeofElements[1] = {10};
|
//// uint16_t sizeofElements[1] = {10};
|
||||||
LocalPool::LocalPoolConfig config = {{1, 10}};
|
// LocalPool::LocalPoolConfig config = {{1, 10}};
|
||||||
LocalPool simplePool(0, config);
|
// LocalPool simplePool(0, config);
|
||||||
std::array<uint8_t, 20> testDataArray;
|
// std::array<uint8_t, 20> testDataArray;
|
||||||
std::array<uint8_t, 20> receptionArray;
|
// std::array<uint8_t, 20> receptionArray;
|
||||||
store_address_t testStoreId;
|
// store_address_t testStoreId;
|
||||||
ReturnValue_t result = retval::CATCH_FAILED;
|
// ReturnValue_t result = retval::CATCH_FAILED;
|
||||||
uint8_t *pointer = nullptr;
|
// uint8_t *pointer = nullptr;
|
||||||
const uint8_t * constPointer = nullptr;
|
// const uint8_t * constPointer = nullptr;
|
||||||
|
//
|
||||||
for(size_t i = 0; i < testDataArray.size(); i++) {
|
// for(size_t i = 0; i < testDataArray.size(); i++) {
|
||||||
testDataArray[i] = i;
|
// testDataArray[i] = i;
|
||||||
}
|
// }
|
||||||
size_t size = 10;
|
// size_t size = 10;
|
||||||
|
//
|
||||||
SECTION ( "Basic tests") {
|
// SECTION ( "Basic tests") {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.getData(testStoreId, &constPointer, &size);
|
// result = simplePool.getData(testStoreId, &constPointer, &size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
memcpy(receptionArray.data(), constPointer, size);
|
// memcpy(receptionArray.data(), constPointer, size);
|
||||||
for(size_t i = 0; i < size; i++) {
|
// for(size_t i = 0; i < size; i++) {
|
||||||
CHECK(receptionArray[i] == i );
|
// CHECK(receptionArray[i] == i );
|
||||||
}
|
// }
|
||||||
memset(receptionArray.data(), 0, size);
|
// memset(receptionArray.data(), 0, size);
|
||||||
result = simplePool.modifyData(testStoreId, &pointer, &size);
|
// result = simplePool.modifyData(testStoreId, &pointer, &size);
|
||||||
memcpy(receptionArray.data(), pointer, size);
|
// memcpy(receptionArray.data(), pointer, size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
for(size_t i = 0; i < size; i++) {
|
// for(size_t i = 0; i < size; i++) {
|
||||||
CHECK(receptionArray[i] == i );
|
// CHECK(receptionArray[i] == i );
|
||||||
}
|
// }
|
||||||
result = simplePool.deleteData(testStoreId);
|
// result = simplePool.deleteData(testStoreId);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), 15);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), 15);
|
||||||
CHECK (result == (int) StorageManagerIF::DATA_TOO_LARGE);
|
// CHECK (result == (int) StorageManagerIF::DATA_TOO_LARGE);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SECTION ( "Reservation Tests ") {
|
// SECTION ( "Reservation Tests ") {
|
||||||
pointer = nullptr;
|
// pointer = nullptr;
|
||||||
result = simplePool.getFreeElement(&testStoreId, size, &pointer);
|
// result = simplePool.getFreeElement(&testStoreId, size, &pointer);
|
||||||
REQUIRE (result == retval::CATCH_OK);
|
// REQUIRE (result == retval::CATCH_OK);
|
||||||
memcpy(pointer, testDataArray.data(), size);
|
// memcpy(pointer, testDataArray.data(), size);
|
||||||
constPointer = nullptr;
|
// constPointer = nullptr;
|
||||||
result = simplePool.getData(testStoreId, &constPointer, &size);
|
// result = simplePool.getData(testStoreId, &constPointer, &size);
|
||||||
|
//
|
||||||
REQUIRE (result == retval::CATCH_OK);
|
// REQUIRE (result == retval::CATCH_OK);
|
||||||
memcpy(receptionArray.data(), constPointer, size);
|
// memcpy(receptionArray.data(), constPointer, size);
|
||||||
for(size_t i = 0; i < size; i++) {
|
// for(size_t i = 0; i < size; i++) {
|
||||||
CHECK(receptionArray[i] == i );
|
// CHECK(receptionArray[i] == i );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SECTION ( "Add, delete, add, add when full") {
|
// SECTION ( "Add, delete, add, add when full") {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.getData(testStoreId, &constPointer, &size);
|
// result = simplePool.getData(testStoreId, &constPointer, &size);
|
||||||
REQUIRE( result == retval::CATCH_OK);
|
// REQUIRE( result == retval::CATCH_OK);
|
||||||
memcpy(receptionArray.data(), constPointer, size);
|
// memcpy(receptionArray.data(), constPointer, size);
|
||||||
for(size_t i = 0; i < size; i++) {
|
// for(size_t i = 0; i < size; i++) {
|
||||||
CHECK(receptionArray[i] == i );
|
// CHECK(receptionArray[i] == i );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result = simplePool.deleteData(testStoreId);
|
// result = simplePool.deleteData(testStoreId);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
|
//
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.getData(testStoreId, &constPointer, &size);
|
// result = simplePool.getData(testStoreId, &constPointer, &size);
|
||||||
REQUIRE( result == retval::CATCH_OK);
|
// REQUIRE( result == retval::CATCH_OK);
|
||||||
memcpy(receptionArray.data(), constPointer, size);
|
// memcpy(receptionArray.data(), constPointer, size);
|
||||||
for(size_t i = 0; i < size; i++) {
|
// for(size_t i = 0; i < size; i++) {
|
||||||
CHECK(receptionArray[i] == i );
|
// CHECK(receptionArray[i] == i );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
store_address_t newAddress;
|
// store_address_t newAddress;
|
||||||
result = simplePool.addData(&newAddress, testDataArray.data(), size);
|
// result = simplePool.addData(&newAddress, testDataArray.data(), size);
|
||||||
REQUIRE(result == (int) StorageManagerIF::DATA_STORAGE_FULL);
|
// REQUIRE(result == (int) StorageManagerIF::DATA_STORAGE_FULL);
|
||||||
|
//
|
||||||
// Packet Index to high intentionally
|
// // Packet Index to high intentionally
|
||||||
newAddress.packetIndex = 2;
|
// newAddress.packetIndex = 2;
|
||||||
pointer = testDataArray.data();
|
// pointer = testDataArray.data();
|
||||||
result = simplePool.modifyData(newAddress, &pointer, &size);
|
// result = simplePool.modifyData(newAddress, &pointer, &size);
|
||||||
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
// REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
||||||
|
//
|
||||||
result = simplePool.deleteData(newAddress);
|
// result = simplePool.deleteData(newAddress);
|
||||||
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
// REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
||||||
|
//
|
||||||
newAddress.packetIndex = 0;
|
// newAddress.packetIndex = 0;
|
||||||
newAddress.poolIndex = 2;
|
// newAddress.poolIndex = 2;
|
||||||
result = simplePool.deleteData(newAddress);
|
// result = simplePool.deleteData(newAddress);
|
||||||
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
// REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SECTION ( "Initialize and clear store, delete with pointer") {
|
// SECTION ( "Initialize and clear store, delete with pointer") {
|
||||||
result = simplePool.initialize();
|
// result = simplePool.initialize();
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
simplePool.clearStore();
|
// simplePool.clearStore();
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
result = simplePool.modifyData(testStoreId, &pointer, &size);
|
// result = simplePool.modifyData(testStoreId, &pointer, &size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
store_address_t newId;
|
// store_address_t newId;
|
||||||
result = simplePool.deleteData(pointer, size, &testStoreId);
|
// result = simplePool.deleteData(pointer, size, &testStoreId);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
REQUIRE(testStoreId.raw != (uint32_t) StorageManagerIF::INVALID_ADDRESS);
|
// REQUIRE(testStoreId.raw != (uint32_t) StorageManagerIF::INVALID_ADDRESS);
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
int runIdx = 0;
|
//int runIdx = 0;
|
||||||
|
//
|
||||||
TEST_CASE( "Local Pool Extended Tests [3 Pools]" , "[TestPool2]") {
|
//TEST_CASE( "Local Pool Extended Tests [3 Pools]" , "[TestPool2]") {
|
||||||
LocalPool::LocalPoolConfig* config;
|
// LocalPool::LocalPoolConfig* config;
|
||||||
if(runIdx == 0) {
|
// if(runIdx == 0) {
|
||||||
config = new LocalPool::LocalPoolConfig{{10, 5}, {5, 10}, {2, 20}};
|
// config = new LocalPool::LocalPoolConfig{{10, 5}, {5, 10}, {2, 20}};
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
// shufle the order, they should be sort implictely so that the
|
// // shufle the order, they should be sort implictely so that the
|
||||||
// order is ascending for the page sizes.
|
// // order is ascending for the page sizes.
|
||||||
config = new LocalPool::LocalPoolConfig{{5, 10}, {2, 20}, {10, 5}};
|
// config = new LocalPool::LocalPoolConfig{{5, 10}, {2, 20}, {10, 5}};
|
||||||
size_t lastSize = 0;
|
// size_t lastSize = 0;
|
||||||
for(const auto& pair: *config) {
|
// for(const auto& pair: *config) {
|
||||||
CHECK(pair.second > lastSize);
|
// CHECK(pair.second > lastSize);
|
||||||
lastSize = pair.second;
|
// lastSize = pair.second;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
runIdx++;
|
// runIdx++;
|
||||||
|
//
|
||||||
LocalPool simplePool(0, *config);
|
// LocalPool simplePool(0, *config);
|
||||||
std::array<uint8_t, 20> testDataArray;
|
// std::array<uint8_t, 20> testDataArray;
|
||||||
std::array<uint8_t, 20> receptionArray;
|
// std::array<uint8_t, 20> receptionArray;
|
||||||
store_address_t testStoreId;
|
// store_address_t testStoreId;
|
||||||
ReturnValue_t result = retval::CATCH_FAILED;
|
// ReturnValue_t result = retval::CATCH_FAILED;
|
||||||
for(size_t i = 0; i < testDataArray.size(); i++) {
|
// for(size_t i = 0; i < testDataArray.size(); i++) {
|
||||||
testDataArray[i] = i;
|
// testDataArray[i] = i;
|
||||||
}
|
// }
|
||||||
size_t size = 0;
|
// size_t size = 0;
|
||||||
|
//
|
||||||
SECTION ("Basic tests") {
|
// SECTION ("Basic tests") {
|
||||||
size = 8;
|
// size = 8;
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
// Should be on second page of the pool now for 8 bytes
|
// // Should be on second page of the pool now for 8 bytes
|
||||||
CHECK(testStoreId.poolIndex == 1);
|
// CHECK(testStoreId.poolIndex == 1);
|
||||||
CHECK(testStoreId.packetIndex == 0);
|
// CHECK(testStoreId.packetIndex == 0);
|
||||||
|
//
|
||||||
size = 15;
|
// size = 15;
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
// Should be on third page of the pool now for 15 bytes
|
// // Should be on third page of the pool now for 15 bytes
|
||||||
CHECK(testStoreId.poolIndex == 2);
|
// CHECK(testStoreId.poolIndex == 2);
|
||||||
CHECK(testStoreId.packetIndex == 0);
|
// CHECK(testStoreId.packetIndex == 0);
|
||||||
|
//
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
// Should be on third page of the pool now for 15 bytes
|
// // Should be on third page of the pool now for 15 bytes
|
||||||
CHECK(testStoreId.poolIndex == 2);
|
// CHECK(testStoreId.poolIndex == 2);
|
||||||
CHECK(testStoreId.packetIndex == 1);
|
// CHECK(testStoreId.packetIndex == 1);
|
||||||
|
//
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
// Should be on third page of the pool now for 15 bytes
|
// // Should be on third page of the pool now for 15 bytes
|
||||||
REQUIRE(result == (int) LocalPool::DATA_STORAGE_FULL);
|
// REQUIRE(result == (int) LocalPool::DATA_STORAGE_FULL);
|
||||||
|
//
|
||||||
size = 8;
|
// size = 8;
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
// Should still work
|
// // Should still work
|
||||||
CHECK(testStoreId.poolIndex == 1);
|
// CHECK(testStoreId.poolIndex == 1);
|
||||||
CHECK(testStoreId.packetIndex == 1);
|
// CHECK(testStoreId.packetIndex == 1);
|
||||||
|
//
|
||||||
// fill the rest of the pool
|
// // fill the rest of the pool
|
||||||
for(uint8_t idx = 2; idx < 5; idx++) {
|
// for(uint8_t idx = 2; idx < 5; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 1);
|
// CHECK(testStoreId.poolIndex == 1);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SECTION ("Fill Count and Clearing") {
|
// SECTION ("Fill Count and Clearing") {
|
||||||
//SECTION("Basic tests");
|
// //SECTION("Basic tests");
|
||||||
uint8_t bytesWritten = 0;
|
// uint8_t bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
// fill count should be all zeros now.
|
// // fill count should be all zeros now.
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 0);
|
// CHECK(receptionArray[0] == 0);
|
||||||
CHECK(receptionArray[1] == 0);
|
// CHECK(receptionArray[1] == 0);
|
||||||
CHECK(receptionArray[2] == 0);
|
// CHECK(receptionArray[2] == 0);
|
||||||
CHECK(receptionArray[3] == 0);
|
// CHECK(receptionArray[3] == 0);
|
||||||
|
//
|
||||||
// now fill the store completely.
|
// // now fill the store completely.
|
||||||
size = 5;
|
// size = 5;
|
||||||
for(uint8_t idx = 0; idx < 10; idx++) {
|
// for(uint8_t idx = 0; idx < 10; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 0);
|
// CHECK(testStoreId.poolIndex == 0);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
size = 10;
|
// size = 10;
|
||||||
for(uint8_t idx = 0; idx < 5; idx++) {
|
// for(uint8_t idx = 0; idx < 5; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 1);
|
// CHECK(testStoreId.poolIndex == 1);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
size = 20;
|
// size = 20;
|
||||||
for(uint8_t idx = 0; idx < 2; idx++) {
|
// for(uint8_t idx = 0; idx < 2; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 2);
|
// CHECK(testStoreId.poolIndex == 2);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
bytesWritten = 0;
|
// bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
// fill count should be all 100 now.
|
// // fill count should be all 100 now.
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 100);
|
// CHECK(receptionArray[0] == 100);
|
||||||
CHECK(receptionArray[1] == 100);
|
// CHECK(receptionArray[1] == 100);
|
||||||
CHECK(receptionArray[2] == 100);
|
// CHECK(receptionArray[2] == 100);
|
||||||
CHECK(receptionArray[3] == 100);
|
// CHECK(receptionArray[3] == 100);
|
||||||
|
//
|
||||||
// now clear the store
|
// // now clear the store
|
||||||
simplePool.clearStore();
|
// simplePool.clearStore();
|
||||||
bytesWritten = 0;
|
// bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 0);
|
// CHECK(receptionArray[0] == 0);
|
||||||
CHECK(receptionArray[1] == 0);
|
// CHECK(receptionArray[1] == 0);
|
||||||
CHECK(receptionArray[2] == 0);
|
// CHECK(receptionArray[2] == 0);
|
||||||
CHECK(receptionArray[3] == 0);
|
// CHECK(receptionArray[3] == 0);
|
||||||
|
//
|
||||||
// now fill one page
|
// // now fill one page
|
||||||
size = 5;
|
// size = 5;
|
||||||
for(uint8_t idx = 0; idx < 10; idx++) {
|
// for(uint8_t idx = 0; idx < 10; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 0);
|
// CHECK(testStoreId.poolIndex == 0);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
bytesWritten = 0;
|
// bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
// First page full, median fill count is 33 %
|
// // First page full, median fill count is 33 %
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 100);
|
// CHECK(receptionArray[0] == 100);
|
||||||
CHECK(receptionArray[1] == 0);
|
// CHECK(receptionArray[1] == 0);
|
||||||
CHECK(receptionArray[2] == 0);
|
// CHECK(receptionArray[2] == 0);
|
||||||
CHECK(receptionArray[3] == 33);
|
// CHECK(receptionArray[3] == 33);
|
||||||
|
//
|
||||||
// now fill second page
|
// // now fill second page
|
||||||
size = 10;
|
// size = 10;
|
||||||
for(uint8_t idx = 0; idx < 5; idx++) {
|
// for(uint8_t idx = 0; idx < 5; idx++) {
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
// result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
// REQUIRE(result == retval::CATCH_OK);
|
||||||
CHECK(testStoreId.poolIndex == 1);
|
// CHECK(testStoreId.poolIndex == 1);
|
||||||
CHECK(testStoreId.packetIndex == idx);
|
// CHECK(testStoreId.packetIndex == idx);
|
||||||
}
|
// }
|
||||||
bytesWritten = 0;
|
// bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
// First and second page full, median fill count is 66 %
|
// // First and second page full, median fill count is 66 %
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 100);
|
// CHECK(receptionArray[0] == 100);
|
||||||
CHECK(receptionArray[1] == 100);
|
// CHECK(receptionArray[1] == 100);
|
||||||
CHECK(receptionArray[2] == 0);
|
// CHECK(receptionArray[2] == 0);
|
||||||
CHECK(receptionArray[3] == 66);
|
// CHECK(receptionArray[3] == 66);
|
||||||
|
//
|
||||||
// now clear first page
|
// // now clear first page
|
||||||
simplePool.clearPage(0);
|
// simplePool.clearPage(0);
|
||||||
bytesWritten = 0;
|
// bytesWritten = 0;
|
||||||
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
// simplePool.getFillCount(receptionArray.data(), &bytesWritten);
|
||||||
// Second page full, median fill count is 33 %
|
// // Second page full, median fill count is 33 %
|
||||||
CHECK(bytesWritten == 4);
|
// CHECK(bytesWritten == 4);
|
||||||
CHECK(receptionArray[0] == 0);
|
// CHECK(receptionArray[0] == 0);
|
||||||
CHECK(receptionArray[1] == 100);
|
// CHECK(receptionArray[1] == 100);
|
||||||
CHECK(receptionArray[2] == 0);
|
// CHECK(receptionArray[2] == 0);
|
||||||
CHECK(receptionArray[3] == 33);
|
// CHECK(receptionArray[3] == 33);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
delete(config);
|
// delete(config);
|
||||||
}
|
//}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user