00001
00002
00003
00004
00005
00006
00007
00008
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
00032 pTC->
setTimeTag(timeTag);
00033 pTC->
setMaxArmedDuration(maxArmedDuration);
00034 pTC->
setObsClock(pObsClk);
00035
00036
00037 pTC->
setCriticalityLevel(
false);
00038
00039
00040
if (!pTC->
canExecute()) {
00041 setTestResult(
TEST_FAILURE,
"Non-critical TC can not be executed");
00042
return;
00043 }
00044
00045
00046
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
00058
00059
00060
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
00087
00088
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
00098
if (!pTC->
isArmed()) {
00099 setTestResult(
TEST_FAILURE,
"Unexpected change in arm state");
00100
return;
00101 }
00102
00103
00104 pTC->
reset();
00105
00106
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
00123 pTC->
setObsClock(pObsClk);
00124 pTC->
setMaxArmedDuration(maxArmedDuration);
00125
00126
00127
00128
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
00138
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
00157
00158
00159 pTC->
reset();
00160 pTC->
setObsClock(pObsClk);
00161 pTC->
setMaxArmedDuration(maxArmedDuration);
00162 pTC->
execute();
00163
00164
00165 pTC->
setImageValidity(
true);
00166
00167
00168 pObsClk->
setTime(pTC->
getTimeWhenArmed()+maxArmedDuration);
00169 pObsClk->
setCycle(0);
00170
00171
00172
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
00182 pTC->
reset();
00183 pTC->
setObsClock(pObsClk);
00184 pTC->
setMaxArmedDuration(maxArmedDuration);
00185 pTC->
execute();
00186
00187
00188 pTC->
setImageValidity(
false);
00189
00190
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 }