added some failure test cases

This commit is contained in:
Robin Müller 2021-02-28 14:54:03 +01:00
parent 16566a5690
commit 304773f7a7
3 changed files with 23 additions and 14 deletions

View File

@ -18,15 +18,13 @@ class PoolVariableIF;
class DataSetIF { class DataSetIF {
public: public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DATA_SET_CLASS; static constexpr uint8_t INTERFACE_ID = CLASS_ID::DATA_SET_CLASS;
static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION = static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION = MAKE_RETURN_CODE(1);
MAKE_RETURN_CODE( 0x01 ); static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE( 0x02 ); static constexpr ReturnValue_t COMMITING_WITHOUT_READING = MAKE_RETURN_CODE(3);
static constexpr ReturnValue_t COMMITING_WITHOUT_READING =
MAKE_RETURN_CODE(0x03);
static constexpr ReturnValue_t DATA_SET_UNINITIALISED = MAKE_RETURN_CODE( 0x04 ); static constexpr ReturnValue_t DATA_SET_UNINITIALISED = MAKE_RETURN_CODE(4);
static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE( 0x05 ); static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE(5);
static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE( 0x06 ); static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE(6);
/** /**
* @brief This is an empty virtual destructor, * @brief This is an empty virtual destructor,

View File

@ -17,22 +17,25 @@ PoolDataSetBase::~PoolDataSetBase() {}
ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF *variable) { ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF *variable) {
if (state != States::STATE_SET_UNINITIALISED) { if (state != States::STATE_SET_UNINITIALISED) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl;
"Call made in wrong position." << std::endl; #else
sif::printError("DataSet::registerVariable: Call made in wrong position.");
#endif #endif
return DataSetIF::DATA_SET_UNINITIALISED; return DataSetIF::DATA_SET_UNINITIALISED;
} }
if (variable == nullptr) { if (variable == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl;
"Pool variable is nullptr." << std::endl; #else
sif::printError("DataSet::registerVariable: Pool variable is nullptr.\n");
#endif #endif
return DataSetIF::POOL_VAR_NULL; return DataSetIF::POOL_VAR_NULL;
} }
if (fillCount >= maxFillCount) { if (fillCount >= maxFillCount) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: DataSet is full." << std::endl;
"DataSet is full." << std::endl; #else
sif::printError("DataSet::registerVariable: DataSet is full.\n");
#endif #endif
return DataSetIF::DATA_SET_FULL; return DataSetIF::DATA_SET_FULL;
} }

View File

@ -53,6 +53,14 @@ TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
CHECK(localSet.localPoolVarUint8.isValid()); CHECK(localSet.localPoolVarUint8.isValid());
} }
/* Common fault test cases */
LocalPoolObjectBase* variableHandle = poolOwner->getPoolObjectHandle(lpool::uint32VarId);
CHECK(variableHandle != nullptr);
CHECK(localSet.registerVariable(variableHandle) ==
static_cast<int>(DataSetIF::DATA_SET_FULL));
variableHandle = nullptr;
REQUIRE(localSet.registerVariable(variableHandle) ==
static_cast<int>(DataSetIF::POOL_VAR_NULL));
} }
/* we need to reset the subscription list because the pool owner /* we need to reset the subscription list because the pool owner