basic storage manager mock

This commit is contained in:
Robin Müller 2022-08-09 12:45:05 +02:00
parent bddf5bded1
commit 22e1555f50
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 65 additions and 12 deletions

View File

@ -2,31 +2,76 @@
ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data,
size_t size, bool ignoreFault) {
return 0;
if (nextAddDataCallFails.first) {
return nextAddDataCallFails.second;
}
return LocalPool::addData(storageId, data, size, ignoreFault);
}
ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) {
if(nextDeleteDataCallFails.first) {
return nextDeleteDataCallFails.second;
}
return LocalPool::deleteData(packet_id);
}
ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { return 0; }
ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size,
store_address_t *storeId) {
return 0;
if(nextDeleteDataCallFails.first) {
return nextDeleteDataCallFails.second;
}
return LocalPool::deleteData(buffer, size, storeId);
}
ReturnValue_t StorageManagerMock::getData(store_address_t packet_id, const uint8_t **packet_ptr,
size_t *size) {
return 0;
if (nextGetDataCallFails.first) {
return nextGetDataCallFails.second;
}
return LocalPool::getData(packet_id, packet_ptr, size);
}
ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t **packet_ptr,
size_t *size) {
return 0;
if (nextModifyDataCallFails.first) {
return nextModifyDataCallFails.second;
}
return LocalPool::modifyData(packet_id, packet_ptr, size);
}
ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size,
uint8_t **p_data, bool ignoreFault) {
return 0;
}
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { return false; }
void StorageManagerMock::clearStore() {}
void StorageManagerMock::clearSubPool(uint8_t poolIndex) {}
void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) {}
size_t StorageManagerMock::getTotalSize(size_t *additionalSize) { return 0; }
StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const { return 0; }
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const {
return LocalPool::hasDataAtId(storeId);
}
void StorageManagerMock::clearStore() {
return LocalPool::clearStore();
}
void StorageManagerMock::clearSubPool(uint8_t poolIndex) {
return LocalPool::clearSubPool(poolIndex);
}
void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) {
return LocalPool::getFillCount(buffer, bytesWritten);
}
size_t StorageManagerMock::getTotalSize(size_t *additionalSize) {
return LocalPool::getTotalSize(additionalSize);
}
StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const {
return LocalPool::getNumberOfSubPools();
}
void StorageManagerMock::reset() {
clearStore();
nextAddDataCallFails.first = false;
nextAddDataCallFails.second = result::OK;
nextModifyDataCallFails.first = false;
nextModifyDataCallFails.second = result::OK;
nextGetDataCallFails.first = false;
nextGetDataCallFails.second = result::OK;
nextDeleteDataCallFails.first = false;
nextDeleteDataCallFails.second = result::OK;
}

View File

@ -1,9 +1,10 @@
#ifndef FSFW_TESTS_STORAGEMANAGERMOCK_H
#define FSFW_TESTS_STORAGEMANAGERMOCK_H
#include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
class StorageManagerMock: public StorageManagerIF {
class StorageManagerMock: public LocalPool {
public:
ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size,
bool ignoreFault) override;
@ -20,5 +21,12 @@ class StorageManagerMock: public StorageManagerIF {
void getFillCount(uint8_t *buffer, uint8_t *bytesWritten) override;
size_t getTotalSize(size_t *additionalSize) override;
[[nodiscard]] max_subpools_t getNumberOfSubPools() const override;
std::pair<bool, ReturnValue_t> nextAddDataCallFails;
std::pair<bool, ReturnValue_t> nextModifyDataCallFails;
std::pair<bool, ReturnValue_t> nextGetDataCallFails;
std::pair<bool, ReturnValue_t> nextDeleteDataCallFails;
void reset();
};
#endif // FSFW_TESTS_STORAGEMANAGERMOCK_H