Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseDummyCriticalTelecommand_2.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseDummyCriticalTelecommand_2.cpp 00005 // 00006 // Version 1.0 00007 // Date 17.06.03 00008 // Author R. Totaro 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../GeneralInclude/TestConstants.h" 00014 #include "../System/DC_DummyObsClock.h" 00015 #include "../Telecommand/DC_DummyCriticalTelecommand.h" 00016 #include "TestCaseDummyCriticalTelecommand_2.h" 00017 00018 TestCaseDummyCriticalTelecommand_2::TestCaseDummyCriticalTelecommand_2(void) : 00019 TestCaseWithEvtCheck(ID_DUMMYCRITICALTELECOMMAND*10+2, 00020 "TestCaseDummyCriticalTelecommand_2") { 00021 return; 00022 } 00023 00024 void TestCaseDummyCriticalTelecommand_2::runTestCase(void) { 00025 const TD_ObsTime timeTag =0; 00026 const TD_ObsTime maxArmedDuration=10; 00027 const unsigned int nEvt =getNumberOfEvents(); 00028 DC_DummyObsClock *pObsClk =new DC_DummyObsClock(); 00029 DC_DummyCriticalTelecommand *pTC =new DC_DummyCriticalTelecommand(); 00030 00031 // Initialize the object, including the base class 00032 pTC->setTimeTag(timeTag); 00033 pTC->setMaxArmedDuration(maxArmedDuration); 00034 pTC->setObsClock(pObsClk); 00035 00036 // First we test the non-critical behaviour 00037 pTC->setCriticalityLevel(false); 00038 00039 // The TC is not critical: canExecute() shall return true 00040 if (!pTC->canExecute()) { 00041 setTestResult(TEST_FAILURE,"Non-critical TC can not be executed"); 00042 return; 00043 } 00044 00045 // Executing a non-critical TC should always result in a invocation 00046 // of doCriticalAction(). 00047 if (pTC->execute()!=ACTION_SUCCESS) { 00048 setTestResult(TEST_FAILURE,"TC execute() failed"); 00049 return; 00050 } 00051 00052 if (pTC->getNumberOfExecutions()!=1) { 00053 setTestResult(TEST_FAILURE,"doCriticalAction() not called"); 00054 return; 00055 } 00056 00057 // We now make the TC critical. An invocation of canExecute() shall 00058 // return true. A subsequent call to execute() shall arm the TC, set the 00059 // "time when armed" to the current time, add an EVT_CRIT_TC_ARMED to the 00060 // event log and return ACTION_SUCCESS. 00061 pTC->setCriticalityLevel(true); 00062 00063 if (!pTC->canExecute()) { 00064 setTestResult(TEST_FAILURE,"Disarmed, critical TC cannot be executed"); 00065 return; 00066 } 00067 00068 if (pTC->execute()!=ACTION_SUCCESS) { 00069 setTestResult(TEST_FAILURE,"TC execute() failed"); 00070 return; 00071 } 00072 00073 if (!pTC->isArmed()) { 00074 setTestResult(TEST_FAILURE,"Failed to arm TC"); 00075 return; 00076 } 00077 00078 if (pTC->getTimeWhenArmed()!=pObsClk->getTime()) { 00079 setTestResult(TEST_FAILURE,"Wrong \"time when armed\""); 00080 return; 00081 } 00082 00083 if (!verifySpecificEvent((nEvt+2),EVT_CRIT_TC_ARMED)) 00084 return; 00085 00086 // Invoking isImageValid() on a newly created DC_DummyCriticalTelecommand 00087 // returns false, thus a new call to canExecute() shall return false and add 00088 // an EVT_CRIT_TC_IMG_INV event to the repository with the TC id as parameter. 00089 if (pTC->canExecute()) { 00090 setTestResult(TEST_FAILURE,"TC with invalid image can be executed"); 00091 return; 00092 } 00093 00094 if (!verifyLatestEvent((nEvt+4),EVT_CRIT_TC_IMG_INV)) 00095 return; 00096 00097 // The arm state shall be unmodifief 00098 if (!pTC->isArmed()) { 00099 setTestResult(TEST_FAILURE,"Unexpected change in arm state"); 00100 return; 00101 } 00102 00103 // Reset the TC in order to perform the next test 00104 pTC->reset(); 00105 00106 // Verify that reset() did its job 00107 if (pTC->getTimeWhenArmed()>=0) { 00108 setTestResult(TEST_FAILURE,"reset() failed (timeWhenArmed)"); 00109 return; 00110 } 00111 00112 if (pTC->isArmed()) { 00113 setTestResult(TEST_FAILURE,"reset() failed (isTcArmed)"); 00114 return; 00115 } 00116 00117 if (pTC->getMaxArmedDuration()>=0) { 00118 setTestResult(TEST_FAILURE,"reset() failed (maxArmedDuration"); 00119 return; 00120 } 00121 00122 // Clearly the TC shall also be re-initialized 00123 pTC->setObsClock(pObsClk); 00124 pTC->setMaxArmedDuration(maxArmedDuration); 00125 00126 // Now the TC is no longer armed. We call execute() to arm it (we know canExecute() 00127 // would return true), set the image validity flag to true and call canExecute() 00128 // a second time. This time it shall return true. 00129 pTC->execute(); 00130 pTC->setImageValidity(true); 00131 00132 if (!pTC->canExecute()) { 00133 setTestResult(TEST_FAILURE,"Valid TC can not be executed"); 00134 return; 00135 } 00136 00137 // We now call execute() and verify that doCriticalAction() is invoked 00138 // and the TC is disarmed. 00139 pTC->execute(); 00140 00141 if (pTC->getNumberOfExecutions()!=2) { 00142 setTestResult(TEST_FAILURE,"doCriticalAction() not called"); 00143 return; 00144 } 00145 00146 if (pTC->isArmed()) { 00147 setTestResult(TEST_FAILURE,"Call to execute() did not disarm TC"); 00148 return; 00149 } 00150 00151 if (pTC->getTimeWhenArmed()>=0) { 00152 setTestResult(TEST_FAILURE,"\"Time when armed\" was not reset"); 00153 return; 00154 } 00155 00156 // Finally, we see what happens when a timeout occurs. In this case the image 00157 // validity shall play no role in the test outcome. We test both cases anyway. 00158 // First of all, the TC shall be reset, initialized and re-armed. 00159 pTC->reset(); 00160 pTC->setObsClock(pObsClk); 00161 pTC->setMaxArmedDuration(maxArmedDuration); 00162 pTC->execute(); 00163 00164 // The image validity is set to true 00165 pTC->setImageValidity(true); 00166 00167 // Then the OBS clock is set to a value such that the TC times out 00168 pObsClk->setTime(pTC->getTimeWhenArmed()+maxArmedDuration); 00169 pObsClk->setCycle(0); 00170 00171 // And it is verified that the TC actually times out and an event is 00172 // reported 00173 if (pTC->canExecute()) { 00174 setTestResult(TEST_FAILURE,"Timed-out TC can be executed"); 00175 return; 00176 } 00177 00178 if (!verifyLatestEvent((nEvt+10),EVT_CRIT_TC_TIMEOUT)) 00179 return; 00180 00181 // We do the same on a TC with an invalid image 00182 pTC->reset(); 00183 pTC->setObsClock(pObsClk); 00184 pTC->setMaxArmedDuration(maxArmedDuration); 00185 pTC->execute(); 00186 00187 // The image validity is set to false, this time 00188 pTC->setImageValidity(false); 00189 00190 // The rest is the same as in the previous test 00191 pObsClk->setTime(pTC->getTimeWhenArmed()+maxArmedDuration); 00192 pObsClk->setCycle(0); 00193 00194 if (pTC->canExecute()) { 00195 setTestResult(TEST_FAILURE,"Timed-out TC can be executed"); 00196 return; 00197 } 00198 00199 if (!verifyLatestEvent((nEvt+13),EVT_CRIT_TC_TIMEOUT)) 00200 return; 00201 00202 setTestResult(TEST_SUCCESS,"Test Successful"); 00203 return; 00204 }
Copyright 2003 P&P Software GmbH - All Rights Reserved