use new storage manager mock
This commit is contained in:
parent
22e1555f50
commit
192956c2c7
@ -5,10 +5,11 @@
|
|||||||
#include "fsfw/storagemanager/LocalPool.h"
|
#include "fsfw/storagemanager/LocalPool.h"
|
||||||
#include "mocks/AcceptsTcMock.h"
|
#include "mocks/AcceptsTcMock.h"
|
||||||
#include "mocks/MessageQueueMock.h"
|
#include "mocks/MessageQueueMock.h"
|
||||||
|
#include "mocks/StorageManagerMock.h"
|
||||||
|
|
||||||
TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
||||||
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
|
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
|
||||||
LocalPool pool(objects::NO_OBJECT, cfg);
|
StorageManagerMock pool(objects::NO_OBJECT, cfg);
|
||||||
auto queue = MessageQueueMock(1);
|
auto queue = MessageQueueMock(1);
|
||||||
CfdpDistribCfg distribCfg(1, pool, &queue);
|
CfdpDistribCfg distribCfg(1, pool, &queue);
|
||||||
auto distributor = CfdpDistributor(distribCfg);
|
auto distributor = CfdpDistributor(distribCfg);
|
||||||
@ -42,7 +43,7 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
|||||||
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
|
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
|
||||||
size_t serLen = 0;
|
size_t serLen = 0;
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
CHECK(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK);
|
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK);
|
||||||
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
|
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
|
||||||
result::OK);
|
result::OK);
|
||||||
TmTcMessage msg(storeId);
|
TmTcMessage msg(storeId);
|
||||||
|
@ -37,10 +37,15 @@ ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t
|
|||||||
}
|
}
|
||||||
return LocalPool::modifyData(packet_id, packet_ptr, size);
|
return LocalPool::modifyData(packet_id, packet_ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size,
|
ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size,
|
||||||
uint8_t **p_data, bool ignoreFault) {
|
uint8_t **p_data, bool ignoreFault) {
|
||||||
return 0;
|
if (nextFreeElementCallFails.first) {
|
||||||
|
return nextFreeElementCallFails.second;
|
||||||
|
}
|
||||||
|
return LocalPool::getFreeElement(storageId, size, p_data, ignoreFault);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const {
|
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const {
|
||||||
return LocalPool::hasDataAtId(storeId);
|
return LocalPool::hasDataAtId(storeId);
|
||||||
}
|
}
|
||||||
@ -74,4 +79,11 @@ void StorageManagerMock::reset() {
|
|||||||
nextGetDataCallFails.second = result::OK;
|
nextGetDataCallFails.second = result::OK;
|
||||||
nextDeleteDataCallFails.first = false;
|
nextDeleteDataCallFails.first = false;
|
||||||
nextDeleteDataCallFails.second = result::OK;
|
nextDeleteDataCallFails.second = result::OK;
|
||||||
|
nextFreeElementCallFails.first = false;
|
||||||
|
nextFreeElementCallFails.second = result::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
StorageManagerMock::StorageManagerMock(object_id_t setObjectId,
|
||||||
|
const LocalPool::LocalPoolConfig &poolConfig)
|
||||||
|
: LocalPool(setObjectId, poolConfig) {
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
class StorageManagerMock: public LocalPool {
|
class StorageManagerMock: public LocalPool {
|
||||||
public:
|
public:
|
||||||
|
StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig& poolConfig);
|
||||||
|
|
||||||
ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size,
|
ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size,
|
||||||
bool ignoreFault) override;
|
bool ignoreFault) override;
|
||||||
ReturnValue_t deleteData(store_address_t packet_id) override;
|
ReturnValue_t deleteData(store_address_t packet_id) override;
|
||||||
@ -26,7 +28,7 @@ class StorageManagerMock: public LocalPool {
|
|||||||
std::pair<bool, ReturnValue_t> nextModifyDataCallFails;
|
std::pair<bool, ReturnValue_t> nextModifyDataCallFails;
|
||||||
std::pair<bool, ReturnValue_t> nextGetDataCallFails;
|
std::pair<bool, ReturnValue_t> nextGetDataCallFails;
|
||||||
std::pair<bool, ReturnValue_t> nextDeleteDataCallFails;
|
std::pair<bool, ReturnValue_t> nextDeleteDataCallFails;
|
||||||
|
std::pair<bool, ReturnValue_t> nextFreeElementCallFails;
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
#endif // FSFW_TESTS_STORAGEMANAGERMOCK_H
|
#endif // FSFW_TESTS_STORAGEMANAGERMOCK_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user