| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2018 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_LGenBase_Test_PhaseTestcases |
| // |
| // Purpose: |
| // This module provides functions for testing MultiplePhase functionality of LGenBase |
| // |
| // Module depends on: |
| // - |
| // |
| // Current Owner: |
| // Jeno Balasko (ETHBAAT) |
| // |
| // Last Review Date: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_LGenBase_Test_PhaseTestcases |
| { |
| import from EPTF_LGenBase_Test_Definitions all; |
| import from EPTF_LGenBase_Test_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LGenBase_Functions all; |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_PhaseDefinitions all; |
| import from EPTF_CLL_LGenBase_PhaseFunctions all; |
| import from EPTF_CLL_LGenBase_PhaseConfigFunctions all; |
| import from EPTF_CLL_LGenBase_TemplateDefinitions all; |
| import from EPTF_CLL_LGenBase_TemplateFunctions all; |
| import from EPTF_CLL_LGenBase_TrafficFunctions all; |
| import from EPTF_CLL_LGenBase_StepFunctions all; |
| import from EPTF_CLL_LGenBase_EventHandlingFunctions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| |
| modulepar |
| { |
| EPTF_LGenBase_PhaseList_Declarators tsp_EPTF_LGenBase_PhaseList_Declarators := {}; |
| } |
| |
| const charstring c_scName:="Sc1"; |
| const charstring c_egName:="egPhaseTest"; |
| const charstring c_preamblePhase:="preamble" |
| |
| group Functions { |
| |
| //=============================================== |
| // f_LGenBase_Test_groupFinishFunction |
| //=============================================== |
| function f_LGenBase_Test_groupFinishFunction(in integer pl_idx) |
| runs on EPTF_LGenBase_Test_CT{ |
| log("--- Traffic case ",f_EPTF_LGenBase_getTcUniqueNameByTcIdx(pl_idx)," has finished.") |
| } |
| |
| //=============================================== |
| // f_LGenBase_Test_checkPhaseFinish |
| //=============================================== |
| function f_LGenBase_Test_checkPhaseFinish( |
| in charstring pl_eGrpName, |
| in charstring pl_scName, |
| in charstring pl_phase, |
| in EPTF_IntegerList pl_args) |
| runs on EPTF_LGenBase_Test_CT { |
| v_LGenBase_testFinished := true |
| log(%definitionId&"--- Phase finished with data: egpName: ",pl_eGrpName, " scname: ", pl_scName, " phase: ", pl_phase, " args: ", pl_args); |
| if( (pl_eGrpName==c_egName) and (pl_scName==c_scName) and (pl_phase== v_LGenBase_Test_actualPhase) ) { |
| setverdict(pass); |
| } else { |
| setverdict(fail); |
| } |
| v_LGenBase_testFinished := true |
| }//f_ |
| |
| //========================================= |
| // f_LGenBase_Test_getEmptyFsmWithSuccess |
| // The fsm increments the indexed counter then finishes the Tc by dispatching a "successful finish tc event" |
| //========================================= |
| function f_LGenBase_Test_getEmptyFsmWithSuccess(in integer pl_idx) |
| runs on EPTF_LGenBase_Test_CT |
| return EPTF_LGenBase_CompactFsmTable { |
| var EPTF_LGenBase_CompactFsmTable vl_fsm := { |
| name := "testFsm"&int2str(pl_idx), |
| // [0] |
| stateList := {"idle"}, |
| timerList := {}, |
| table := { |
| { |
| eventToListen := {c_EPTF_LGenBase_bIdx,c_EPTF_LGenBase_inputIdx_testMgmt_startTC,fsm}, |
| cellRow := { |
| //state[0]==idle |
| {{ |
| {refers(f_EPTF_LGenBase_Test_step_counter),{pl_idx}}, |
| {refers(f_EPTF_LGenBase_step_trafficSuccess),{}} |
| }, omit,omit} |
| } |
| } |
| } |
| } |
| return vl_fsm; |
| } |
| |
| //========================================= |
| // f_EPTF_LGenBase_Test_step_counter |
| //========================================= |
| function f_EPTF_LGenBase_Test_step_counter(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_LGenBase_Test_CT { |
| log("--- counter pl_ptr:", pl_ptr); |
| //count: |
| v_registerCounterSucc:=v_registerCounterSucc+1; |
| v_LGenBase_Test_counters[pl_ptr.stepArgs[0]]:=v_LGenBase_Test_counters[pl_ptr.stepArgs[0]]+1; |
| log("--->Total Success Counter: ", v_registerCounterSucc); |
| log("--->Actual phase counter: ", v_LGenBase_Test_counters[pl_ptr.stepArgs[0]]); |
| } |
| //========================================= |
| // f_LGenBase_Test_phaseTestInit_Part1 |
| //========================================= |
| function f_LGenBase_Test_phaseTestInit_Part1(in integer pl_count := 4) |
| runs on EPTF_LGenBase_Test_CT { |
| f_EPTF_LGenBase_Test_init("PhaseTest", imst); |
| f_EPTF_LGenBase_PhaseList_Declarators_store(tsp_EPTF_LGenBase_PhaseList_Declarators); |
| v_LGenBase_Test_counters:={}; |
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("bhPhaseTest", tsp_nrOfEntities, |
| null, |
| null, |
| null); |
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("etPhaseTest", {"bhPhaseTest"}); |
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({c_egName, "etPhaseTest", tsp_nrOfEntities}); |
| v_dummyInt := f_EPTF_LGenBase_declareFunction("groupFinishFunction", |
| { |
| customFinishFunction := refers(f_LGenBase_Test_groupFinishFunction) |
| }); |
| |
| for(var integer i:=0;i<pl_count;i:=i+1) { |
| v_LGenBase_Test_counters[i]:=0; |
| v_dummyInt := f_EPTF_LGenBase_declareCompactFsmTable(f_LGenBase_Test_getEmptyFsmWithSuccess(i)); |
| v_dummyInt := f_EPTF_LGenBase_declareTcType({ |
| name := "tcPhaseTest"&int2str(i), |
| fsmName := "testFsm"&int2str(i), |
| entityType := "etPhaseTest", |
| customEntitySucc := "", |
| groupFinishConditions := { |
| nrOfExecStart := omit, |
| nrOfSuccesses := omit, |
| nrOfFails := omit, |
| nrOfGrpLoop := omit, |
| nrOfRangeLoop := omit, |
| execTime := omit, |
| customFinishCondition := omit |
| }, |
| entityFinishConditions := { |
| nrOfExecStart := omit, |
| nrOfSuccesses := 1, |
| nrOfFails := omit, |
| customFinishCondition := omit |
| }, |
| groupFinishActions := { |
| { |
| disableTc := { |
| tcName := "tcPhaseTest"&int2str(i) |
| } |
| }, |
| { |
| customFinishFunction := "groupFinishFunction" |
| } |
| }, |
| entityFinishActions := { }, |
| params := {} |
| }); |
| }//for |
| }//f_ |
| //========================================= |
| // f_LGenBase_Test_phaseTestInit |
| //========================================= |
| function f_LGenBase_Test_phaseTestInit() |
| runs on EPTF_LGenBase_Test_CT { |
| |
| f_LGenBase_Test_phaseTestInit_Part1(); |
| |
| var EPTF_LGenBase_TcOfScenarioDeclaratorList vl_tcList:={}; |
| for(var integer i:=0;i<4;i:=i+1) { |
| vl_tcList[i]:= { |
| tcName := "tcPhaseTest"&int2str(i), |
| tcParamsList := { |
| {startDelay := 0.1}, |
| {target := {cpsToReach := tsp_cps}}, |
| {scheduler := { preDefinedName := orig }}, |
| {enableEntitiesAtStart := true}, //????? |
| {enabledAtStart := true}, |
| {trafficStartFinish := { |
| {nrOfSuccesses := {tsp_nrOfEntities,{}}}} |
| }, |
| {entityFinishConditions := {{nrOfSuccesses := 1}}}} |
| } |
| |
| }//for |
| |
| var EPTF_LGenBase_TcMgmt_PhaseFinishConditionList vl_phaseFinishConditions :={}; |
| var EPTF_LGenBase_TcMgmt_PhaseActionList vl_phaseStateChangeActions :={}; |
| vl_phaseFinishConditions := { |
| { |
| phase := "init", |
| conditions := { |
| {tcFinished := "tcPhaseTest0"} |
| } |
| }, |
| { |
| phase := "preamble", |
| conditions := { |
| {tcFinished := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| conditions := { |
| {tcFinished := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "postamble", |
| conditions := { |
| {tcFinished := "tcPhaseTest3"} |
| } |
| }, |
| { |
| phase := "delete", |
| conditions := { |
| {tcFinished := "tcPhaseTest3"} |
| } |
| } |
| }//vl_ |
| |
| vl_phaseStateChangeActions:= { |
| { |
| phase := "init", |
| state := RUNNING, |
| actions := { |
| {startTc := "tcPhaseTest0"} |
| } |
| }, |
| { |
| phase := "init", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest0"} |
| } |
| }, |
| { |
| phase := "preamble", |
| state := RUNNING, |
| actions := { |
| {startTc := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "preamble", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| state := RUNNING, |
| actions := { |
| {startTc := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "postamble", |
| state := RUNNING, |
| actions := { |
| {stopScenario := ""} |
| } |
| }, |
| { |
| phase := "delete", |
| state := RUNNING, |
| actions := { |
| {stopScenario := ""} |
| } |
| } |
| }; |
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3({ |
| name := c_scName, |
| tcList := vl_tcList, |
| scParamsList := { |
| {enabled :=true}, |
| {phaseListName := "AdvancedPhases"}, |
| {phaseFinishConditions:=vl_phaseFinishConditions}, |
| {phaseStateChangeActions:=vl_phaseStateChangeActions} |
| }}); |
| |
| }//f_ |
| |
| //=========================================== |
| // f_LGenBase_Test_phaseTestInit_TCsTogether |
| //=========================================== |
| function f_LGenBase_Test_phaseTestInit_TCsTogether() |
| runs on EPTF_LGenBase_Test_CT { |
| |
| f_LGenBase_Test_phaseTestInit_Part1(3); |
| //v_dummyInt := f_EPTF_LGenBase_declareFunction("Finished",{customFinishFunction := refers(f_EPTF_LGenBase_TestFinished)}); |
| f_EPTF_LGenBase_PhaseList_Declarators_store( |
| { |
| { |
| name := "TCsTogetherPhases", |
| phases := |
| { |
| { name := "init", enabled := true }, |
| { name := "preamble", enabled := true }, |
| { name := "loadgen" , enabled := true } |
| } |
| } |
| } |
| ); |
| |
| var EPTF_LGenBase_TcOfScenarioDeclaratorList vl_tcList:={}; |
| for(var integer i:=0;i<3;i:=i+1) { |
| vl_tcList[i]:= { |
| tcName := "tcPhaseTest"&int2str(i), |
| tcParamsList := { |
| {startDelay := 0.1}, |
| {target := {cpsToReach := tsp_cps}}, |
| {scheduler := { preDefinedName := orig }}, |
| {enableEntitiesAtStart := true}, //????? |
| {enabledAtStart := false}, |
| {trafficStartFinish := { |
| {nrOfExecStart := {tsp_nrOfEntities,{}}}} |
| }, |
| //{trafficFinishedActions := {{customFinishFunction := "Finished"}}}, |
| {entityFinishConditions := { |
| {nrOfSuccesses := 1}} |
| } |
| } |
| }; |
| |
| }//for |
| |
| var EPTF_LGenBase_TcMgmt_PhaseFinishConditionList vl_phaseFinishConditions :={}; |
| var EPTF_LGenBase_TcMgmt_PhaseActionList vl_phaseStateChangeActions :={}; |
| vl_phaseFinishConditions := { |
| { |
| phase := "init", |
| conditions := { |
| {tcFinished := "tcPhaseTest0"}, |
| {tcFinished := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "preamble", |
| conditions := { |
| {tcFinished := "tcPhaseTest0"}, |
| {tcFinished := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| conditions := { |
| {tcFinished := "tcPhaseTest2"} |
| } |
| } |
| }//vl_ |
| |
| vl_phaseStateChangeActions:= { |
| { |
| phase := "init", |
| state := RUNNING, |
| actions := { |
| {startTc := "tcPhaseTest0"}, |
| {startTc := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "init", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest0"}, |
| {stopTc := "tcPhaseTest1"} |
| } |
| }, |
| { |
| phase := "preamble", |
| state := RUNNING, |
| actions := { |
| {restoreTc := "tcPhaseTest0"}, |
| {startTc := "tcPhaseTest0"}, |
| {startTc := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "preamble", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest0"}, |
| {stopTc := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| state := RUNNING, |
| actions := { |
| {restoreTc := "tcPhaseTest2"}, |
| {startTc := "tcPhaseTest2"} |
| } |
| }, |
| { |
| phase := "loadgen", |
| state := STOPPING, |
| actions := { |
| {stopTc := "tcPhaseTest2"} |
| } |
| } |
| }; |
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3({ |
| name := c_scName, |
| tcList := vl_tcList, |
| scParamsList := { |
| {enabled :=true}, |
| {phaseListName := "TCsTogetherPhases"}, |
| {phaseFinishConditions:=vl_phaseFinishConditions}, |
| {phaseStateChangeActions:=vl_phaseStateChangeActions}}}); |
| }//f_ |
| |
| //=========================================== |
| // f_LGenBase_Test_checkCounters |
| //=========================================== |
| function f_LGenBase_Test_checkCounters( |
| in EPTF_IntegerList pl_expectedCounters) |
| runs on EPTF_LGenBase_Test_CT |
| { |
| for ( var integer vl_i := 0; vl_i < sizeof(v_LGenBase_Test_counters) ; vl_i := vl_i+1 )
|
| {
|
| if(match(v_LGenBase_Test_counters,pl_expectedCounters)){ |
| setverdict(pass) |
| }else{ |
| log(v_LGenBase_Test_counters,pl_expectedCounters) |
| setverdict(fail) |
| } |
| }
|
| } |
| } |
| |
| group Testcases_Phase { |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_PhaseList |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_PhaseList_store, f_EPTF_LGenBase_PhaseList_get_byIndex, f_EPTF_LGenBase_PhaseList_get_byName |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_LGenBase_Test_CT |
| // 1. Stores a phase list declarator |
| // 2. Gets the store declarator by index |
| // 3. Checks if the original and the retrieved are the same. |
| // Expected Result: |
| // The check is true |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_PhaseList() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_EPTF_LGenBase_init("lGenBasePhaseTest", 0, "lGenBasePhaseTest#",orig); |
| var EPTF_LGenBase_PhaseList_Declarator vl_declarator1:= {"PD1",{}}, vl_declarator2:= {"PD2",{}}, vl_declarator3:= {"PD3",{}}, vl_declReturned:={"",{}}; |
| var integer vl_plIdx:=-1; |
| var boolean vl_retval:=false; |
| vl_plIdx:=f_EPTF_LGenBase_PhaseList_store(vl_declarator1); |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byIndex(vl_plIdx, vl_declReturned); |
| if(vl_retval and match(vl_declReturned,vl_declarator1)) { |
| setverdict(pass) |
| } else { |
| setverdict(fail); |
| log(match(vl_declReturned,vl_declarator1)) |
| } |
| |
| //=== store and getByIdx === |
| vl_plIdx:=f_EPTF_LGenBase_PhaseList_store(vl_declarator2); |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byIndex(vl_plIdx, vl_declReturned); |
| if(vl_retval and match(vl_declReturned,vl_declarator2)) { |
| setverdict(pass) |
| } else { |
| setverdict(fail); |
| log(match(vl_declReturned,vl_declarator3)) |
| } |
| vl_plIdx:=f_EPTF_LGenBase_PhaseList_store(vl_declarator3); |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byIndex(vl_plIdx, vl_declReturned); |
| if(vl_retval and match(vl_declReturned,vl_declarator3)) { |
| setverdict(pass) |
| } else { |
| setverdict(fail); |
| log(match(vl_declReturned,vl_declarator3)) |
| } |
| |
| //== get_ByName == |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byName("PD2",vl_declReturned) |
| if(vl_retval and match(vl_declReturned,vl_declarator2)) { |
| setverdict(pass) |
| } else { |
| setverdict(fail); |
| log(match(vl_declReturned,vl_declarator3)) |
| } |
| |
| //=== negative test === |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byIndex(/*sizeof(v_LGenBase_PhaseListDeclaratorDB.data)*/1000, vl_declReturned); |
| if(vl_retval) { setverdict(fail) } |
| vl_declReturned:={"",{}}; |
| vl_retval:=f_EPTF_LGenBase_PhaseList_get_byName("PD bubu",vl_declReturned) |
| if(vl_retval) { setverdict(fail); } |
| |
| if(f_EPTF_LGenBase_PhaseList_store(vl_declarator1)!=-1) { setverdict(fail); } |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_phaseIsValid |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase |
| // 9. Check if only the phase executed |
| // 10. Check if all entities executed exactly one times (nrOfSuccesses==number of entities) |
| // 11. Repeat step 8-10 for phases "idle", "preamble", "loadgen" which are enabled |
| // Expected Result: |
| // The checks are true |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_phaseIsValid() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| |
| var integer vl_scIdx := f_EPTF_LGenBase_scenarioAbsIdxByName(c_egName,c_scName); |
| |
| var EPTF_LGenBase_PhaseList_Declarator vl_declarator; |
| v_dummyBool := f_EPTF_LGenBase_PhaseList_get_byName("BasicPhases", vl_declarator); |
| log("Current PhaseList: ", vl_declarator); |
| |
| if(f_EPTF_LGenBase_phaseIsValid(vl_scIdx,"preamble")) { // phase declared |
| setverdict(pass); |
| } else { |
| setverdict(fail); |
| } |
| |
| if(f_EPTF_LGenBase_phaseIsValid(vl_scIdx,"bubu")) { // phase not declared |
| setverdict(fail); |
| } else { |
| setverdict(pass); |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StartPhase_enable |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase |
| // 9. Check if only the phase executed |
| // 10. Check if all entities executed exactly one times (nrOfSuccesses==number of entities) |
| // 11. Repeat step 8-10 for phases "idle", "preamble", "loadgen" which are enabled |
| // Expected Result: |
| // The checks are true |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_StartPhase_enable() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| timer t; |
| var EPTF_IntegerList vl_expectedCounters:={0,0,0,0} |
| for( var integer i:=0;i< 3;i:=i+1) { |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[i].name; |
| vl_expectedCounters[i]:= tsp_nrOfEntities; |
| v_dummyBool := f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase ", i, " started<<<") |
| t.start(tsp_execTime); |
| t.timeout; |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| //2. check: |
| if( tsp_cps*tsp_execTime>int2float(tsp_nrOfEntities)) { |
| f_EPTF_LGenBase_Test_setVerdictFromBool(v_LGenBase_Test_counters==vl_expectedCounters) |
| } else { |
| setverdict(pass) |
| } |
| }//for |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StartPhase_disable |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase |
| // 9. Check if only the phase executed |
| // 10. Check if all entities executed exactly zero times (nrOfSuccesses==number of entities) |
| // Expected Result: |
| // The checks are true |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_StartPhase_disable() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| var boolean vl_success:=false; |
| timer t; |
| //var EPTF_IntegerList vl_expectedCounters:={0,0,0,0} |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[3].name; |
| |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success); |
| log(">>>Phase 3 start result: ",vl_success); |
| t.start(tsp_execTime); |
| t.timeout; |
| |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| //2. check: |
| f_EPTF_LGenBase_Test_setVerdictFromBool(v_LGenBase_Test_counters[3]==0) |
| |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StopPhase_simple |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase "init" only |
| // 9. Check if only the phase executed, i.e if its fsm is increments its counter |
| // 10. After 1.9s check stop the phase |
| // 11. check if the counters are the same after 2s, 3s, 4s, 5s |
| // Expected Result: |
| // The checks are true |
| /////////////////////////////////////////////////////////// |
| |
| testcase tc_EPTF_LGenBase_Test_StopPhase_simple() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| |
| var integer vl_i:=0; |
| var boolean vl_success:=false; |
| |
| //Start Phase 0: |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name; |
| //vl_expectedCounters[vl_i]:= tsp_nrOfEntities; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase start result: ",vl_success); |
| log(">>>Phase ", vl_i, " started<<<"); |
| f_EPTF_LGenBase_Test_setGuard() |
| if(f_EPTF_LGenBase_wait4TestFinished()){ |
| //stops phase 0 |
| vl_success:=f_EPTF_LGenBase_stopPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase); |
| log(">>>Phase stop result: ",vl_success); |
| log(">>>Phase stopped: ", v_LGenBase_Test_actualPhase); |
| log(">>>>>Counters just after stop",v_LGenBase_Test_counters); |
| if( match(v_LGenBase_Test_counters[0],tsp_nrOfEntities)) { |
| setverdict(pass) |
| } else { |
| log(match(v_LGenBase_Test_counters[0],tsp_nrOfEntities)) |
| setverdict(fail) |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| }//tc_ |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StartStopPhase_complex |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase 0 at 2sec, phase 1 at 4sec, phase 2 at 5sec and phase 3 at 6sec. Check the success of the startPhase |
| // 9. After 5s and 7s stop the actual running phase |
| // 11. check the counters after 0s, 2s, 4s, 6s, 8s |
| // Expected result: |
| // 1.In step 8 the startPhases are all successful except of phase 2 (phase 1 is running still when it was started) |
| // 2.In step 9 the stopPhases are successful |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_StartStopPhase_complex() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| |
| timer t_1s :=2.0; |
| t_1s.start; |
| var EPTF_IntegerList vl_expectedCounters:={0,0,0,0}; |
| var boolean vl_success:=false; |
| alt { |
| [] t_1s.timeout {}; |
| } |
| // init phase 0 |
| vl_expectedCounters[0]:= tsp_nrOfEntities; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[0].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase start result: ",vl_success); |
| log(">>>Phase init started<<<"); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[0].name; |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==true) |
| t_1s.start(2.0); |
| alt { |
| [] t_1s.timeout {}; |
| } |
| // preamble phase 1 |
| vl_expectedCounters[1]:= tsp_nrOfEntities; |
| |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[1].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase start result: ",vl_success); |
| log(">>>Phase preamble started<<<"); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[1].name; |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==true) |
| t_1s.start(0.01); |
| alt { |
| [] t_1s.timeout {}; |
| } |
| // loadgen phase 2, preamble already running |
| vl_expectedCounters[2]:= tsp_nrOfEntities; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[2].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase start result: ",vl_success); |
| log(">>>Phase loadgen started<<<"); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==false) |
| |
| // stopping preamble |
| vl_success:=f_EPTF_LGenBase_stopPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase); |
| log(">>>Phase stop result: ",vl_success); |
| log(">>>Phase stopped: ", v_LGenBase_Test_actualPhase); |
| log(">>>>>Counters just after stop",v_LGenBase_Test_counters); |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==true); |
| vl_expectedCounters[1]:= v_LGenBase_Test_counters[1]; //freeze for the final comparison |
| t_1s.start(1.0); |
| alt { |
| [] t_1s.timeout {}; |
| } |
| // postamble phase 3 |
| vl_expectedCounters[3]:= tsp_nrOfEntities; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[3].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase start result: ",vl_success); |
| log(">>>Phase preamble started<<<"); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[3].name; |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==true) |
| t_1s.start(1.0); |
| alt { |
| [] t_1s.timeout {}; |
| } |
| // stopping postamble |
| vl_success:=f_EPTF_LGenBase_stopPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase); |
| log(">>>Phase stop result: ",vl_success); |
| log(">>>Phase stopped: ", v_LGenBase_Test_actualPhase); |
| log(">>>>>Counters just after stop",v_LGenBase_Test_counters); |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_success==true); |
| vl_expectedCounters[3]:= v_LGenBase_Test_counters[3]; //freeze for the final comparison |
| t_1s.start(1.0); |
| alt { |
| [] t_1s.timeout {}; |
| } |
| |
| log(">>>Bye: All phases used<<<"); |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StartStopPhase_TCsTogether |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase 0 at 0sec, phase 1 at 2sec, phase 2 at 4sec and phase 3 at 6sec. Check the success of the startPhase |
| // 9. After 2s 4s 6s 8s stop the actual phase |
| // 11. check the counters after 0s, 2s, 4s, 6s, 8s |
| // Expected result: |
| // 1.In step 8 the startPhases are all successful |
| // 2.In step 9 the stopPhases are successful |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LGenBase_Test_StartStopPhase_TCsTogether() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit_TCsTogether(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| |
| //for( var integer i:=0;i< 3;i:=i+1) { |
| var integer vl_i:=0; |
| var boolean vl_success:=false; |
| |
| //Phase0: |
| v_LGenBase_Test_actualPhase:= tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase ",vl_i, " start result: ",vl_success); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| var integer vl_index:=-1; |
| f_EPTF_LGenBase_Test_setGuard() |
| while(true){ |
| if(f_EPTF_LGenBase_wait4TestFinished()){ |
| //====== Stop phase ============= |
| vl_success:=f_EPTF_LGenBase_stopPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase); |
| log(">>>Phase stop result: ",vl_success); |
| log(">>>Phase stopped: ", v_LGenBase_Test_actualPhase); |
| log(">>>>>Counters just after stop",v_LGenBase_Test_counters); |
| select(v_LGenBase_Test_actualPhase) { |
| case("init") { vl_index :=0} |
| case("preamble") {vl_index:=1} |
| case("loadgen") {vl_index:=2} |
| //case("postamble"){vl_index:=3} |
| //case("delete") {vl_index:=4} |
| } |
| select(vl_index) { |
| case(0) { |
| f_LGenBase_Test_checkCounters({tsp_nrOfEntities, tsp_nrOfEntities, 0}); |
| } |
| case(1) { |
| f_LGenBase_Test_checkCounters({tsp_nrOfEntities*2, tsp_nrOfEntities, tsp_nrOfEntities}); |
| }; |
| case(2) { |
| f_LGenBase_Test_checkCounters({tsp_nrOfEntities*2, tsp_nrOfEntities, tsp_nrOfEntities*2}); |
| } |
| } |
| //====== Start next phase: ====== |
| vl_i:=vl_i+1; |
| if( vl_i<3) { |
| log("New phase name to be started: ",tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name); |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase ",vl_i, " start result: ",vl_success); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| if(vl_success) { |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name; |
| } else { |
| setverdict(fail); |
| } |
| }else{ |
| log(">>>Bye 1: All phases used<<<"); |
| f_EPTF_Base_stop(pass) |
| //stop, exit from the altstep |
| } |
| }else{ |
| log(">>>Bye 2 with t timeout<<<"); |
| setverdict(fail); |
| } |
| }//alt |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LGenBase_Test_StartStopPhase_TCsTogether_WeightedSc |
| // |
| // |
| // Purpose: |
| // To test f_EPTF_LGenBase_startPhase |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // 1. Declare a behavior type (bt) |
| // 2. Declare an entity type (et) |
| // 3. Create an entity group (eg) |
| // 4. Create a group finish function (fg) |
| // 5. Create a phase finish function (fph) |
| // 6. Create 4 fsm tables, 4 traffic case types with entity finish cond: nrOfSuccesses := 1 group finish cond: nrOfSuccesses := tsp_nrOfEntities |
| // 7. Create a scenario instance from eg and the traffic cases and with 5 phases. |
| // 8. Start the phase 0 at 0sec, phase 1 at 2sec, phase 2 at 4sec and phase 3 at 6sec. Check the success of the startPhase |
| // 9. After 2s 4s 6s 8s stop the actual phase |
| // 11. check the counters after 0s, 2s, 4s, 6s, 8s |
| // Expected result: |
| // 1.In step 8 the startPhases are all successful |
| // 2.In step 9 the stopPhases are successful |
| /////////////////////////////////////////////////////////// |
| //State: Started NOT READY at all |
| |
| /* testcase tc_EPTF_LGenBase_Test_StartStopPhase_TCsTogether_WeightedSc() |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_phaseTestInit_TCsTogether(); |
| f_EPTF_LGenBase_createScenario2EntityGroup({c_egName,c_scName}); |
| |
| timer t; |
| t.start(tsp_execTime); |
| |
| timer t_1s :=2.0; |
| t_1s.start; |
| var EPTF_IntegerList vl_expectedCounters:={0,0,0,0}; |
| //for( var integer i:=0;i< 3;i:=i+1) { |
| var integer vl_i:=0; |
| var boolean vl_success:=false; |
| |
| //Phase0: |
| v_LGenBase_Test_actualPhase:= tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name; |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase ",vl_i, " start result: ",vl_success); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| var integer vl_index:=-1; |
| |
| alt { |
| [] t_1s.timeout { |
| //====== Stop phase ============= |
| vl_success:=f_EPTF_LGenBase_stopPhase( |
| c_egName, |
| c_scName, |
| v_LGenBase_Test_actualPhase); |
| log(">>>Phase stop result: ",vl_success); |
| log(">>>Phase stopped: ", v_LGenBase_Test_actualPhase); |
| log(">>>>>Counters just after stop",v_LGenBase_Test_counters); |
| select(v_LGenBase_Test_actualPhase) { |
| case("init") { vl_index :=0} |
| case("preamble") {vl_index:=1} |
| case("loadgen") {vl_index:=2} |
| case("postamble"){vl_index:=3} |
| case("delete") {vl_index:=4} |
| } |
| select(vl_index) { |
| case(0) { |
| vl_expectedCounters[0]:= v_LGenBase_Test_counters[0]; |
| vl_expectedCounters[1]:= v_LGenBase_Test_counters[1]; |
| f_EPTF_LGenBase_Test_setVerdictFromBool( |
| vl_expectedCounters[0]>0 and vl_expectedCounters[1]>0); |
| } |
| case(1) { |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_expectedCounters[0]==v_LGenBase_Test_counters[0]); |
| vl_expectedCounters[0]:= v_LGenBase_Test_counters[0]; |
| vl_expectedCounters[2]:= v_LGenBase_Test_counters[2]; |
| f_EPTF_LGenBase_Test_setVerdictFromBool( |
| vl_expectedCounters[0]>0 and vl_expectedCounters[2]>0) |
| }; |
| case(2) { |
| f_EPTF_LGenBase_Test_setVerdictFromBool(vl_expectedCounters[2]==v_LGenBase_Test_counters[2]); |
| vl_expectedCounters[2]:= v_LGenBase_Test_counters[2] |
| } |
| } |
| f_LGenBase_Test_checkCounters(vl_expectedCounters); |
| //====== Start next phase: ====== |
| vl_i:=vl_i+1; |
| if( vl_i<5) { |
| log("New phase name to be started: ",tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name); |
| vl_success:=f_EPTF_LGenBase_startPhase( |
| c_egName, |
| c_scName, |
| tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name, |
| pl_fn:=refers(f_LGenBase_Test_checkPhaseFinish)); |
| log(">>>Phase ",vl_i, " start result: ",vl_success); |
| log(">>>>>Counters: ",v_LGenBase_Test_counters); |
| if(vl_success) { |
| v_LGenBase_Test_actualPhase:=tsp_EPTF_LGenBase_PhaseList_Declarators[1].phases[vl_i].name; |
| } else { |
| setverdict(fail); |
| } |
| t_1s.start(2.0); |
| repeat; |
| } |
| else |
| { |
| log(">>>Bye 1: All phases used<<<"); |
| //stop, exit from the altstep |
| } |
| } |
| [] t.timeout { log(">>>Bye 2 with t timeout<<<"); |
| f_LGenBase_Test_checkCounters(vl_expectedCounters) |
| } |
| }//alt |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| */ |
| |
| //Private functions: |
| // function f_EPTF_LGenBase_resetAllPhase |
| // function f_EPTF_LGenBase_resetAllPhaseByIdx |
| // function f_EPTF_LGenBase_getActualPhase |
| // function f_EPTF_LGenBase_getPhaseActions |
| // function f_EPTF_LGenBase_getActualPhaseActions |
| // function f_EPTF_LGenBase_getPhaseFinishConditions |
| // function f_EPTF_LGenBase_getActualPhaseFinishConditions |
| // function f_EPTF_LGenBase_setPhaseAndState |
| // function f_EPTF_LGenBase_setPhaseAndStateByIdx |
| // function f_EPTF_LGenBase_callPhaseActions |
| // function f_EPTF_LGenBase_callPhaseFinishConditions |
| // function f_EPTF_LGenBase_defaultPhaseFinished |
| |
| |
| }//group |
| |
| control { |
| execute(tc_EPTF_LGenBase_Test_PhaseList()); |
| execute(tc_EPTF_LGenBase_Test_phaseIsValid()); |
| execute(tc_EPTF_LGenBase_Test_StartPhase_enable()); |
| execute(tc_EPTF_LGenBase_Test_StartPhase_disable()); |
| execute(tc_EPTF_LGenBase_Test_StopPhase_simple()); |
| execute(tc_EPTF_LGenBase_Test_StartStopPhase_complex()); |
| execute(tc_EPTF_LGenBase_Test_StartStopPhase_TCsTogether()); |
| } |
| |
| }//module |