mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 16:29:04 -06:00
* Created new SerialBufferBase as a parent of SerializeBufferBase. Renaming interface functions to be less confusing. * Deprecating copyRawOffset. No direct use-cases in F' core. * Make SerialBufferBase a true pure virtual interface. * Changing Serializable to work with SerialBufferBase parent interface. * Changing copyRaw and copyRawOffset to work with SerialBufferBase * Updating documentation for SerialBufferBase usage * Adding some documentation. Adding missing ASSERT in copyRaw. Fixing some bugs that new ASSERT uncovered. * Renaming SerializeBufferBase to LinearBufferBase. Add a using declaration to maintain backwards compatability. Properly mark LinearBufferBase functions as override. * Filling in the rest of the docstrings for the classes in Serializable * Removing redundant virtual keyword on override function * Applying clang formatting * Incorporating PR comments * Fix compile issues * Bump version to alpha * Format * v --------- Co-authored-by: M Starch <LeStarch@googlemail.com>
211 lines
7.8 KiB
C++
211 lines
7.8 KiB
C++
// ======================================================================
|
|
// \title QueuedTest/test/ut/QueuedTestTester.cpp
|
|
// \author tiffany
|
|
// \brief cpp file for QueuedTest test harness implementation class
|
|
// ======================================================================
|
|
|
|
#include "QueuedTestTester.hpp"
|
|
#include "STest/Pick/Pick.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction and destruction
|
|
// ----------------------------------------------------------------------
|
|
|
|
QueuedTestTester ::QueuedTestTester()
|
|
: QueuedTestGTestBase("QueuedTestTester", QueuedTestTester::MAX_HISTORY_SIZE),
|
|
component("QueuedTest"),
|
|
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);
|
|
}
|
|
|
|
QueuedTestTester ::~QueuedTestTester() {}
|
|
|
|
void QueuedTestTester ::initComponents() {
|
|
this->init();
|
|
this->component.init(QueuedTestTester::TEST_INSTANCE_QUEUE_DEPTH, QueuedTestTester::TEST_INSTANCE_ID);
|
|
}
|
|
|
|
Fw::ParamValid QueuedTestTester ::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 QueuedTestComponentBase::PARAMID_PARAMBOOL:
|
|
status = val.serializeFrom(boolPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMU32:
|
|
status = val.serializeFrom(u32Prm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMSTRING:
|
|
status = val.serializeFrom(stringPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMENUM:
|
|
status = val.serializeFrom(enumPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMARRAY:
|
|
status = val.serializeFrom(arrayPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMSTRUCT:
|
|
status = val.serializeFrom(structPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
}
|
|
|
|
this->pushFromPortEntry_prmGetIn(id, val);
|
|
|
|
return prmValid;
|
|
}
|
|
|
|
void QueuedTestTester ::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 QueuedTestComponentBase::PARAMID_PARAMBOOL:
|
|
status = val.deserializeTo(boolPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMU32:
|
|
status = val.deserializeTo(u32Prm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMSTRING:
|
|
status = val.deserializeTo(stringPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMENUM:
|
|
status = val.deserializeTo(enumPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::PARAMID_PARAMARRAY:
|
|
status = val.deserializeTo(arrayPrm.args.val);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
break;
|
|
|
|
case QueuedTestComponentBase::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 QueuedTestTester::QueuedTestComponentBaseParamExternalDelegate ::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 QueuedTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamBoolExternal);
|
|
break;
|
|
// ParamI32External
|
|
case QueuedTestComponentBase::PARAMID_PARAMI32EXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamI32External);
|
|
break;
|
|
// ParamStringExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamStringExternal);
|
|
break;
|
|
// ParamEnumExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamEnumExternal);
|
|
break;
|
|
// ParamArrayExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
|
|
stat = buff.deserializeTo(this->m_param_ParamArrayExternal);
|
|
break;
|
|
// ParamStructExternal
|
|
case QueuedTestComponentBase::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 QueuedTestTester::QueuedTestComponentBaseParamExternalDelegate ::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 QueuedTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamBoolExternal);
|
|
break;
|
|
// ParamI32External
|
|
case QueuedTestComponentBase::PARAMID_PARAMI32EXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamI32External);
|
|
break;
|
|
// ParamStringExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamStringExternal);
|
|
break;
|
|
// ParamEnumExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamEnumExternal);
|
|
break;
|
|
// ParamArrayExternal
|
|
case QueuedTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
|
|
stat = buff.serializeFrom(this->m_param_ParamArrayExternal);
|
|
break;
|
|
// ParamStructExternal
|
|
case QueuedTestComponentBase::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;
|
|
}
|