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

TestCaseBasicReconfigurer_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseBasicReconfigurer_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.06.03 00008 // Author R. Totaro 00009 00010 #include "TestCaseBasicReconfigurer_1.h" 00011 #include "../GeneralInclude/CompilerSwitches.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Base/DC_BasicReconfigurer.h" 00015 00016 TestCaseBasicReconfigurer_1::TestCaseBasicReconfigurer_1(void) : 00017 TestCaseWithEvtCheck(ID_BASICRECONFIGURER*10+1,"TestCaseBasicReconfigurer_1") { 00018 return; 00019 } 00020 00021 void TestCaseBasicReconfigurer_1::runTestCase(void) { 00022 const TD_Config nConf=16; 00023 unsigned int nEvt =getNumberOfEvents(); 00024 DC_BasicReconfigurer *pBR =new DC_BasicReconfigurer(); 00025 00026 // Verify correctness of the class identifier 00027 if (pBR->getClassId()!=ID_BASICRECONFIGURER) { 00028 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00029 return; 00030 } 00031 00032 // A newly created reconfigurer shall not be configured... 00033 if (pBR->isObjectConfigured()) { 00034 setTestResult(TEST_FAILURE,"Newly created reconfigurer is configured"); 00035 return; 00036 } 00037 00038 // ...but it should be enabled! 00039 if (!pBR->isEnabled()) { 00040 setTestResult(TEST_FAILURE,"Newly created reconfigurer is not enabled"); 00041 return; 00042 } 00043 00044 // Let's see if we can change the enable status 00045 pBR->setEnabled(false); 00046 if (pBR->isEnabled()) { 00047 setTestResult(TEST_FAILURE,"Can't chenge enable status"); 00048 return; 00049 } 00050 00051 // We now set the number of possible configurations 00052 pBR->setNumberOfConfigurations(nConf); 00053 00054 // The reconfigurer should now be configured 00055 if (!pBR->isObjectConfigured()) { 00056 setTestResult(TEST_FAILURE,"Reconfigurer not configured"); 00057 return; 00058 } 00059 00060 // Let's verify that the number of configuration is properly set, 00061 // that all the newly created configurations are healthy, and that 00062 // the active configuration is set to 0. 00063 if (pBR->getNumberOfConfigurations()!=nConf) { 00064 setTestResult(TEST_FAILURE,"Wrong number of configurations"); 00065 return; 00066 } 00067 00068 for (TD_Config i=0;i<nConf;i++) { 00069 if (!pBR->isConfigurationHealthy(i)) { 00070 setTestResult(TEST_FAILURE,"Unexpected unhealthy configuration found"); 00071 return; 00072 } 00073 } 00074 00075 if (pBR->getActive()!=0) { 00076 setTestResult(TEST_FAILURE,"Wrong active configuration"); 00077 return; 00078 } 00079 00080 // We now test DC_BasicReconfigurer::setActive(). 00081 // First we try to set an out-of-range configuration 00082 // and verify the event reporting. 00083 if (isNonNominalCheckAllowed()) { 00084 pBR->setActive(nConf); 00085 if (!verifyLatestEvent(nEvt+1,EVT_ILLEGAL_CONFIG)) 00086 return; 00087 nEvt++; 00088 } 00089 00090 // Now we set the active configuration to a legal one and 00091 // verify the correctness of the active configuration value 00092 // and, once again, the event reporting. 00093 pBR->setActive(nConf-1); 00094 00095 if (pBR->getActive()!=nConf-1) { 00096 setTestResult(TEST_FAILURE,"Wrong active configuration"); 00097 return; 00098 } 00099 00100 if (!verifyLatestEvent(nEvt+1,EVT_RECONFIG)) 00101 return; 00102 nEvt++; 00103 00104 // We now test DC_BasicReconfigurer::setHealthStatus(). 00105 // Once again, we start by verify the error reporting, then 00106 // we check the nominal functionality. 00107 if (isNonNominalCheckAllowed()) { 00108 pBR->setHealthStatus(nConf,NOT_HEALTHY); 00109 if (!verifyLatestEvent(nEvt+1,EVT_ILLEGAL_CONFIG)) 00110 return; 00111 nEvt++; 00112 } 00113 00114 pBR->setHealthStatus(0,NOT_HEALTHY); 00115 if (pBR->isConfigurationHealthy(0)) { 00116 setTestResult(TEST_FAILURE,"Wrong configuration health status"); 00117 return; 00118 } 00119 00120 // We call reconfigure(). The call should fail (the reconfigurer 00121 // is still disabled). 00122 pBR->reconfigure(); 00123 if (!verifyLatestEvent(nEvt+1,EVT_RECONFIG_DISABLED)) 00124 return; 00125 nEvt++; 00126 00127 // We now enable it and try again. We also verify that the old 00128 // active configuration is set to NOT_HEALTHY and that the new 00129 // one is HEALTHY. 00130 pBR->setEnabled(true); 00131 pBR->reconfigure(); 00132 00133 if (!verifyLatestEvent(nEvt+1,EVT_RECONFIG)) 00134 return; 00135 nEvt++; 00136 00137 if (pBR->isConfigurationHealthy(nConf-1)) { 00138 setTestResult(TEST_FAILURE,"Wrong configuration health status"); 00139 return; 00140 } 00141 00142 if (!pBR->isConfigurationHealthy(pBR->getActive())) { 00143 setTestResult(TEST_FAILURE,"Unhealthy active configuration"); 00144 return; 00145 } 00146 00147 // Let's set all the configurations to NOT_HEALTHY and verify that 00148 // reconfigure properly reports the error 00149 for (TD_Config i=0;i<nConf;i++) 00150 pBR->setHealthStatus(i,NOT_HEALTHY); 00151 00152 pBR->reconfigure(); 00153 00154 if (!verifyLatestEvent(nEvt+1,EVT_RECONFIG_NO_HEALTHY)) 00155 return; 00156 nEvt++; 00157 00158 // We now verify the behaviour of DC_BasicReconfigurer::reset(). 00159 // The reconfigurer is disabled and reset() is called. 00160 pBR->setEnabled(false); 00161 pBR->reset(); 00162 00163 // All the configurations should now be healhty, the active should be 00164 // the first and the reconfigurer should be enabled. 00165 if (!pBR->isEnabled()) { 00166 setTestResult(TEST_FAILURE,"Reset failed to enable reconfigurer"); 00167 return; 00168 } 00169 00170 if (pBR->getActive()!=0) { 00171 setTestResult(TEST_FAILURE,"Reset failed to set active configuration"); 00172 return; 00173 } 00174 00175 for (TD_Config i=0;i<nConf;i++) { 00176 if (!pBR->isConfigurationHealthy(i)) { 00177 setTestResult(TEST_FAILURE,"Reset failed to set the configuration status"); 00178 return; 00179 } 00180 } 00181 00182 setTestResult(TEST_SUCCESS,"Test Successful"); 00183 return; 00184 }
Copyright 2003 P&P Software GmbH - All Rights Reserved