00001
00002
00003
00004
00005
00006
00007
00008
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
00027
if (pBR->
getClassId()!=ID_BASICRECONFIGURER) {
00028 setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00029
return;
00030 }
00031
00032
00033
if (pBR->
isObjectConfigured()) {
00034 setTestResult(
TEST_FAILURE,
"Newly created reconfigurer is configured");
00035
return;
00036 }
00037
00038
00039
if (!pBR->
isEnabled()) {
00040 setTestResult(
TEST_FAILURE,
"Newly created reconfigurer is not enabled");
00041
return;
00042 }
00043
00044
00045 pBR->
setEnabled(
false);
00046
if (pBR->
isEnabled()) {
00047 setTestResult(
TEST_FAILURE,
"Can't chenge enable status");
00048
return;
00049 }
00050
00051
00052 pBR->
setNumberOfConfigurations(nConf);
00053
00054
00055
if (!pBR->
isObjectConfigured()) {
00056 setTestResult(
TEST_FAILURE,
"Reconfigurer not configured");
00057
return;
00058 }
00059
00060
00061
00062
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
00081
00082
00083
if (
isNonNominalCheckAllowed()) {
00084 pBR->
setActive(nConf);
00085
if (!verifyLatestEvent(nEvt+1,EVT_ILLEGAL_CONFIG))
00086
return;
00087 nEvt++;
00088 }
00089
00090
00091
00092
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
00105
00106
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
00121
00122 pBR->
reconfigure();
00123
if (!verifyLatestEvent(nEvt+1,EVT_RECONFIG_DISABLED))
00124
return;
00125 nEvt++;
00126
00127
00128
00129
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
00148
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
00159
00160 pBR->
setEnabled(
false);
00161 pBR->
reset();
00162
00163
00164
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 }