mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
* Queues use MemAllocator pattern * Derive queue allocation from MallocRegistry * Formatting * Fix UTs * Fix CI * Fix alignment in UT * Formatting and sp * Formatting, bad header * More formatting * Add queue teardown * Deinit components * Fix priority queue test * Fix bug in priority queue allocation * Correct comments * Fix FppTest and Ref UTs * Fix max heap teardown * Fix review comment on max heap * Fix null -> nullptr
213 lines
7.8 KiB
C++
213 lines
7.8 KiB
C++
// ======================================================================
|
|
// \title ActiveTest/test/ut/ActiveTestActiveTestTester.cpp
|
|
// \author tiffany
|
|
// \brief cpp file for ActiveTest test harness implementation class
|
|
// ======================================================================
|
|
|
|
#include "ActiveTestTester.hpp"
|
|
#include "STest/Pick/Pick.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction and destruction
|
|
// ----------------------------------------------------------------------
|
|
|
|
ActiveTestTester ::ActiveTestTester()
|
|
: ActiveTestGTestBase("ActiveTestTester", ActiveTestTester::MAX_HISTORY_SIZE),
|
|
component("ActiveTest"),
|
|
primitiveBuf(primitiveData, sizeof(primitiveData)),
|
|
stringBuf(stringData, sizeof(stringData)),
|
|
enumBuf(enumData, sizeof(enumData)),
|
|
arrayBuf(arrayData, sizeof(arrayData)),
|
|
structBuf(structData, sizeof(structData)),
|
|
serialBuf(serialData, sizeof(serialData)),
|
|
time(STest::Pick::any(), STest::Pick::lowerUpper(0, 999999)) {
|
|
this->initComponents();
|
|
this->connectPorts();
|
|
this->connectAsyncPorts();
|
|
this->component.registerExternalParameters(&this->paramTesterDelegate);
|
|
}
|
|
|
|
ActiveTestTester ::~ActiveTestTester() {
|
|
this->component.deinit();
|
|
}
|
|
|
|
void ActiveTestTester ::initComponents() {
|
|
this->init();
|
|
this->component.init(ActiveTestTester::TEST_INSTANCE_QUEUE_DEPTH, ActiveTestTester::TEST_INSTANCE_ID);
|
|
}
|
|
|
|
Fw::ParamValid ActiveTestTester ::from_prmGetIn_handler(const FwIndexType portNum,
|
|
FwPrmIdType id,
|
|
Fw::ParamBuffer& val) {
|
|
val.resetSer();
|
|
|
|
Fw::SerializeStatus status;
|
|
U32 id_base = component.getIdBase();
|
|
|
|
FW_ASSERT(id >= id_base);
|
|
|
|
switch (id - id_base) {
|
|
case ActiveTestComponentBase::PARAMID_PARAMBOOL:
|
|
status = val.serializeFrom(boolPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMU32:
|
|
status = val.serializeFrom(u32Prm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRING:
|
|
status = val.serializeFrom(stringPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMENUM:
|
|
status = val.serializeFrom(enumPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMARRAY:
|
|
status = val.serializeFrom(arrayPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRUCT:
|
|
status = val.serializeFrom(structPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
}
|
|
|
|
this->pushFromPortEntry_prmGetIn(id, val);
|
|
|
|
return prmValid;
|
|
}
|
|
|
|
void ActiveTestTester ::from_prmSetIn_handler(const FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {
|
|
Fw::SerializeStatus status;
|
|
U32 id_base = component.getIdBase();
|
|
|
|
FW_ASSERT(id >= id_base);
|
|
|
|
switch (id - id_base) {
|
|
case ActiveTestComponentBase::PARAMID_PARAMBOOL:
|
|
status = val.deserializeTo(boolPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMU32:
|
|
status = val.deserializeTo(u32Prm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRING:
|
|
status = val.deserializeTo(stringPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMENUM:
|
|
status = val.deserializeTo(enumPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMARRAY:
|
|
status = val.deserializeTo(arrayPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRUCT:
|
|
status = val.deserializeTo(structPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
}
|
|
|
|
this->pushFromPortEntry_prmSetIn(id, val);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Unit test implementation of external parameter delegate serialization/deserialization
|
|
// ----------------------------------------------------------------------
|
|
|
|
Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelegate ::deserializeParam(
|
|
const FwPrmIdType base_id,
|
|
const FwPrmIdType local_id,
|
|
const Fw::ParamValid prmStat,
|
|
Fw::SerialBufferBase& buff) {
|
|
Fw::SerializeStatus stat;
|
|
(void)base_id;
|
|
|
|
// Serialize the parameter based on ID
|
|
switch (local_id) {
|
|
// ParamBoolExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamBoolExternal);
|
|
break;
|
|
// ParamI32External
|
|
case ActiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamI32External);
|
|
break;
|
|
// ParamStringExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamStringExternal);
|
|
break;
|
|
// ParamEnumExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamEnumExternal);
|
|
break;
|
|
// ParamArrayExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamArrayExternal);
|
|
break;
|
|
// ParamStructExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamStructExternal);
|
|
break;
|
|
default:
|
|
// Unknown ID should not have gotten here
|
|
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
|
|
}
|
|
|
|
return stat;
|
|
}
|
|
|
|
Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelegate ::serializeParam(
|
|
const FwPrmIdType base_id,
|
|
const FwPrmIdType local_id,
|
|
Fw::SerialBufferBase& buff) const {
|
|
Fw::SerializeStatus stat;
|
|
(void)base_id;
|
|
|
|
// Serialize the parameter based on ID
|
|
switch (local_id) {
|
|
// ParamBoolExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamBoolExternal);
|
|
break;
|
|
// ParamI32External
|
|
case ActiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamI32External);
|
|
break;
|
|
// ParamStringExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamStringExternal);
|
|
break;
|
|
// ParamEnumExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamEnumExternal);
|
|
break;
|
|
// ParamArrayExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamArrayExternal);
|
|
break;
|
|
// ParamStructExternal
|
|
case ActiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamStructExternal);
|
|
break;
|
|
default:
|
|
// Unknown ID should not have gotten here
|
|
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
|
|
}
|
|
|
|
return stat;
|
|
}
|