unit test for detection of missed reply when commanded externally
This commit is contained in:
parent
161dbde0d7
commit
4fba2704aa
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ComIFMock supports the simulation of various device communication error cases
|
* @brief The ComIFMock supports the simulation of various device communication error cases
|
||||||
* like incomplete or wrong replies and can be used to test the DeviceHandlerBase.
|
* like incomplete or wrong replies and can be used to test the
|
||||||
|
* DeviceHandlerBase.
|
||||||
*/
|
*/
|
||||||
class ComIFMock : public DeviceCommunicationIF, public SystemObject {
|
class ComIFMock : public DeviceCommunicationIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
|
@ -83,7 +83,11 @@ void DeviceHandlerMock::fillCommandAndReplyMap() {
|
|||||||
uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
||||||
|
|
||||||
void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) {
|
void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) {
|
||||||
periodicReplyCountdown.setTimeout(0);
|
periodicReplyCountdown.setTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
|
||||||
|
simpleCommandReplyTimeout.setTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerMock::resetPeriodicReplyState() {
|
void DeviceHandlerMock::resetPeriodicReplyState() {
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
CookieIF *comCookie, FailureIsolationBase* fdirInstance);
|
CookieIF *comCookie, FailureIsolationBase* fdirInstance);
|
||||||
virtual ~DeviceHandlerMock();
|
virtual ~DeviceHandlerMock();
|
||||||
void changePeriodicReplyCountdown(uint32_t timeout);
|
void changePeriodicReplyCountdown(uint32_t timeout);
|
||||||
|
void changeSimpleCommandReplyCountdown(uint32_t timeout);
|
||||||
void resetPeriodicReplyState();
|
void resetPeriodicReplyState();
|
||||||
bool getPeriodicReplyReceived();
|
bool getPeriodicReplyReceived();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
|||||||
result = deviceHandlerCommander.initialize();
|
result = deviceHandlerCommander.initialize();
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
SECTION("Commanding") {
|
SECTION("Commanding nominal") {
|
||||||
comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL);
|
comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL);
|
||||||
result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK,
|
result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK,
|
||||||
DeviceHandlerMock::SIMPLE_COMMAND);
|
DeviceHandlerMock::SIMPLE_COMMAND);
|
||||||
@ -36,7 +36,28 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
|||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Periodic reply") {
|
SECTION("Commanding missed reply") {
|
||||||
|
comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY);
|
||||||
|
deviceHandlerCommander.resetReplyReturnCode();
|
||||||
|
// Set the timeout to 0 to immediately timeout the reply
|
||||||
|
deviceHandlerMock.changeSimpleCommandReplyCountdown(0);
|
||||||
|
result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK,
|
||||||
|
DeviceHandlerMock::SIMPLE_COMMAND);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
deviceHandlerCommander.performOperation();
|
||||||
|
result = deviceHandlerCommander.getReplyReturnCode();
|
||||||
|
REQUIRE(result == DeviceHandlerIF::TIMEOUT);
|
||||||
|
uint32_t missedReplies = deviceFdirMock.getMissedReplyCount();
|
||||||
|
REQUIRE(missedReplies == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Periodic reply nominal") {
|
||||||
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
|
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||||
|
Loading…
Reference in New Issue
Block a user