| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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 // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // |
| // Purpose: |
| // This module provides functions for testing functionalities and bugfixes |
| // after version R14 of LGenBase |
| // |
| // Module depends on: |
| // - |
| // |
| // Current Owner: |
| // Janos Zoltan Svaner (EJNOSVN) |
| // |
| // Last Review Date: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_LGenBase_Test_Testcases_Latest |
| // [.objid{ itu_t(0) identified_organization(4) etsi(0) |
| // identified_organization(127) ericsson(5) testing(0) |
| // <put further nodes here if needed>}] |
| { |
| import from EPTF_LGenBase_Test_Definitions all; |
| import from EPTF_LGenBase_Test_Functions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_ILog_Functions all; |
| import from EPTF_CLL_Logging_Functions all; |
| import from EPTF_CLL_LGenBase_ILog_Functions all; |
| import from EPTF_CLL_LGenBase_Functions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_EventHandlingFunctions all; |
| import from EPTF_CLL_LGenBase_TrafficFunctions all; |
| import from EPTF_CLL_LGenBase_TemplateDefinitions all; |
| import from EPTF_CLL_LGenBase_TemplateFunctions all; |
| import from EPTF_CLL_LGenBase_StepFunctions all; |
| import from PIPEasp_PortType all; |
| import from PIPEasp_Types all; |
| |
| modulepar |
| { |
| charstring tsp_dummyTemplatePathArithmetic := "../dummy_templ_arith.txt"; |
| charstring tsp_dummyTemplatePathArithmetic_dos := "./dummy_templ_arith_dos.txt"; |
| } |
| |
| group LGenBase_DataSource_tests{ |
| |
| /////////////////////////////////////////////////////////// |
| // TesScase: tc_LGenBase_DS_Neg_WrongConditionIsScPresent1 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsScPresent |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsScPresent1() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsScPresent, |
| {}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // TesScase: tc_LGenBase_DS_Neg_WrongConditionIsScPresent2 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsScPresent |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsScPresent2() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsScPresent, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // TesScase: tc_LGenBase_DS_Neg_WrongConditionIsScPresent3 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsScPresent |
| // Params: too many params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsScPresent3() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsScPresent, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"},{c_LGenBase_paramNameScenario, "eg2"},{c_LGenBase_paramNameEntityGroup, "eg3"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongConditionIsTcPresent1 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsTcPresent |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsTcPresent1() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsTcPresent, |
| {}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongConditionIsTcPresent2 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsTcPresent |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsTcPresent2() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsTcPresent, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongConditionIsTcPresent3 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionIsTcPresent |
| // Params: too many params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionIsTcPresent3() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionIsTcPresent, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"},{c_LGenBase_paramNameScenario, "eg2"},{c_LGenBase_paramNameEntityGroup, "eg3"}, {c_LGenBase_paramNameEntityGroup, "eg4"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup1 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: dataElementTcEnabledAtStartup |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup1() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_dataElementTcEnabledAtStartup, |
| {}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup2 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: dataElementTcEnabledAtStartup |
| // Params: too few params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup2() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_dataElementTcEnabledAtStartup, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup3 |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: dataElementTcEnabledAtStartup |
| // Params: too many params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup3() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_dataElementTcEnabledAtStartup, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"},{c_LGenBase_paramNameScenario, "eg2"},{c_LGenBase_paramNameEntityGroup, "eg3"}, {c_LGenBase_paramNameEntityGroup, "eg4"}}); |
| } |
| |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_ILog_tests |
| // |
| // Purpose: Test of the EPTF_CLL_LGenBase_ILog CLL functions. |
| // |
| // Action: The testcase . |
| // |
| // Expected Result: pass verdict. The test result is pass if all function operates without any error. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_ILog_tests() runs on EPTF_LGenBase_Test_CT { |
| |
| // Init |
| // --------------------------------------------------------------------------------------------------------- |
| f_EPTF_LGenBase_init(c_ILog_testName); |
| |
| // Just Magic 8> |
| // BehaviorType |
| v_ILog_behavOK := f_EPTF_LGenBase_declareBehaviorType(c_ILog_behavName, -1, null, null, null); |
| // FSM event |
| v_ILog_action := f_EPTF_LGenBase_declareFsmEvent(c_ILog_behavName, c_ILog_action); |
| // Entity |
| v_dummyInt := f_EPTF_LGenBase_declareEntityType(c_ILog_entityType, {c_ILog_behavName}); |
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({c_ILog_entityGroup, c_ILog_entityType, 2}); |
| // FSM |
| var integer vl_tIdx := f_EPTF_LGenBase_declareCompactFsmTable({ |
| name := "iLogTestFsm", |
| // [0] |
| stateList := {"idle"}, |
| timerList := {}, |
| table := { |
| {eventToListen := {v_ILog_behavOK,v_ILog_action,fsm}, |
| cellRow := { |
| //state[0]==idle |
| {{{refers(f_EPTF_ILog_Test_msgStep),{}}}, omit,0} |
| } |
| } |
| } |
| } |
| ); |
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= c_ILog_entityIdx1, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1) |
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= c_ILog_entityIdx2, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1) |
| |
| // ILog log DB: |
| var EPTF_LGenBase_TestStepArgs vl_testStepArgs1; |
| vl_testStepArgs1.eIdx := c_ILog_entityIdx1; |
| vl_testStepArgs1.refContext.fCtxIdx := vl_tIdx; |
| var EPTF_LGenBase_TestStepArgs vl_testStepArgs2; |
| vl_testStepArgs2.eIdx := c_ILog_entityIdx2; |
| vl_testStepArgs2.refContext.fCtxIdx := vl_tIdx; |
| |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // Calls <f_EPTF_ILogBase_register_DB>. |
| v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1] := f_EPTF_ILog_register_DB(refers(f_EPTF_ILog_Test_logItem), {c_ILog_entityIdx1}); |
| v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx2] := f_EPTF_ILog_register_DB(refers(f_EPTF_ILog_Test_logItem), {c_ILog_entityIdx2}); |
| |
| // [1]: new chain add one element and log it with logFailed |
| // --------------------------------------------------------------------------------------------------------- |
| // This function creates a new chains or reuses an existing free chains for short and detailed chains. |
| // Sets the elements of the application data assigned to the FSM context. |
| action("f_EPTF_LGenBase_ILog_newChains->"); |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| |
| // getcheck |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| action("f_EPTF_LGenBase_ILog_addToChains->"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| // logFailed STEP |
| // The function creates the log from the items of the short and detailed chain. |
| action("f_EPTF_LGenBase_ILog_step_logFailed->"); |
| f_EPTF_LGenBase_ILog_step_logFailed(vl_testStepArgs1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // GET LOG STR |
| var charstring vl_logStr0 := f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx1); |
| const charstring cl_loxExpected0 := "<<[FIRST:short] ILogHeader: 1 - Short Chain - 0>>"& |
| "<<[FIRST:detailed] ILogHeader: 2 - Detailed Chain - 0>>"& |
| "{EPTF_ILog_Test: Event in chain#2 - 1 [0]: Detailed Chain ({ 0 }): addToILog[0, 0]}"; |
| |
| action("GET LOG STR[0]:", vl_logStr0); |
| if(match ( vl_logStr0, cl_loxExpected0 ) == false) { |
| setverdict(fail, "Log[0] not mach: " & log2str(match ( vl_logStr0, cl_loxExpected0 ))); |
| } |
| |
| action("GET LOG STR:", f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx1)); |
| |
| // reset DB & Log |
| f_EPTF_ILog_Test_resetDB(); |
| f_EPTF_ILog_Test_resetLog(); |
| |
| // [2]: one add to chain without new chain => warning and logSuccess |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_LGenBase_ILog_addToChains->"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // [3] log success without valid chain |
| // --------------------------------------------------------------------------------------------------------- |
| // logSuccess STEP |
| // The function creates the log from the items of the short chain and deletes it from the detailed chain. |
| action("f_EPTF_LGenBase_ILog_step_logSuccess->"); |
| f_EPTF_LGenBase_ILog_step_logSuccess(vl_testStepArgs1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // GET LOG STR |
| action(f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx1)); |
| |
| // [4] delete log without valid chain |
| // --------------------------------------------------------------------------------------------------------- |
| // deleteLog STEP |
| // The function deletes the log from the items of the short and detailed chain. |
| action("f_EPTF_LGenBase_ILog_step_deleteLog->"); |
| f_EPTF_LGenBase_ILog_step_deleteLog(vl_testStepArgs1); |
| action("GETERRORMSG:", f_EPTF_Common_getErrorMsg()); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // [5] shortlog next without valid chain |
| // --------------------------------------------------------------------------------------------------------- |
| // shortLogNext STEP |
| // Sets an element of the application data assigned to the FSM context: enable short log |
| action("f_EPTF_LGenBase_ILog_step_shortLogNext->"); |
| f_EPTF_LGenBase_ILog_step_shortLogNext(vl_testStepArgs1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // [6] disable shortlog vithout valid chain |
| // --------------------------------------------------------------------------------------------------------- |
| // disableShortLog STEP |
| // Disable short log: sets an element of the application data assigned to the FSM context. |
| action("f_EPTF_LGenBase_ILog_disableShortLog->"); |
| f_EPTF_LGenBase_ILog_disableShortLog(vl_testStepArgs1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // [7] new chain for second header and log failed vithout log data |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_LGenBase_ILog_newChains->"); |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx2, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_second_detailed), pl_paramDetailed := {c_ILog_entityIdx2, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_second_short), pl_paramShort := {c_ILog_entityIdx2, vl_tIdx}); |
| |
| // getcheck |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, 1); |
| |
| // logFailed STEP |
| action("f_EPTF_LGenBase_ILog_step_logFailed->"); |
| f_EPTF_LGenBase_ILog_step_logFailed(vl_testStepArgs2); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, -1); |
| |
| // [8] paralell log in 2 independent chain |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_LGenBase_ILog_newChains[1]->"); |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| action("f_EPTF_LGenBase_ILog_newChains[2]->"); |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx2, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_second_detailed), pl_paramDetailed := {c_ILog_entityIdx2, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_second_short), pl_paramShort := {c_ILog_entityIdx2, vl_tIdx}); |
| |
| // reset DB & Log |
| f_EPTF_ILog_Test_resetDB(); |
| f_EPTF_ILog_Test_resetLog(); |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->0"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx1); // addToILog[0, 0] => 1:detailed |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| // shortLogNext STEP |
| action("f_EPTF_LGenBase_ILog_step_shortLogNext[1]->1"); |
| f_EPTF_LGenBase_ILog_step_shortLogNext(vl_testStepArgs1); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->1"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx1); // addToILog[0, 1] => 1:detailed + short |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[2]->0"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs2, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx2]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx2); // addToILog[1, 0] => 2:detailed |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, 3); |
| |
| // shortLogNext STEP |
| action("f_EPTF_LGenBase_ILog_step_shortLogNext[2]->1"); |
| f_EPTF_LGenBase_ILog_step_shortLogNext(vl_testStepArgs2); |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, 3); |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->2"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx1); // addToILog[0, 2] => 1: detailed |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, 1); |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[2]->1"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs2, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx2]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, c_ILog_entityIdx2); // addToILog[1, 1] => 2: detailed + short |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, 3); |
| |
| // logSuccess STEP |
| action("f_EPTF_LGenBase_ILog_step_logSuccess[1]->"); |
| f_EPTF_LGenBase_ILog_step_logSuccess(vl_testStepArgs1); // 1: short => |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx1, vl_tIdx, -1); |
| |
| // logFailed STEP |
| action("f_EPTF_LGenBase_ILog_step_logFailed[2]->"); |
| f_EPTF_LGenBase_ILog_step_logFailed(vl_testStepArgs2); // 2: short + detailed |
| f_EPTF_ILog_Test_getCheckChainId(c_ILog_entityIdx2, vl_tIdx, -1); |
| |
| // GET LOG STR[1] |
| var charstring vl_logSt1 := f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx1); |
| const charstring cl_loxExpected1 := "<<[FIRST:short] ILogHeader: 1 - Short Chain - 0>>"& |
| "{EPTF_ILog_Test: Event in chain#1 - 1 [1]: Short Chain ({ 0 }): addToILog[0, 1]}"& |
| // FIXME: fix artf235361 because in f_EPTF_LGenBase_ILog_addToChains->f_EPTF_LGenBase_ILog_addToChainsBase the |
| // f_EPTF_LGenBase_ILog_disableShortLogBase has been commented out, otherwise this line is not logged |
| "{EPTF_ILog_Test: Event in chain#1 - 1 [2]: Short Chain ({ 0 }): addToILog[0, 2]}"; |
| action("GET LOG STR[1]:", vl_logSt1); |
| if(match ( vl_logSt1, cl_loxExpected1 ) == false) { |
| setverdict(fail, "Log[1] not match: " & log2str(match ( vl_logSt1, cl_loxExpected1 ))); |
| } |
| |
| // GET LOG STR[2] |
| var charstring vl_logSt2 := f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx2); |
| action("f_EPTF_ILog_Test_getLogStr[2]->", vl_logSt2); |
| const charstring cl_loxExpected2 := "<<[SECOND:short] ILogHeader: 3 - Short Chain - 1>>"& |
| "{EPTF_ILog_Test: Event in chain#3 - 2 [1]: Short Chain ({ 1 }): addToILog[1, 1]}"& |
| "<<[SECOND:detailed] ILogHeader: 4 - Detailed Chain - 1>>"& |
| "{EPTF_ILog_Test: Event in chain#4 - 2 [0]: Detailed Chain ({ 1 }): addToILog[1, 0]}"& |
| "{EPTF_ILog_Test: Event in chain#4 - 2 [1]: Detailed Chain ({ 1 }): addToILog[1, 1]}"; |
| action("GET LOG STR[2]:", vl_logSt2); |
| if(match ( vl_logSt2, cl_loxExpected2 ) == false) { |
| setverdict(fail, "Log[2] not match: " & log2str(match ( vl_logSt2, cl_loxExpected2 ))); |
| } |
| |
| |
| // Cleanup |
| // --------------------------------------------------------------------------------------------------------- |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_ILog_negative_tests |
| // |
| // Purpose: Negative tests of the EPTF_CLL_LGenBase_ILog CLL functions. |
| // |
| // Action: The testcase . |
| // |
| // Expected Result: pass verdict. The test result is pass if all function operates without any error. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_ILog_negative_tests() runs on EPTF_LGenBase_Test_CT { |
| |
| // Init |
| // --------------------------------------------------------------------------------------------------------- |
| f_EPTF_LGenBase_init(c_ILog_testName); |
| |
| // Just Magic 8> |
| // BehaviorType |
| v_ILog_behavOK := f_EPTF_LGenBase_declareBehaviorType(c_ILog_behavName, -1, null, null, null); |
| // FSM event |
| v_ILog_action := f_EPTF_LGenBase_declareFsmEvent(c_ILog_behavName, c_ILog_action); |
| // Entity |
| v_dummyInt := f_EPTF_LGenBase_declareEntityType(c_ILog_entityType, {c_ILog_behavName}); |
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({c_ILog_entityGroup, c_ILog_entityType, 2}); |
| // FSM |
| var integer vl_tIdx := f_EPTF_LGenBase_declareCompactFsmTable({ |
| name := "iLogTestFsm", |
| // [0] |
| stateList := {"idle"}, |
| timerList := {}, |
| table := { |
| {eventToListen := {v_ILog_behavOK,v_ILog_action,fsm}, |
| cellRow := { |
| //state[0]==idle |
| {{{refers(f_EPTF_ILog_Test_msgStep),{}}}, omit,0} |
| } |
| } |
| } |
| } |
| ); |
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= c_ILog_entityIdx1, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1) |
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= c_ILog_entityIdx2, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1) |
| |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // Calls <f_EPTF_ILogBase_register_DB>. |
| v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1] := f_EPTF_ILog_register_DB(refers(f_EPTF_ILog_Test_logItem), {c_ILog_entityIdx1}); |
| v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx2] := f_EPTF_ILog_register_DB(refers(f_EPTF_ILog_Test_logItem), {c_ILog_entityIdx2}); |
| |
| // [1]: Negative tests - new chain |
| // --------------------------------------------------------------------------------------------------------- |
| // This function creates a new chains or reuses an existing free chains for short and detailed chains. |
| // Sets the elements of the application data assigned to the FSM context. |
| action("f_EPTF_LGenBase_ILog_newChains->NonExist[pl_eAbsIdx]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Unbound right operand of integer comparison. |
| |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_idxNonExist, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_idxNonExist, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_idxNonExist, vl_tIdx}); |
| */ |
| |
| action("f_EPTF_LGenBase_ILog_newChains->NonExist[pl_fsmCtx]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Unbound right operand of integer comparison. |
| |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_entityIdx1, pl_fsmCtx := c_idxNonExist, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_entityIdx1, c_idxNonExist}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_entityIdx1, c_idxNonExist}); |
| */ |
| |
| // [2] Negative tests - invalid calls of f_EPTF_ILog_addToChains |
| // --------------------------------------------------------------------------------------------------------- |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->NonExist[eIdx]"); |
| var EPTF_LGenBase_TestStepArgs vl_testStepArgsNonExist; |
| vl_testStepArgsNonExist.eIdx := c_ILog_entityIdx1; |
| vl_testStepArgsNonExist.refContext.fCtxIdx := vl_tIdx; |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_Base_setNegativeTestMode(true); |
| f_EPTF_Base_setExpectedErrorMsg("Index overflow in a value of type*"); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgsNonExist, v_EPTF_ILog_Test_logItems_dbIds[c_entityIdx1]); |
| if(v_dummyInt!=c_IList_err){ |
| setverdict( fail, "Invalid returned value in f_EPTF_LGenBase_ILog_addToChains[non exist eIdx]. Should be: ",c_IList_err, " but got: ",v_dummyInt ); |
| } |
| f_EPTF_Base_setNegativeTestMode(false); |
| */ |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->NonExist[fCtxIdx]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityFsmCtxList: The index is 123, but the value has only 1 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_entityIdx1; |
| vl_testStepArgsNonExist.refContext.fCtxIdx := c_idxNonExist; |
| f_EPTF_Base_setNegativeTestMode(true); |
| f_EPTF_Base_setExpectedErrorMsg("Index overflow in a value of type "); |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgsNonExist, v_EPTF_ILog_Test_logItems_dbIds[c_entityIdx1]); |
| if(v_dummyInt!=c_IList_err){ |
| setverdict( fail, "Invalid returned value in f_EPTF_LGenBase_ILog_addToChains[non exist fCtxIdx]. Should be: ",c_IList_err, " but got: ",v_dummyInt ); |
| } |
| f_EPTF_Base_setNegativeTestMode(false); |
| */ |
| |
| action("f_EPTF_LGenBase_ILog_addToChains[1]->NonExist[dbId]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_Common_Definitions.EPTF_IntegerArray2D: The index is 1, but the value has only 0 elements. |
| |
| vl_testStepArgsNonExist.refContext.fCtxIdx := vl_tIdx; |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgsNonExist, c_idxNonExist); |
| if(v_dummyInt!=c_IList_err){ |
| setverdict( fail, "Invalid returned value in f_EPTF_LGenBase_ILog_addToChains[non exist dbId]. Should be: ",c_IList_err, " but got: ",v_dummyInt ); |
| } |
| */ |
| |
| // [3] Negative tests - invalid calls of f_EPTF_ILog_getChainId |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_ILog_getChainId[1]->NonExist[pl_eAbsIdx]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| v_dummyInt := f_EPTF_LGenBase_ILog_getChainId(c_idxNonExist, vl_tIdx, short); |
| */ |
| |
| action("f_EPTF_LGenBase_ILog_getChainId[1]->NonExist[pl_fsmCtx]"); |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityFsmCtxList: The index is 123, but the value has only 1 elements. |
| |
| v_dummyInt := f_EPTF_LGenBase_ILog_getChainId(c_entityIdx1, c_idxNonExist, short); |
| */ |
| |
| // [4] Negative tests - invalid calls of f_EPTF_ILog_step_logSuccess |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_LGenBase_ILog_step_logSuccess->NonExist[eIdx]"); |
| var EPTF_LGenBase_TestStepArgs vl_testStepArgs1; |
| vl_testStepArgs1.eIdx := c_ILog_entityIdx1; |
| vl_testStepArgs1.refContext.fCtxIdx := vl_tIdx; |
| |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // reset chain |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_LGenBase_ILog_step_logSuccess(vl_testStepArgsNonExist); |
| */ |
| f_EPTF_LGenBase_ILog_step_deleteLog(vl_testStepArgs1); |
| |
| |
| // [5] Negative tests - invalid calls of f_EPTF_ILog_step_logFailed |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_LGenBase_ILog_step_logFailed->NonExist[eIdx]"); |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // reset chain |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_LGenBase_ILog_step_logFailed(vl_testStepArgsNonExist); |
| action("***", v_dummyInt); |
| */ |
| f_EPTF_LGenBase_ILog_step_deleteLog(vl_testStepArgs1); |
| |
| |
| // [6] Negative tests - invalid calls of f_EPTF_ILog_step_deleteLog |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_ILog_step_deleteLog->NonExist[eIdx]"); |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // reset chain |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_LGenBase_ILog_step_deleteLog(vl_testStepArgsNonExist); |
| */ |
| f_EPTF_LGenBase_ILog_step_deleteLog(vl_testStepArgs1); |
| |
| |
| // [7] Negative tests - invalid calls of f_EPTF_ILog_step_shortLogNext |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_ILog_step_shortLogNext->NonExist[eIdx]"); |
| // reset DB |
| f_EPTF_ILog_Test_resetDB(); |
| // reset Log |
| f_EPTF_ILog_Test_resetLog(); |
| // reset chain |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_LGenBase_ILog_step_shortLogNext(vl_testStepArgsNonExist); |
| */ |
| // No delete for test "There is unprocessed chain data! Please log or delete it previously!" warning in f_EPTF_ILog_newChains |
| |
| |
| // [8] Negative tests - invalid calls of f_EPTF_ILog_disableShortLog |
| // --------------------------------------------------------------------------------------------------------- |
| action("f_EPTF_ILog_disableShortLog->NonExist[eIdx]"); |
| // reset chain |
| f_EPTF_LGenBase_ILog_newChains(pl_eAbsIdx := c_ILog_entityIdx1, pl_fsmCtx := vl_tIdx, |
| pl_logHeaderDetailedFn := refers(f_logHeader_first_detailed), pl_paramDetailed := {c_ILog_entityIdx1, vl_tIdx}, |
| pl_logHeaderShortFn := refers(f_logHeader_first_short), pl_paramShort := {c_ILog_entityIdx1, vl_tIdx}); |
| // Add element(s) short and or detailed chain Id(s) to the chains that are given in the input integer list than disable short log. |
| v_dummyInt := f_EPTF_LGenBase_ILog_addToChains(vl_testStepArgs1, v_EPTF_ILog_Test_logItems_dbIds[c_ILog_entityIdx1]); |
| f_EPTF_ILog_Test_adToDB(v_dummyInt, 0); // addToILog[0, 0] => detailed |
| |
| /* |
| RUN ERROR => |
| Dynamic test case error: Index overflow in a value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityCtxList: The index is 123, but the value has only 2 elements. |
| vl_testStepArgsNonExist.eIdx := c_idxNonExist; |
| f_EPTF_LGenBase_ILog_disableShortLog(vl_testStepArgsNonExist); |
| */ |
| |
| |
| /* |
| If the f_EPTF_LGenBase_ILog_step_deleteLog steps are not there, it generates a new chain, |
| and the latest database content is still valid: |
| |
| <<[FIRST:short] ILogHeader: 9 - Short Chain - 0>> |
| <<[FIRST:detailed] ILogHeader: 10 - Detailed Chain - 0>> |
| {EPTF_ILog_Test: Event in chain#10 - 0 [4]: Detailed Chain: addToILog[0, 4]} |
| |
| otherwise it uses the same chain, so: |
| |
| <<[FIRST:short] ILogHeader: 1 - Short Chain - 0>> |
| <<[FIRST:detailed] ILogHeader: 2 - Detailed Chain - 0>> |
| {EPTF_ILog_Test: Event in chain#2 - 0 [0]: Detailed Chain: addToILog[0, 0]} |
| |
| - Shouldn't we delete the existing chains in case of f_EPTF_LGenBase_ILog_newChains? |
| - No, now it sends a warning: "There is unprocessed chain data! Please log or delete it previously!" |
| |
| */ |
| // logFailed STEP |
| action("f_EPTF_LGenBase_ILog_step_logFailed[1]->"); |
| f_EPTF_LGenBase_ILog_step_logFailed(vl_testStepArgs1); |
| // GET LOG STR[1] |
| var charstring vl_logSt1 := f_EPTF_ILog_Test_getLogStr(c_ILog_entityIdx1); |
| action("vl_logSt1->",vl_logSt1); |
| |
| |
| // Cleanup |
| // --------------------------------------------------------------------------------------------------------- |
| /* |
| In case of a faulty chainID, the f_EPTF_ILog_disableShortLog and the f_EPTF_ILog_step_shortLogNext causes this error: |
| |
| 2012/Jun/19 17:44:17.880719 |
| ERROR EPTF_ILog_Test.ttcn:925(controlpart:EPTF_ILog_Test)-> |
| EPTF_ILog_Test.ttcn:913(testcase:tc_ILog_negative_tests)-> |
| EPTF_CLL_Base_Functions.ttcn:255(function:f_EPTF_Base_cleanup_CT)-> |
| EPTF_CLL_LGenBase_Functions.ttcn:491(function:f_EPTF_LGenBase_cleanup_CT) |
| Dynamic test case error: Performing sizeof operation on an unbound value of type @EPTF_CLL_LGenBase_Definitions.EPTF_LGenBase_EntityFsmCtxList. |
| |
| 2012. 11. 28.: The contents of EPTF_ILog_Test.ttcn have been moved to this file. |
| */ |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| |
| testcase tc_LGenBase_Test_fsmVarAdd () |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_negativeFsmVarAddSub(c_EPTF_LGenBase_stepName_fsmVarAdd); |
| } |
| |
| testcase tc_LGenBase_Test_fsmVarSub () |
| runs on EPTF_LGenBase_Test_CT |
| { |
| f_LGenBase_Test_negativeFsmVarAddSub(c_EPTF_LGenBase_stepName_fsmVarSub); |
| } |
| |
| function f_LGenBase_Test_negativeFsmVarAddSub(in charstring pl_stepName) runs on EPTF_LGenBase_Test_CT |
| { |
| f_EPTF_LGenBase_init("Test_c_EPTF_LGenBase_stepName_fsmVarAdd"); |
| f_EPTF_Base_setExpectedErrorMsg("*Invalid step arguments: *. It should contain at least 3 pairs of variable index and scope*"); |
| |
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b1", -1, null, null, null); |
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("Entity_Tc_A", {"b1"}); |
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({name := "eg0", eType := "Entity_Tc_A", eCount := 2}) |
| var integer vl_varRefIdx := 0; |
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable({ |
| name := "fsm1", |
| fsmParams := { |
| {stateList := {"idle"}}, |
| {timerList := {{"timer", 1.0}}}, |
| {varList := {{"name1",{intVal := 2},FSM}, |
| {"name2",{intVal := 3},FSM}, |
| {"name3",{intVal := 4},FSM}}} |
| }, |
| table := { |
| classicTable := { |
| {eventToListen := {c_EPTF_LGenBase_behavior,c_EPTF_LGenBase_inputName_testMgmt_startTC,fsm}, |
| cellRow := { |
| {{ |
| {pl_stepName, { stepContextArgs := {vl_varRefIdx, c_EPTF_LGenBase_fsmObjectScopeFSM |
| /* This would be the correct call of the step: |
| ,vl_varRefIdx+1, c_EPTF_LGenBase_fsmObjectScopeFSM, |
| vl_varRefIdx+2, c_EPTF_LGenBase_fsmObjectScopeFSM*/}}} |
| }, omit, omit} |
| } |
| } |
| } |
| } |
| }) |
| |
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({ |
| name := "TC_Succ", |
| fsmName := "fsm1", |
| entityType := "Entity_Tc_A", |
| customEntitySucc := "" |
| }) |
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3({ |
| name := "sc1", |
| tcList := { |
| { tcName := "TC_Succ", |
| tcParamsList := { |
| {enabledAtStart := false}, |
| {target := {cpsToReach := 0.0}} |
| } |
| } |
| }, |
| scParamsList := { |
| {trafficType := terminating} |
| } |
| }) |
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg0","sc1"}); |
| var EPTF_LGenBase_ReportedEventDescriptor vl_event := c_EPTF_LGenBase_emptyReportedEventDescriptor; |
| vl_event.event.bIdx := c_EPTF_LGenBase_bIdx; |
| vl_event.event.iIdx := c_EPTF_LGenBase_inputIdx_testMgmt_startTC; |
| vl_event.event.target.eIdx := 1; |
| vl_event.event.target.fsmCtxIdx := 0; |
| f_EPTF_LGenBase_dispatchEvent(vl_event); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| ////////////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_DS_ConditionHasActiveTc_NoEGSCTC |
| // |
| // Purpose: To test the DataSource Client functionality of the |
| // LGenBase feature that do need no eg/sc/tc declaration |
| // |
| // Action: calls f_LGenBase_Test_DataSource(), which test |
| // only the c_LGenBase_conditionHasActiveTc without |
| // eg, sc and tc. |
| // |
| // Expected Result: pass |
| ///////////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_DS_ConditionHasActiveTc_NoEGSCTC() |
| runs on EPTF_LGenBase_DataSourceTest_CT{ |
| f_LGenBase_Test_DataSource(c_fsm1, 0); |
| } |
| |
| ////////////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_DS_ConditionHasActiveTc_EGNoSCTC |
| // |
| // Purpose: To test the DataSource Client functionality of the |
| // LGenBase feature that do need no eg/sc/tc declaration |
| // |
| // Action: calls f_LGenBase_Test_DataSource(), which test |
| // only the c_LGenBase_conditionHasActiveTc with eg given |
| // but without sc and tc. |
| // |
| // Expected Result: pass |
| ///////////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_DS_ConditionHasActiveTc_EGNoSCTC() |
| runs on EPTF_LGenBase_DataSourceTest_CT{ |
| f_LGenBase_Test_DataSource(c_fsm1, 1); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_DS_Neg_WrongConditionHasActiveTc |
| // |
| // Purpose: |
| // This is a fake negative test case. |
| // It tests the DataSourceClient function of LGenBase with this wrong request: |
| // Data Element: conditionHasActiveTc |
| // Params: too much params |
| // A proper warning message should appear. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_DS_Neg_WrongConditionHasActiveTc() runs on EPTF_LGenBase_DataSourceTest_CT |
| { |
| f_LGenBase_Test_wrongConditionRequest( |
| c_fsm1, |
| c_LGenBase_conditionHasActiveTc, |
| {{c_LGenBase_paramNameEntityGroup, "eg1"}}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_externalTemplates_arithmetic |
| // |
| // Purpose: |
| // Testcase to check the 'external templates' feature arithmetic |
| // |
| // Requirement: |
| // dummy_template.txt external template file is available on filesystem |
| // |
| // Action: |
| // - Loads an external template, |
| // - creates template set, |
| // - declares a template type |
| // - assigns template type to external template, |
| // - substitutes template with sample values and logs content |
| // - checks the arithmetic functionality works |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_externalTemplates_arithmetic() runs on EPTF_LGenBase_Test_CT |
| { |
| const charstring extTemplName1 := "dummy"; |
| const charstring extTemplName2 := "dummy2"; |
| const charstring extTemplName_dos := "dummy_dos"; |
| const charstring extTemplName_unixFalse := "dummy_unix_false"; |
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {extTemplName1, tsp_dummyTemplatePathArithmetic, true}, |
| {extTemplName2, "file_not_exist.txt", false}, |
| {extTemplName_dos, tsp_dummyTemplatePathArithmetic_dos, true}, |
| {extTemplName_unixFalse, tsp_dummyTemplatePathArithmetic, false} |
| } |
| |
| // 1. load the external template list |
| log("Init component and load external template list"); |
| f_EPTF_LGenBase_init("LGenBase Templates Test", pl_extTemplLoadList := extTemplLoadList, pl_enableDefaultArithmeticOperationsInExtTemplate := true); |
| |
| // check dummy template exist, other one not exist |
| if ( f_EPTF_LGenBase_getExtTemplIdx(extTemplName1) >= 0 |
| and f_EPTF_LGenBase_getExtTemplIdx(extTemplName_unixFalse) >= 0 |
| and f_EPTF_LGenBase_getExtTemplIdx(extTemplName_dos) >= 0 |
| and f_EPTF_LGenBase_getExtTemplIdx(extTemplName2) == -1 ) |
| { |
| //check if the endline characters are correctly changed |
| if ( f_LGenBase_Test_externalTemplates_isDosLineEnd(extTemplName1) |
| and f_LGenBase_Test_externalTemplates_isDosLineEnd(extTemplName_dos) |
| and not f_LGenBase_Test_externalTemplates_isDosLineEnd(extTemplName_unixFalse) |
| ) { |
| log("External template loaded OK"); |
| } |
| else { |
| setverdict(fail, "External templates end line characters are not correct"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| else |
| { |
| setverdict(fail, "Could not load external templates"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // 2. create a new template set |
| log("Create template set"); |
| var integer setId := f_EPTF_LGenBase_createTemplateSet(); |
| if(setId >= 0) |
| { |
| log("Template set created OK"); |
| } |
| else |
| { |
| log("Could not create template set"); |
| setverdict(fail); |
| } |
| |
| // 3. declare a new template type |
| log("Declare new template type"); |
| var EPTF_LGenBase_TemplateTypeKey templTypeKey := {"SIP", "INVITE"}; |
| var integer templTypeIdx := f_EPTF_LGenBase_declareTemplateType(templTypeKey, {"USERNAME"}, {"USERID"}) |
| if ( templTypeIdx>=0 ) |
| { |
| log("Template type declared OK"); |
| } |
| else |
| { |
| log("Could not declare template type"); |
| setverdict(fail); |
| } |
| |
| // 4. assign declared template type to 'dummy' template |
| log("Assign declared type to external template"); |
| // NOTE: f_EPTF_LGenBase_assignExtTemplToTemplType(setId, templTypeIdx, extTemplIdx) is more efficient |
| if(f_EPTF_LGenBase_assignExtTemplToTemplType3(setId, templTypeKey, extTemplName1) >= 0) |
| { |
| log("Assigment OK"); |
| } |
| else |
| { |
| log("Could not assign template type with external template"); |
| setverdict(fail); |
| } |
| |
| // 5 get substituted template content |
| log("Get substituted template content"); |
| var charstring vl_content1 := "", vl_content2:=""; |
| |
| // 5.1 get content by position-based parameter assign |
| var integer vl_templateItemIdx := f_EPTF_LGenBase_getTemplateItemIdxFromSet(setId, templTypeIdx); |
| if (vl_templateItemIdx < 0) |
| { |
| log("Template type not found in template set"); |
| setverdict(fail); |
| } |
| if(f_EPTF_LGenBase_getTemplateContentFast(setId, vl_templateItemIdx, {"username_0012_a@uri.hu", "myuserid"}, vl_content1)) |
| { |
| log("Positional parameter substitution done OK"); |
| log("Result:\n", vl_content1); |
| setverdict(pass); |
| } |
| else |
| { |
| log("Parameter substitution failed"); |
| setverdict(fail); |
| } |
| |
| // 5.2 get content by dictionary-based parameter assign |
| // NOTE: f_EPTF_LGenBase_getTemplateContent(extTemplIdx, ...) is more efficient |
| if(f_EPTF_LGenBase_getTemplateContentByExtTemplName(extTemplName1, {{"USERNAME","username_0012_a@uri.hu"},{"USERID","myuserid"}}, vl_content2)) |
| { |
| log("Dictionary-based parameter substitution done OK"); |
| log("Result:\n", vl_content2); |
| setverdict(pass); |
| } |
| else |
| { |
| log("Parameter substitution failed"); |
| setverdict(fail); |
| } |
| |
| if(vl_content1 != vl_content2) |
| { |
| log("Substituted contents are not equal!"); |
| setverdict(fail); |
| } |
| |
| |
| if(vl_content1 != c_LGenBase_TemplateSubstitutionTest_Result) |
| { |
| log("Substituted contents are correct!"); |
| setverdict(fail); |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // functions and component that is needed to check expected warning messages |
| group CheckExpectedWarning { |
| |
| private function f_EPTF_LGenBase_Test_ExpectedWarning_init() runs on EPTF_CLL_LGenBase_Test_ExpectedWarning_CT { |
| if (v_LGenBase_Test_expectedWarningInitialized) { |
| return; |
| } |
| v_LGenBase_Test_expectedWarningInitialized:=true; |
| v_LGenBase_Test_expectedWarningArrived := false; |
| v_LGenBase_Test_expectedWarningMsg:=""; |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_LGenBase_Test_ExpectedWarning_cleanup)); |
| f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_LGenBase_Test_ExpectedWarning_checkExpectedWarning_preamble_FT)); |
| } |
| |
| private function f_EPTF_LGenBase_Test_ExpectedWarning_cleanup() runs on EPTF_CLL_LGenBase_Test_ExpectedWarning_CT { |
| if (not v_LGenBase_Test_expectedWarningInitialized) { |
| return; |
| } |
| v_LGenBase_Test_expectedWarningInitialized:=false; |
| if (v_LGenBase_Test_expectedWarningMsg != "" and not v_LGenBase_Test_expectedWarningArrived) { |
| setverdict(fail,"Expected warning message ",v_LGenBase_Test_expectedWarningMsg," was not logged!"); |
| } else { |
| setverdict(pass,"Expected warning message was logged"); |
| } |
| } |
| |
| public function f_EPTF_LGenBase_Test_ExpectedWarning_setExpectedWarning(in charstring pl_expectedWarningMsg) runs on EPTF_CLL_LGenBase_Test_ExpectedWarning_CT { |
| if (pl_expectedWarningMsg=="") { |
| return; |
| } |
| f_EPTF_LGenBase_Test_ExpectedWarning_init(); |
| v_LGenBase_Test_expectedWarningMsg := pl_expectedWarningMsg; |
| } |
| |
| private function f_EPTF_LGenBase_Test_ExpectedWarning_checkExpectedWarning_preamble_FT(in charstring pl_message) runs on EPTF_CLL_LGenBase_Test_ExpectedWarning_CT { |
| if (not match(pl_message,pattern "*Warning*")) { |
| return; |
| } |
| action(match(pl_message,pattern v_LGenBase_Test_expectedWarningMsg)) |
| if (match(pl_message,pattern v_LGenBase_Test_expectedWarningMsg)) { |
| v_LGenBase_Test_expectedWarningArrived := true; |
| } |
| } |
| |
| } // group CheckExpectedWarning |
| |
| |
| type component EPTF_LGenBase_Test_CheckExpectedWarning_CT extends EPTF_CLL_LGenBase_Test_ExpectedWarning_CT, EPTF_LGenBase_Test_CT { |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_externalTemplates_assignExisting |
| // |
| // Purpose: |
| // Testcase to check the if assign is done for an existing 'external template' |
| // |
| // Requirement: |
| // dummy_template.txt external template file is available on filesystem |
| // |
| // Action: |
| // - Loads an external template, |
| // - creates template set, |
| // - declares a template type |
| // - assigns template type to external template, |
| // - assigns another template type to the same external template |
| // - checks the warning |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_externalTemplates_assignExisting() runs on EPTF_LGenBase_Test_CheckExpectedWarning_CT |
| { |
| const charstring extTemplName1 := "dummy1"; |
| const charstring extTemplName2 := "dummy2"; |
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {extTemplName1, tsp_dummyTemplatePathArithmetic, true}, |
| {extTemplName2, tsp_dummyTemplatePathArithmetic, true} |
| } |
| |
| // 1. load the external template list |
| log("Init component and load external template list"); |
| f_EPTF_LGenBase_init("LGenBase Templates Test", pl_extTemplLoadList := extTemplLoadList, pl_enableDefaultArithmeticOperationsInExtTemplate := true); |
| |
| f_EPTF_LGenBase_Test_ExpectedWarning_init(); |
| f_EPTF_LGenBase_Test_ExpectedWarning_setExpectedWarning("*Assignment in the template set 0 already exists for template type 0. Assigned template: dummy1. Cannot assign new template: dummy2*"); |
| |
| // check dummy template exist, other one not exist |
| if ( f_EPTF_LGenBase_getExtTemplIdx(extTemplName1) >= 0 |
| and f_EPTF_LGenBase_getExtTemplIdx(extTemplName2) >= 0 ) |
| { |
| log("External template loaded OK"); |
| } |
| else |
| { |
| setverdict(fail, "Could not load external templates"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // 2. create a new template set |
| log("Create template set"); |
| var integer setId := f_EPTF_LGenBase_createTemplateSet(); |
| if(setId >= 0) |
| { |
| log("Template set created OK"); |
| } |
| else |
| { |
| log("Could not create template set"); |
| setverdict(fail); |
| } |
| |
| // 3. declare a new template type |
| log("Declare new template type"); |
| var EPTF_LGenBase_TemplateTypeKey templTypeKey := {"SIP", "INVITE"}; |
| var integer templTypeIdx := f_EPTF_LGenBase_declareTemplateType(templTypeKey, {"USERNAME"}, {"USERID"}) |
| if ( templTypeIdx>=0 ) |
| { |
| log("Template type declared OK"); |
| } |
| else |
| { |
| log("Could not declare template type"); |
| setverdict(fail); |
| } |
| |
| // 4. assign declared template type to 'dummy' template |
| log("Assign declared type to external template"); |
| // NOTE: f_EPTF_LGenBase_assignExtTemplToTemplType(setId, templTypeIdx, extTemplIdx) is more efficient |
| if(f_EPTF_LGenBase_assignExtTemplToTemplType3(setId, templTypeKey, extTemplName1) >= 0) |
| { |
| log("Assigment OK"); |
| } |
| else |
| { |
| log("Could not assign template type with external template"); |
| setverdict(fail); |
| } |
| |
| |
| // 5. assigns another template type to the same external template |
| if(f_EPTF_LGenBase_assignExtTemplToTemplType3(setId, templTypeKey, extTemplName2) >= 0) |
| { |
| log("Assigment OK"); |
| setverdict(fail, "Assignment should not be OK"); |
| } |
| else |
| { |
| log("Could not assign template type with external template"); |
| setverdict(pass); |
| } |
| |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| type component EPTF_LGenBase_TestPipe_CT extends EPTF_LGenBase_Test_CT{ |
| port PIPEasp_PT v_pipe_PCO; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGenBase_Test_externalTemplates_isDosLineEnd |
| // |
| // Purpose: |
| // returns if the template end line characters are dos end line characters |
| // |
| // Parameters: |
| // pl_extTemplateName - *in* *charstring* - the name of the template |
| // |
| // Return Value: |
| // if the template contains "\r\n" characters it will be true |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| function f_LGenBase_Test_externalTemplates_isDosLineEnd(in charstring pl_extTemplateName) |
| runs on EPTF_LGenBase_Test_CT |
| return boolean { |
| |
| var charstring vl_content := ""; |
| f_EPTF_LGenBase_getTemplateContentByExtTemplName(pl_extTemplateName, {}, vl_content); |
| |
| for ( var integer i := 0; i <= lengthof(vl_content) -2; i := i + 1) { |
| if (substr(vl_content,i,2)== "\r\n") { |
| return true; |
| } |
| } |
| return false; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LGenBase_PIPEsend |
| // |
| // Purpose: |
| // Send a bash command through the PIPE testport, and |
| // return the exit code |
| // |
| // Parameters: |
| // pl_command - *in* *charstring* - the command to execute |
| // pl_result - *out* <ASP_PResult> - the results of the command |
| // |
| // Return Value: |
| // Exit code from the executed command - usually 0 means success |
| // |
| // Detailed Comments: |
| // The pl_result out parameter can be <unbound> if the return value is not 0 |
| // |
| /////////////////////////////////////////////////////////// |
| function f_EPTF_LGenBase_PIPEsend(in charstring pl_command, out ASP_PResult pl_result) |
| runs on EPTF_LGenBase_TestPipe_CT |
| return integer |
| { |
| log("Sending command on PIPE test port: " & pl_command); |
| const float c_guard := 300.0; |
| var ASP_PExecute vl_pExecute := { command := "bash ", stdin := pl_command & "; exit" } |
| v_pipe_PCO.send(vl_pExecute); |
| timer t_guard; |
| t_guard.start(c_guard); |
| alt |
| { |
| [] v_pipe_PCO.receive(ASP_PResult:?) -> value pl_result |
| { |
| t_guard.stop; |
| return pl_result.code; |
| } |
| [] t_guard.timeout |
| { |
| setverdict(fail,"PIPE answer timeout!"); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| return 1; |
| } |
| } |
| setverdict(fail,"Shouldn't be reached!"); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| return 2; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_fsmDump |
| // |
| // Purpose: |
| // Testcase to check the 'FSM Dump' feature |
| // |
| // Requirement: |
| // PIPE testport for file-operations |
| // |
| // Action: |
| // - remove FSM dump files, |
| // - initialize LGenBase, |
| // - disable the FSMdump functionality, |
| // - declare an FSM, |
| // - check if the file is created with disabled dump, |
| // - enable the FSMdump functionality, |
| // - declare the FSM again, |
| // - check if the file has been created correctly, |
| // - compare the file and the expected output |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_fsmDump() runs on EPTF_LGenBase_TestPipe_CT |
| { |
| map(self:v_pipe_PCO, system:v_pipe_PCO) |
| const ASP_PLineMode c_pLineMode := { lineMode := true }; |
| v_pipe_PCO.send(c_pLineMode); |
| |
| const charstring cl_dump_files := "fsmdump_*"; |
| |
| // 1. remove FSM dump files |
| var ASP_PResult vl_result; |
| if (f_EPTF_LGenBase_PIPEsend("rm -f "&cl_dump_files, vl_result) != 0) { |
| setverdict(fail,"Error while removing files: "&vl_result.stderr); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 2. initialize LGenBase |
| f_EPTF_LGenBase_init("LGenBase FSM Dump Test"); |
| |
| // 3. disable the FSMdump functionality |
| f_EPTF_LGenBase_setFSMdumpPath(""); |
| |
| // 4. declare an FSM |
| var EPTF_LGenBase_FsmTableDeclarator vl_fsm := { |
| name := "FSMTest 1", |
| fsmParams := |
| {{stateList := {"idle"}}}, |
| table := { |
| extendedTable := { |
| { |
| events2Listen := {events := { { singleEvent := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_startTC, fsm }}}}, |
| cellRow := { statedCellRow := { |
| { |
| inState := {state := "idle"}, |
| cell := {{{c_EPTF_LGenBase_stepName_trafficSuccess, omit}}, |
| omit, omit |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| f_EPTF_LGenBase_declareFSMTable(vl_fsm); |
| |
| // 5. check if any file is created with disabled dump |
| if (f_EPTF_LGenBase_PIPEsend("ls "&cl_dump_files, vl_result) == 0) { |
| setverdict(fail,"File created when it shouldn't be: "&vl_result.stdout); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 6. enable the FSMdump functionality |
| f_EPTF_LGenBase_setFSMdumpPath("."); |
| |
| // 7. declare the FSM again |
| vl_fsm.name := "FSMTest 2"; |
| f_EPTF_LGenBase_declareFSMTable(vl_fsm); |
| |
| // 8. check if the file has been created correctly |
| const charstring cl_expected_filename := "fsmdump_FSMTest_2.cfg" |
| if (f_EPTF_LGenBase_PIPEsend("ls "&cl_dump_files, vl_result) != 0) { |
| setverdict(fail,"No dump file is created!"); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| } |
| else { |
| if (vl_result.stdout != cl_expected_filename) { |
| setverdict(fail,"Dump file name is '"&vl_result.stdout&"' instead of '"&cl_expected_filename&"'"); |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| // 9. compare the file and the expected output |
| if (f_EPTF_LGenBase_PIPEsend("diff -q expected_fsm_dump.txt "&cl_expected_filename, vl_result) != 0) { |
| setverdict(fail,"Error: "&vl_result.stdout); |
| } |
| |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| group DTEHandler_Event4FSM { |
| |
| function f_EPTF_LGenBase_Test_DTEInTestStep_shouldGenerateDTE(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_LGenBase_Test_CT return boolean |
| { |
| // returns true if entity should generate DTE |
| return pl_ptr.eIdx rem 3 == 1; |
| } |
| |
| function f_EPTF_LGenBase_Test_step_start(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_LGenBase_Test_CT |
| { |
| action("!!!! started entity: ", pl_ptr.eIdx); |
| } |
| |
| function f_EPTF_LGenBase_Test_step_generateDTE(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_LGenBase_Test_CT |
| { |
| action("!!!! generateDTE is running for entity: ", pl_ptr.eIdx, " , post/dispatch: ", pl_ptr.stepArgs); |
| if (not f_EPTF_LGenBase_Test_DTEInTestStep_shouldGenerateDTE(pl_ptr)) { |
| return; // no DTE |
| } |
| |
| //log(%definitionId, " started..."); |
| var integer i := 1; |
| log(i/(i-1)); |
| } |
| |
| function f_EPTF_LGenBase_Test_step_checkDTE(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_LGenBase_Test_CT |
| { |
| action("!!!! checkDTE is running for entity: ", pl_ptr.eIdx); |
| v_EventReceived[pl_ptr.eIdx] := v_EventReceived[pl_ptr.eIdx] + 1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_LGenBase_Test_DTEHandler_Event4FSM |
| // |
| // Purpose: |
| // Testcase to check if events are handled correctly for entities that generated DTE before |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - start traffic case |
| // - entity 1 generates DTE |
| // - traffic case finishes |
| // - entity 1 enabled |
| // - traffic case started |
| // - number of starts checked |
| // |
| // Description: |
| // This test checks correct behaviour for artifact artf636751. |
| // Test case should pass |
| // The original code generated DTE when the traffic case was started |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_LGenBase_Test_DTEHandler_Event4FSM () runs on EPTF_LGenBase_Test_CT { |
| f_EPTF_LGenBase_init("DTEHandler_Event4FSM"); |
| const charstring cl_behaviorName := "DTEHandler_Event4FSM_behavior"; |
| const charstring cl_entityType := "DTEHandler_Event4FSM_entityType"; |
| const charstring cl_entityGrp := "DTEHandler_Event4FSM_entityGrp"; |
| const charstring cl_fsmName := "DTEHandler_Event4FSM_FSM"; |
| const charstring cl_stepName_start := "DTEHandler_Event4FSM_step_start"; |
| const charstring cl_stepName_generateDTE := "DTEHandler_Event4FSM_step_generateDTE"; |
| const charstring cl_stepName_checkDTE := "DTEHandler_Event4FSM_step_checkDTE"; |
| const charstring cl_trafficCase := "DTEHandler_Event4FSM_trafficCase"; |
| const charstring cl_scenario := "DTEHandler_Event4FSM_scenario"; |
| |
| // BehaviorType |
| v_myBCtxIdx := f_EPTF_LGenBase_declareBehaviorType(cl_behaviorName, -1, null, null, null); |
| // FSM event |
| // Declare Step |
| f_EPTF_LGenBase_declareStep(cl_behaviorName, {cl_stepName_start,refers(f_EPTF_LGenBase_Test_step_start)}) |
| f_EPTF_LGenBase_declareStep(cl_behaviorName, {cl_stepName_generateDTE,refers(f_EPTF_LGenBase_Test_step_generateDTE)}) |
| f_EPTF_LGenBase_declareStep(cl_behaviorName, {cl_stepName_checkDTE,refers(f_EPTF_LGenBase_Test_step_checkDTE)}) |
| |
| // Entity |
| v_dummyInt := f_EPTF_LGenBase_declareEntityType(cl_entityType, {cl_behaviorName}); |
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({cl_entityGrp, cl_entityType, 3}); |
| // FSM |
| var integer vl_tIdx := f_EPTF_LGenBase_declareCompactFsmTable({ |
| name := cl_fsmName, |
| // [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_start),{}}, |
| {refers(f_EPTF_LGenBase_Test_step_generateDTE),{}}, |
| {refers(f_EPTF_LGenBase_Test_step_checkDTE),{}}, |
| {refers(f_EPTF_LGenBase_step_trafficSuccess),{}} |
| }, |
| omit, |
| 0 |
| } |
| } |
| }, |
| {eventToListen := {c_EPTF_LGenBase_bIdx,c_EPTF_LGenBase_inputIdx_testMgmt_trafficCaseStarted,general}, |
| cellRow := { |
| //state[0]==idle |
| { |
| { |
| {refers(f_EPTF_LGenBase_Test_step_start),{}} |
| }, |
| omit, |
| 0 |
| } |
| } |
| } |
| } |
| }); |
| |
| v_dummyInt := f_EPTF_LGenBase_declareTcType2( |
| { |
| name := cl_trafficCase, |
| fsmName := cl_fsmName, |
| entityType := cl_entityType, |
| customEntitySucc := "" |
| }); |
| |
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3( |
| { |
| name := cl_scenario, |
| tcList := { |
| { |
| tcName := cl_trafficCase, |
| tcParamsList := { |
| {target := {cpsToReach := 3.0}}, |
| {scheduler := { preDefinedName := orig }}, |
| {enableEntitiesAtStart := true}, |
| {enabledAtStart := true}, |
| {trafficStartFinish := {{nrOfSuccesses := {10,{}} }}} // condition for tc finish |
| } |
| } |
| }, |
| scParamsList := {} |
| }); |
| |
| f_EPTF_LGenBase_createScenario2EntityGroup( { cl_entityGrp, cl_scenario } ); |
| |
| var integer vl_tcIdx := f_EPTF_LGenBase_trafficCaseId(pl_eGrpName := cl_entityGrp, pl_scName := cl_scenario, pl_tcName := cl_trafficCase); |
| for (var integer i := 0; i < 3; i := i + 1) { |
| v_EventReceived[i] := 0; |
| } |
| |
| timer t_finish := 5.0; |
| t_finish.start; |
| t_finish.timeout; |
| |
| f_EPTF_LGenBase_enableEntityInTrafficCase(vl_tcIdx, 1); |
| |
| action("!!!! traffic case start - begin "); |
| f_EPTF_LGenBase_startTrafficCase( cl_entityGrp, cl_scenario, cl_trafficCase); |
| action("!!!! traffic case start - finish "); |
| |
| // fix: eventHandling:4946 |
| |
| t_finish.start; |
| t_finish.timeout; |
| |
| // check v_EventReceived counters and set verdict |
| action("v_EventReceived: ", v_EventReceived); |
| |
| if (v_EventReceived != {10, 0 , 10}) { |
| setverdict(fail,"Number of traffic success is incorrect: ", v_EventReceived, " should be: {10, 0, 10}"); |
| } else { |
| setverdict(pass); |
| } |
| |
| f_EPTF_Base_stop(pl_verdict := none); |
| |
| } |
| |
| } //group DTEHandler_Event4FSM |
| |
| control { |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsScPresent1()); |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsScPresent2()); |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsScPresent3()); |
| |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsTcPresent1()); |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsTcPresent2()); |
| execute(tc_LGenBase_DS_Neg_WrongConditionIsTcPresent3()); |
| |
| execute(tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup1()); |
| execute(tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup2()); |
| execute(tc_LGenBase_DS_Neg_WrongdataElementTcEnabledAtStartup3()); |
| |
| execute(tc_LGenBase_ILog_tests()); |
| execute(tc_LGenBase_ILog_negative_tests()); |
| execute(tc_LGenBase_Test_fsmVarAdd()); |
| execute(tc_LGenBase_Test_fsmVarSub()); |
| |
| execute(tc_LGenBase_Test_DS_ConditionHasActiveTc_NoEGSCTC()); |
| execute(tc_LGenBase_Test_DS_ConditionHasActiveTc_EGNoSCTC()); |
| execute(tc_LGenBase_DS_Neg_WrongConditionHasActiveTc()); |
| execute(tc_LGenBase_Test_externalTemplates_arithmetic()); |
| execute(tc_LGenBase_Test_externalTemplates_assignExisting()); |
| |
| execute(tc_LGenBase_Test_fsmDump()); |
| |
| execute(tc_LGenBase_Test_DTEHandler_Event4FSM()); |
| } |
| |
| } |