fsfw/unittests/mocks/StorageManagerMock.h

40 lines
1.8 KiB
C
Raw Normal View History

#ifndef FSFW_TESTS_STORAGEMANAGERMOCK_H
#define FSFW_TESTS_STORAGEMANAGERMOCK_H
2022-08-09 12:45:05 +02:00
#include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
2022-08-09 13:04:23 +02:00
class StorageManagerMock : public LocalPool {
public:
2022-08-09 13:04:23 +02:00
StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig &poolConfig);
2022-08-09 12:50:50 +02:00
2022-11-14 14:57:37 +01:00
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;
2022-11-14 14:57:37 +01:00
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;
void getFillCount(uint8_t *buffer, uint8_t *bytesWritten) override;
size_t getTotalSize(size_t *additionalSize) override;
[[nodiscard]] max_subpools_t getNumberOfSubPools() const override;
2022-08-09 12:45:05 +02:00
std::pair<bool, ReturnValue_t> nextAddDataCallFails;
2022-08-09 13:04:23 +02:00
/**
* This can be used to make both the modify and get API call fail. This is because generally,
* the pool implementation get functions will use the modify API internally.
*/
2022-08-09 12:45:05 +02:00
std::pair<bool, ReturnValue_t> nextModifyDataCallFails;
std::pair<bool, ReturnValue_t> nextDeleteDataCallFails;
2022-08-09 12:50:50 +02:00
std::pair<bool, ReturnValue_t> nextFreeElementCallFails;
2022-09-05 14:20:01 +02:00
using LocalPool::getFreeElement;
2023-08-03 13:03:58 +02:00
using StorageManagerIF::getData;
2022-09-05 14:20:01 +02:00
2022-08-09 12:45:05 +02:00
void reset();
};
#endif // FSFW_TESTS_STORAGEMANAGERMOCK_H