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

TestCaseBasicPUSTcLoader_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseBasicPUSTcLoader_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.02.04 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/BasicTypes.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Telecommand/CC_TelecommandFactory.h" 00015 #include "../Telecommand/CC_TelecommandManager.h" 00016 #include "../Telecommand/DC_TestPUSTelecommand.h" 00017 #include "../Telecommand/DC_BasicPUSTcLoader.h" 00018 #include "../Data/DC_SampleFullDataPool.h" 00019 #include "../Utilities/TestCasePUSFull.h" 00020 #include "TestCaseBasicPUSTcLoader_1.h" 00021 00022 #include <string.h> 00023 #include <assert.h> 00024 00025 TestCaseBasicPUSTcLoader_1::TestCaseBasicPUSTcLoader_1(void) : 00026 TestCasePUSFull(ID_BASICPUSTCLOADER*10+1,"TestCaseBasicPUSTcLoader_1") { 00027 return; 00028 } 00029 00030 void TestCaseBasicPUSTcLoader_1::runTestCase(void) { 00031 00032 const unsigned int TC_AREA_SIZE = 85; 00033 tcArea = new unsigned char[TC_AREA_SIZE]; 00034 CC_TelecommandFactory* pTCF = CC_TelecommandFactory::getInstance(); 00035 if ( pTCF->getNumberTestPUSTelecommand()!=0 ) 00036 { setTestResult(TEST_FAILURE,"Wrong number of telecommands"); 00037 return; 00038 } 00039 if ( pTCF->getCapacityTestPUSTelecommand()<3 ) 00040 { setTestResult(TEST_FAILURE,"Insufficient TC factory capacity"); 00041 return; 00042 } 00043 unsigned int nEvt; 00044 CC_TelecommandManager* pTCM = getTelecommandManager(); 00045 pTCL = getTcLoader(); 00046 00047 // Check the correctness of the class identifier 00048 if ( (pTCL->getClassId() != ID_BASICPUSTCLOADER) ) 00049 { setTestResult(TEST_FAILURE,"Wrong class identifier"); 00050 return; 00051 } 00052 00053 // Set the start address of the telecommand load area 00054 pTCL->setTcLoadAreaStart(tcArea); 00055 00056 // Set max number of TCs 00057 const unsigned int MAX_NUMBER_OF_TC = 4; 00058 pTCL->setMaxNumberOfTc(MAX_NUMBER_OF_TC); 00059 if ( pTCL->getMaxNumberOfTc()!=MAX_NUMBER_OF_TC) 00060 { setTestResult(TEST_FAILURE,"Wrong configuration value"); 00061 return; 00062 } 00063 00064 // Set max length of TCs 00065 const unsigned int MAX_TC_LENGTH = 20; 00066 pTCL->setMaxTcLength(MAX_TC_LENGTH); 00067 if ( pTCL->getMaxTcLength()!=MAX_TC_LENGTH) 00068 { setTestResult(TEST_FAILURE,"Wrong configuration value"); 00069 return; 00070 } 00071 00072 // Load one telecommand image 00073 unsigned short tcID = 11; 00074 TD_TelecommandSource tcSource = 13; 00075 unsigned int start = 0; 00076 *(tcArea+start) = 1; // number of telecommands 00077 start++; 00078 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00079 0xA,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00080 start = start+9+sizeof(TD_TelecommandSource); 00081 writeTcData(start,3,false,true,1,2,0); 00082 start = start+8; 00083 pTCL->activate(); 00084 00085 // Check the number of loaded telecommands 00086 if ( pTCM->getPendingTelecommands()!=1 ) 00087 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00088 return; 00089 } 00090 00091 // Check the configuration of the loaded telecommand 00092 Telecommand* pTC = pTCM->getPendingTelecommand(0); 00093 if ( pTC==pNULL ) 00094 { setTestResult(TEST_FAILURE,"No loaded telecommand"); 00095 return; 00096 } 00097 if ( pTC->getClassId()!=ID_TESTPUSTELECOMMAND ) 00098 { setTestResult(TEST_FAILURE,"Wrong loaded telecommand"); 00099 return; 00100 } 00101 if ( checkTcConfig( (DC_TestPUSTelecommand*)pTC, 00102 PUSTelecommand::getPacketId(), tcID, 00103 0xA, tcSource, 3, false, false, 1, 2, 0) ) 00104 { setTestResult(TEST_FAILURE,"Wrong telecommand configuration"); 00105 return; 00106 } 00107 00108 // Check the "in use" status 00109 if ( !pTC->isInUse() ) 00110 { setTestResult(TEST_FAILURE,"Wrong in_use status"); 00111 return; 00112 } 00113 pTCM->activate(); 00114 if ( pTC->isInUse() ) 00115 { setTestResult(TEST_FAILURE,"Wrong in_use status"); 00116 return; 00117 } 00118 00119 // Write two TC packets to the tc load area of which the second is not intended for the TC loader 00120 *(tcArea) = 2; // number of telecommands 00121 start = 1; 00122 00123 writeTcHeader(start,PUSTelecommand::getPacketId()+1,tcID,11+sizeof(TD_TelecommandSource), 00124 0xA,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00125 start = start+9+sizeof(TD_TelecommandSource); 00126 writeTcData(start,3,false,true,1,2,0); 00127 start = start+8; 00128 00129 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00130 0xA,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00131 start = start+9+sizeof(TD_TelecommandSource); 00132 writeTcData(start,3,false,true,1,2,0); 00133 start = start+8; 00134 pTCL->activate(); 00135 00136 // Check the number of loaded telecommands 00137 if ( pTCM->getPendingTelecommands()!=1 ) 00138 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00139 return; 00140 } 00141 00142 // Write three TC packets to the tc load area 00143 *(tcArea) = 3; // number of telecommands 00144 start = 1; 00145 00146 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00147 0xB,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00148 start = start+9+sizeof(TD_TelecommandSource); 00149 writeTcData(start,7,true,true,1,1,1); 00150 start = start+8; 00151 00152 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00153 0xC,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00154 start = start+9+sizeof(TD_TelecommandSource); 00155 writeTcData(start,17,false,true,2,2,0); 00156 start = start+8; 00157 00158 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00159 0xD,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00160 start = start+9+sizeof(TD_TelecommandSource); 00161 writeTcData(start,27,true,true,3,3,1); 00162 start = start+8; 00163 pTCL->activate(); 00164 00165 // Check the number of loaded telecommands 00166 if ( pTCM->getPendingTelecommands()!=3 ) 00167 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00168 return; 00169 } 00170 00171 // Check the configuration of the first telecommand 00172 Telecommand* pTCa = pTCM->getPendingTelecommand(0); 00173 if ( pTC==pNULL ) 00174 { setTestResult(TEST_FAILURE,"No loaded telecommand"); 00175 return; 00176 } 00177 if ( pTC->getClassId()!=ID_TESTPUSTELECOMMAND ) 00178 { setTestResult(TEST_FAILURE,"Wrong loaded telecommand"); 00179 return; 00180 } 00181 if ( checkTcConfig( (DC_TestPUSTelecommand*)pTC, 00182 PUSTelecommand::getPacketId(), tcID, 00183 0xB, tcSource, 7,true,true,1,1,1) ) 00184 { setTestResult(TEST_FAILURE,"Wrong telecommand configuration"); 00185 return; 00186 } 00187 00188 // Check the configuration of the second telecommand 00189 Telecommand* pTCb = pTCM->getPendingTelecommand(1); 00190 if ( pTC==pNULL ) 00191 { setTestResult(TEST_FAILURE,"No loaded telecommand"); 00192 return; 00193 } 00194 if ( pTC->getClassId()!=ID_TESTPUSTELECOMMAND ) 00195 { setTestResult(TEST_FAILURE,"Wrong loaded telecommand"); 00196 return; 00197 } 00198 if ( checkTcConfig( (DC_TestPUSTelecommand*)pTC, 00199 PUSTelecommand::getPacketId(), tcID, 00200 0xC, tcSource, 17,false,false,2,2,0) ) 00201 { setTestResult(TEST_FAILURE,"Wrong telecommand configuration"); 00202 return; 00203 } 00204 00205 // Check the configuration of the third telecommand 00206 Telecommand* pTCc = pTCM->getPendingTelecommand(2); 00207 if ( pTC==pNULL ) 00208 { setTestResult(TEST_FAILURE,"No loaded telecommand"); 00209 return; 00210 } 00211 if ( pTC->getClassId()!=ID_TESTPUSTELECOMMAND ) 00212 { setTestResult(TEST_FAILURE,"Wrong loaded telecommand"); 00213 return; 00214 } 00215 if ( checkTcConfig( (DC_TestPUSTelecommand*)pTC, 00216 PUSTelecommand::getPacketId(), tcID, 00217 0xD, tcSource, 27,true,false,3,3,1) ) 00218 { setTestResult(TEST_FAILURE,"Wrong telecommand configuration"); 00219 return; 00220 } 00221 00222 // Check the "in use" status 00223 if ( !pTCa->isInUse() || !pTCb->isInUse() || !pTCc->isInUse() ) 00224 { setTestResult(TEST_FAILURE,"Wrong in_use status"); 00225 return; 00226 } 00227 pTCM->activate(); 00228 if ( pTCa->isInUse() || pTCb->isInUse() || pTCc->isInUse() ) 00229 { setTestResult(TEST_FAILURE,"Wrong in_use status"); 00230 return; 00231 } 00232 00233 // Write a TC packets that is too long 00234 *(tcArea) = 1; // number of telecommands 00235 start = 1; 00236 00237 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,MAX_TC_LENGTH+1, 00238 0xA,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00239 start = start+9+sizeof(TD_TelecommandSource); 00240 writeTcData(start,3,false,true,1,2,0); 00241 start = start+8; 00242 nEvt = getNumberOfEvents(); 00243 pTCL->activate(); 00244 00245 // Check the number of loaded telecommands 00246 if ( pTCM->getPendingTelecommands()!=0 ) 00247 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00248 return; 00249 } 00250 00251 // Check correct event generation and flush the TC manager 00252 if ( !verifyLatestEvent(nEvt+1,EVT_TC_TOO_LONG) ) 00253 { setTestResult(TEST_FAILURE,"Wrong event report type"); 00254 return; 00255 } 00256 nEvt++; 00257 pTCM->activate(); 00258 00259 // Write two TC packets of which the first one has a type not recongnized by the TC loader 00260 *(tcArea) = 2; // number of telecommands 00261 start = 1; 00262 00263 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00264 0xA,PUS_TYPE_TEST+1,PUS_ST_TC_TEST,tcSource); 00265 start = start+9+sizeof(TD_TelecommandSource); 00266 writeTcData(start,3,false,true,1,2,0); 00267 start = start+8; 00268 00269 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00270 0xA,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00271 start = start+9+sizeof(TD_TelecommandSource); 00272 writeTcData(start,3,false,true,1,2,0); 00273 start = start+8; 00274 00275 nEvt = getNumberOfEvents(); 00276 pTCL->activate(); 00277 00278 // Check the number of loaded telecommands 00279 if ( pTCM->getPendingTelecommands()!=1 ) 00280 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00281 return; 00282 } 00283 00284 // Check correct event generation 00285 if ( !verifySpecificEvent(nEvt+1,EVT_UNKNOWN_TC_TYPE) ) 00286 { setTestResult(TEST_FAILURE,"Wrong event report type"); 00287 return; 00288 } 00289 pTCM->activate(); // flush the TC manager 00290 00291 // Write more TC packets that allowed 00292 *(tcArea) = MAX_NUMBER_OF_TC+1; // number of telecommands 00293 00294 nEvt = getNumberOfEvents(); 00295 pTCL->activate(); 00296 00297 // Check the number of loaded telecommands 00298 if ( pTCM->getPendingTelecommands()!=0 ) 00299 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00300 return; 00301 } 00302 00303 // Check correct event generation 00304 if ( !verifyLatestEvent(nEvt+1,EVT_TOO_MANY_TC_PCKT) ) 00305 { setTestResult(TEST_FAILURE,"Wrong event report type"); 00306 return; 00307 } 00308 pTCM->activate(); // flush the TC manager 00309 00310 // Write four TC packets to the tc load area 00311 *(tcArea) = 4; // number of telecommands 00312 start = 1; 00313 00314 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00315 0xB,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00316 start = start+9+sizeof(TD_TelecommandSource); 00317 writeTcData(start,7,true,true,1,1,1); 00318 start = start+8; 00319 00320 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00321 0xC,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00322 start = start+9+sizeof(TD_TelecommandSource); 00323 writeTcData(start,17,false,true,2,2,0); 00324 start = start+8; 00325 00326 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00327 0xD,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00328 start = start+9+sizeof(TD_TelecommandSource); 00329 writeTcData(start,27,true,true,3,3,1); 00330 start = start+8; 00331 00332 writeTcHeader(start,PUSTelecommand::getPacketId(),tcID,11+sizeof(TD_TelecommandSource), 00333 0xD,PUS_TYPE_TEST,PUS_ST_TC_TEST,tcSource); 00334 start = start+9+sizeof(TD_TelecommandSource); 00335 writeTcData(start,27,true,true,3,3,1); 00336 start = start+8; 00337 nEvt = getNumberOfEvents(); 00338 pTCL->activate(); 00339 00340 // Check the number of loaded telecommands 00341 if ( pTCM->getPendingTelecommands()!=3 ) 00342 { setTestResult(TEST_FAILURE,"Wrong number of pending TCs"); 00343 return; 00344 } 00345 00346 // Check correct event generation (NB: one event is created whenever a TC is 00347 // successufully loaded in the TC manager) 00348 if ( !verifyLatestEvent(nEvt+4,EVT_NO_TC_AVAIL) ) 00349 { setTestResult(TEST_FAILURE,"Wrong event report type"); 00350 return; 00351 } 00352 pTCM->activate(); // flush the TC manager 00353 00354 // If this point is reached, the test was successful 00355 setTestResult(TEST_SUCCESS,"Test Successful"); 00356 return; 00357 } 00358 00359 void TestCaseBasicPUSTcLoader_1::writeTcHeader(unsigned int start, unsigned short packetId, unsigned short packetSeqControl, 00360 unsigned short packetLength, unsigned char ackField, unsigned char tcType, 00361 unsigned char tcSubType, TD_TelecommandSource tcSource) { 00362 00363 assert(sizeof(unsigned short)==2); 00364 assert(sizeof(unsigned char)==1); 00365 memcpy((tcArea+start),&packetId,2); 00366 memcpy((tcArea+start+2),&packetSeqControl,2); 00367 memcpy((tcArea+start+4),&packetLength,2); 00368 memcpy((tcArea+start+6),&ackField,1); 00369 memcpy((tcArea+start+7),&tcType,1); 00370 memcpy((tcArea+start+8),&tcSubType,1); 00371 memcpy((tcArea+start+9),&tcSource,sizeof(TD_TelecommandSource)); 00372 } 00373 00374 void TestCaseBasicPUSTcLoader_1::writeTcData( 00375 unsigned int start, unsigned int execCounter, bool execCheckVal, 00376 bool valCheckVal, TD_CheckCode execCheckCode, 00377 TD_CheckCode valCheckCode, bool execOutcome) { 00378 00379 *(unsigned char*)(tcArea+start) = (unsigned char)execCounter; 00380 *(unsigned char*)(tcArea+start+1) = execCheckVal; 00381 *(unsigned char*)(tcArea+start+2) = valCheckVal; 00382 *(unsigned char*)(tcArea+start+3) = (unsigned char)execCheckCode; 00383 *(unsigned char*)(tcArea+start+4) = (unsigned char)valCheckCode; 00384 *(unsigned char*)(tcArea+start+5) = execOutcome; 00385 } 00386 00387 bool TestCaseBasicPUSTcLoader_1::checkTcConfig(DC_TestPUSTelecommand* pTC, 00388 unsigned short packetID, unsigned short packetSeqControl, 00389 unsigned char ackField, TD_TelecommandSource tcSource, 00390 unsigned int execCounter, bool execCheckVal, 00391 bool valCheckVal, TD_CheckCode execCheckCode, 00392 TD_CheckCode valCheckCode, bool execOutcome) { 00393 00394 if ( pTC->getPacketId()!=packetID ) 00395 return false; 00396 00397 if ( pTC->getTelecommandId()!=packetSeqControl ) 00398 return false; 00399 00400 if ( pTC->isAcceptanceAckRequired() && !(ackField&1) ) 00401 return false; 00402 00403 if ( pTC->isStartAckRequired() && !(ackField&2) ) 00404 return false; 00405 00406 if ( pTC->isProgressAckRequired() && !(ackField&4) ) 00407 return false; 00408 00409 if ( pTC->isCompletionAckRequired() && !(ackField&8) ) 00410 return false; 00411 00412 if ( pTC->getSource()!=tcSource ) 00413 return false; 00414 00415 if ( pTC->getExecutionCounter() != execCounter ) 00416 return false; 00417 00418 if ( pTC->canExecute() && !execCheckVal ) 00419 return false; 00420 00421 if ( pTC->isValid() && !valCheckVal ) 00422 return false; 00423 00424 if ( pTC->getExecutionCheckCode() != execCheckCode ) 00425 return false; 00426 00427 if ( pTC->getValidityCheckCode() != valCheckCode ) 00428 return false; 00429 00430 if ( (pTC->execute()== ACTION_SUCCESS) && !execOutcome ) 00431 return false; 00432 00433 return true; 00434 } 00435
Copyright 2003 P&P Software GmbH - All Rights Reserved