| ///////////////////////////////////////////////////////////////////////////////
|
| // //
|
| // 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_TestcasesR3
|
| //
|
| // Purpose:
|
| // This module provides functions for testing new R3 functionalities of LGenBase
|
| //
|
| // Module depends on:
|
| // -
|
| //
|
| // Current Owner:
|
| // László Skumát (ELSZSKU)
|
| //
|
| // Last Review Date:
|
| // -
|
| //
|
| ///////////////////////////////////////////////////////////////
|
| module EPTF_LGenBase_Test_TestcasesR3
|
| {
|
| 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_Base_Definitions all;
|
| import from EPTF_CLL_LGenBase_Definitions all;
|
| import from EPTF_CLL_LGenBase_Functions all;
|
| import from EPTF_CLL_LGenBaseStats_Definitions all;
|
| import from EPTF_CLL_LGenBaseStats_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_LGenBase_LoggingFunctions all;
|
| import from EPTF_CLL_Logging_Functions all;
|
| import from EPTF_CLL_FBQ_Functions all;
|
| import from EPTF_CLL_Base_Functions all;
|
| import from EPTF_CLL_Variable_Functions all;
|
| import from EPTF_CLL_Variable_Definitions all;
|
| import from EPTF_CLL_StatHandlerClient_Definitions all;
|
| import from EPTF_CLL_StatMeasure_Definitions all
|
| import from EPTF_CLL_StatMeasure_Functions all
|
| import from EPTF_CLL_RBTScheduler_Functions all;
|
| import from EPTF_CLL_StatHandlerClient_Functions all;
|
| import from EPTF_CLL_Scheduler_Definitions all
|
|
|
| modulepar
|
| {
|
| EPTF_LGenBase_PhaseList_Declarators tsp_EPTF_LGenBase_PhaseList_Declarators := {};
|
| // module parameter for external templates testcase, defines path of dummy template
|
| charstring tsp_dummyTemplatePath := "../dummy_templ.txt";
|
| }
|
|
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Name: tc_EPTF_LGenBase_Test_declareStepAndFunction
|
| //
|
| // Purpose: testing interoperability function f_EPTF_LGenBase_declareStep, f_EPTF_LGenBase_declareFunction
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_EPTF_LGenBase_Test_declareStepAndFunction() runs on EPTF_LGenBase_Test_CT {
|
| var charstring vl_bName:=tsp_EPTF_LGenBase_Test_behaviorTypeName;
|
| f_EPTF_LGenBase_Test_init(vl_bName, imst2);
|
|
|
| log("Part 'Declare Test Step and Declare Function' starts");
|
| var charstring vl_stepName := "f_EPTF_LGenBase_Test_step_Dummy1";
|
| var charstring vl_behaviorTypeName := tsp_EPTF_LGenBase_Test_behaviorTypeName;
|
|
|
| var EPTF_LGenBase_TestStepDescriptor vl_testStep := {name := vl_stepName, step := refers(f_EPTF_LGenBase_Test_step_Dummy1)}
|
| var EPTF_LGenBase_RegisteredFunctions vl_function:= {testStepFunction:= refers(f_EPTF_LGenBase_Test_step_Dummy1)}
|
|
|
| var integer vl_stepIdx := f_EPTF_LGenBase_declareStep( vl_behaviorTypeName, vl_testStep );
|
| var integer vl_fnIdx := f_EPTF_LGenBase_declareFunction( vl_stepName, vl_function );
|
|
|
| var integer vl_fnIdxCheck := f_EPTF_LGenBase_functionNameIndex(vl_stepName);
|
| var integer vl_bIdx := f_EPTF_LGenBase_behaviorTypeNameIndex(vl_behaviorTypeName);
|
|
|
| log("Check 'Declare Test Step and Declare Function' starts");
|
| f_EPTF_LGenBase_Test_setVerdictFromBool( vl_fnIdxCheck == vl_fnIdx );
|
| //f_EPTF_LGenBase_Test_setVerdictFromBool( refers(f_EPTF_LGenBase_Test_step_Dummy1) == f_EPTF_LGenBase_Test_getTestStepFunction(vl_bIdx, vl_stepIdx));
|
|
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| group listeners{
|
| type component EPTF_LGenBase_TestListeners_CT extends EPTF_LGenBase_Test_CT{
|
| const integer c_LGenBase_TestListeners_dummy2Add := 5;
|
| const integer c_LGenBase_TestListeners_dummy2Remove := 2;
|
| const integer c_LGenBase_TestListeners_dummyRemaining := c_LGenBase_TestListeners_dummy2Add-c_LGenBase_TestListeners_dummy2Remove;
|
| const EPTF_IntegerList c_initCalledListeners := {0,0,0,0,0,0,0,0,0,0,0,0}
|
| //var EPTF_
|
| var EPTF_IntegerList v_calledListeners := c_initCalledListeners;
|
| var EPTF_IntegerArray2D v_activatedIdxs := {};
|
| var EPTF_IntegerArray2D v_listener := {};
|
| var integer v_behavFail := -1;
|
| var integer v_behavOK := -1;
|
| var integer v_firstInput := -1;
|
| var integer v_secondInput := -1;
|
| var integer v_thirdInput := -1;
|
| var integer v_listenerNot2CallIdx := -1;
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_listenerMustNotBeCalled(
|
| EPTF_LGenBase_ReportedEventDescriptor pl_event,
|
| EPTF_IntegerList pl_listenerArgs
|
| )
|
| runs on EPTF_LGenBase_CT{
|
| log("Event: ",pl_event);
|
| setverdict ( fail );
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_checkEvent(
|
| in EPTF_LGenBase_ReportedEventDescriptor pl_event,
|
| in EPTF_IntegerList pl_listenerArgs){
|
| select( pl_listenerArgs[0] )
|
| {
|
| case ( c_EPTF_LGenBase_eventTypeBehavior )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeGeneral )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.iIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetInput+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntity )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.iIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetInput+1] or
|
| pl_event.event.target.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntityIndex )
|
| {
|
| if(pl_event.event.target.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFSMOfEntity )
|
| {
|
| if(pl_event.event.target.fsmCtxIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetFSM+1] or
|
| pl_event.event.target.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfEntity )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.target.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntity )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.iIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetInput+1] or
|
| pl_event.event.source.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceFsm )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.iIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetInput+1] or
|
| pl_event.event.source.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceEntity+1] or
|
| pl_event.event.source.fsmCtxIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceFSM+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntityIndex )
|
| {
|
| if(pl_event.event.source.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFsmOfSourceEntity )
|
| {
|
| if(pl_event.event.source.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceEntity+1] or
|
| pl_event.event.source.fsmCtxIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceFSM+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfSourceEntity )
|
| {
|
| if(pl_event.event.bIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetBehavior+1] or
|
| pl_event.event.source.eIdx != pl_listenerArgs[c_EPTF_LGenBase_eventOffsetSourceEntity+1]){
|
| log(pl_event, pl_listenerArgs)
|
| setverdict ( fail );
|
| }
|
| }
|
| case else
|
| {
|
| setverdict ( fail );
|
| }
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_listener4Check(
|
| EPTF_LGenBase_ReportedEventDescriptor pl_event,
|
| EPTF_IntegerList pl_listenerArgs
|
| )
|
| runs on EPTF_LGenBase_TestListeners_CT{
|
| f_EPTF_LGenBase_Test_checkEvent(pl_event, pl_listenerArgs);
|
| v_calledListeners[pl_listenerArgs[0]] := v_calledListeners[pl_listenerArgs[0]] + 1;
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_msgStep (EPTF_LGenBase_TestStepArgs pl_ptr)
|
| runs on EPTF_LGenBase_TestListeners_CT{
|
| //f_EPTF_LGenBase_Test_checkEvent(pl_ptr., pl_ptr.refContext.fRefArgs);
|
| v_calledListeners[c_EPTF_LGenBase_eventTypeFSM] := v_calledListeners[c_EPTF_LGenBase_eventTypeFSM] + 1;
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_addRemoveDummyListeners()
|
| runs on EPTF_LGenBase_TestListeners_CT{
|
| for ( var integer vl_i := 0; vl_i < c_LGenBase_TestListeners_dummy2Add ; vl_i := vl_i+1 )
|
| {
|
| v_dummyInt := f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {vl_i})
|
| }
|
| for ( var integer vl_i := 0; vl_i < c_LGenBase_TestListeners_dummy2Remove ; vl_i := vl_i+1 )
|
| {
|
| f_EPTF_LGenBase_removeListener(vl_i);
|
| }
|
| }
|
|
|
| /*testcase tc_EPTF_LGenBase_Test_addRemoveListeners() runs on EPTF_LGenBase_TestListeners_CT{
|
| f_EPTF_LGenBase_init("tc_EPTF_LGenBase_Test_addRemoveListeners", 0, "e_", orig);
|
| var integer vl_baseCount := f_EPTF_FBQ_getOrCreateFreeSlot(v_LGenBase_listenersQueue); //f_EPTF_FBQ_getLengthOfBusyChain(v_LGenBase_listenersQueue);
|
| if(vl_baseCount != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {0})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {0})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {0})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+2 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), {0})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+2 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), {0})){
|
| setverdict ( fail );
|
| }
|
| f_EPTF_LGenBase_removeListener(vl_baseCount+1);
|
| f_EPTF_LGenBase_removeListener(vl_baseCount+1);
|
| f_EPTF_LGenBase_removeListener(vl_baseCount+1);
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), {1})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), {1})){
|
| setverdict ( fail );
|
| }
|
| if(vl_baseCount+1 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), {1})){
|
| setverdict ( fail );
|
| }
|
| f_EPTF_LGenBase_removeListener(vl_baseCount+1);
|
| if(vl_baseCount+3 != f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {2})){
|
| setverdict ( fail );
|
| }
|
| if(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled) != v_LGenBase_listeners[vl_baseCount].listener.fn or
|
| 0 != sizeof(v_LGenBase_listeners[vl_baseCount].listener.args) or
|
| 1 != v_LGenBase_listeners[vl_baseCount].refCount){
|
| setverdict ( fail );
|
| }
|
| if(refers(f_EPTF_LGenBase_Test_listener4Check) != v_LGenBase_listeners[vl_baseCount+1].listener.fn or
|
| {1} != v_LGenBase_listeners[vl_baseCount+1].listener.args or
|
| 2 != v_LGenBase_listeners[vl_baseCount+1].refCount){
|
| setverdict ( fail );
|
| }
|
| if(refers(f_EPTF_LGenBase_Test_listener4Check) != v_LGenBase_listeners[vl_baseCount+2].listener.fn or
|
| {0} != v_LGenBase_listeners[vl_baseCount+2].listener.args or
|
| 2 != v_LGenBase_listeners[vl_baseCount+2].refCount){
|
| setverdict ( fail );
|
| }
|
| if(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled) != v_LGenBase_listeners[vl_baseCount+3].listener.fn or
|
| {2} != v_LGenBase_listeners[vl_baseCount+3].listener.args or
|
| 1 != v_LGenBase_listeners[vl_baseCount+3].refCount){
|
| setverdict ( fail );
|
| }
|
| setverdict(pass);
|
| f_EPTF_Base_cleanup_CT()
|
| }
|
| */
|
|
|
| template EPTF_IntegerList t_EPTF_LGenBase_Test_ListenerArgs(
|
| in integer pl_behavior := -1,
|
| in integer pl_input := -1,
|
| in integer pl_entity := -1,
|
| in integer pl_fsm := -1,
|
| in integer pl_source := -1,
|
| in integer pl_sourceFSM := -1):={
|
| -1, pl_behavior, pl_input, pl_entity, pl_fsm, pl_source, pl_sourceFSM
|
| }
|
| function f_EPTF_LGenBase_Test_fillListenerArgs(
|
| in EPTF_LGenBase_EventType pl_type,
|
| inout EPTF_IntegerList pl_listenerArgs)
|
| runs on EPTF_LGenBase_TestListeners_CT{
|
| select( pl_type )
|
| {
|
| case ( c_EPTF_LGenBase_eventTypeBehavior )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(pl_behavior := v_behavOK));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeGeneral )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(pl_behavior := v_behavOK, pl_input := v_secondInput));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_behavior := v_behavOK,
|
| pl_input := v_secondInput,
|
| pl_entity := 1
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntityIndex )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_entity := 1
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFSMOfEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_entity := 1,
|
| pl_fsm := 0
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_behavior := v_behavOK,
|
| pl_entity := 1
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_behavior := v_behavOK,
|
| pl_input := v_secondInput,
|
| pl_source := 1
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceFsm )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_behavior := v_behavOK,
|
| pl_input := v_secondInput,
|
| pl_source := 1,
|
| pl_sourceFSM := 0
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntityIndex )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_source := 1
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFsmOfSourceEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_source := 1,
|
| pl_sourceFSM := 0
|
| ));
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfSourceEntity )
|
| {
|
| pl_listenerArgs := valueof(t_EPTF_LGenBase_Test_ListenerArgs(
|
| pl_behavior := v_behavOK,
|
| pl_source := 1
|
| ));
|
| }
|
| case else
|
| {
|
| setverdict ( fail );
|
| }
|
| }
|
| }
|
|
|
| //type record of
|
| function f_EPTF_LGenBase_Test_activateListeners(
|
| in EPTF_LGenBase_EventType pl_type)
|
| runs on EPTF_LGenBase_TestListeners_CT{
|
| var EPTF_IntegerList vl_listenerArgs := {};
|
| f_EPTF_LGenBase_Test_fillListenerArgs(pl_type, vl_listenerArgs);
|
| vl_listenerArgs[0] := pl_type;
|
| select( pl_type )
|
| {
|
| case ( c_EPTF_LGenBase_eventTypeBehavior )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateBehaviorListener(v_behavFail, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateBehaviorListener(v_behavOK, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateBehaviorListener(v_behavOK, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeGeneral )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateGeneralListener(v_behavFail,v_secondInput, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateGeneralListener(v_behavOK, v_secondInput, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateGeneralListener(v_behavOK, v_secondInput, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateEntityListener(v_behavFail,v_secondInput, 1, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateEntityListener(v_behavOK, v_secondInput, 1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateEntityListener(v_behavOK, v_secondInput, 1, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeEntityIndex )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateEntityIdxListener(2, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateEntityIdxListener(1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateEntityIdxListener(1, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFSMOfEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateFSMOfEntityListener(0, 0, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateFSMOfEntityListener(1, 0, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateFSMOfEntityListener(1, 0, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateBehaviorOfEntityListener(v_behavFail,1, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateBehaviorOfEntityListener(v_behavOK, 1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateBehaviorOfEntityListener(v_behavOK, 1, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateSourceEntityListener(v_behavFail,v_secondInput, 1, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateSourceEntityListener(v_behavOK, v_secondInput, 1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateSourceEntityListener(v_behavOK, v_secondInput, 1, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceFsm )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateSourceFsmListener(v_behavFail,v_secondInput, 1, 0, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateSourceFsmListener(v_behavOK, v_secondInput, 1, 0, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateSourceFsmListener(v_behavOK, v_secondInput, 1, 0, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeSourceEntityIndex )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateSourceEntityIndexListener(0, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateSourceEntityIndexListener(1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateSourceEntityIndexListener(1, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeFsmOfSourceEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateFsmOfSourceEntityListener(0, 0, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateFsmOfSourceEntityListener(1, 0, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateFsmOfSourceEntityListener(1, 0, v_listener[pl_type][0]);
|
| }
|
| case ( c_EPTF_LGenBase_eventTypeBehaviorOfSourceEntity )
|
| {
|
| //Listener not to call
|
| v_activatedIdxs[pl_type][0] :=
|
| f_EPTF_LGenBase_activateBehaviorOfSourceEntityListener(v_behavFail, 0, v_listenerNot2CallIdx);
|
| //Listeners to call
|
| v_listener[pl_type][0] :=
|
| f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listener4Check), vl_listenerArgs);
|
| log("------ Adding BehaviorOfSourceEntityListener ", vl_listenerArgs)
|
| //f_EPTF_LGenBase_Test_behaviorOfSourceListener
|
| v_activatedIdxs[pl_type][1] :=
|
| f_EPTF_LGenBase_activateBehaviorOfSourceEntityListener(v_behavOK, 1, v_listener[pl_type][0]);
|
| v_activatedIdxs[pl_type][2] :=
|
| f_EPTF_LGenBase_activateBehaviorOfSourceEntityListener(v_behavOK, 1, v_listener[pl_type][0]);
|
| }
|
| case else
|
| {
|
| setverdict ( fail );
|
| }
|
| }
|
| }
|
|
|
| testcase tc_EPTF_LGenBase_Test_activateListeners() runs on EPTF_LGenBase_TestListeners_CT{
|
| f_EPTF_LGenBase_init("tc_EPTF_LGenBase_Test_behaviorListeners", 0, "e_", orig);
|
| f_EPTF_LGenBase_Test_addRemoveDummyListeners()
|
| const charstring c_behavName := "tc_EPTF_LGenBase_Test_activateListenersBehavior";
|
| const charstring c_behavNameNot2Call := "tc_EPTF_LGenBase_Test_activateNot2CallListenersBehavior";
|
| const charstring c_firstInputName := "tc_EPTF_LGenBase_Test_activateListeners_firstInput";
|
| const charstring c_secondInputName := "tc_EPTF_LGenBase_Test_activateListeners_secondInput";
|
| const charstring c_thirdInputName := "tc_EPTF_LGenBase_Test_activateListeners_thirdInput";
|
| v_behavFail := f_EPTF_LGenBase_declareBehaviorType(c_behavNameNot2Call, -1, null, null, null)
|
| v_behavOK := f_EPTF_LGenBase_declareBehaviorType(c_behavName, -1, null, null, null)
|
| v_firstInput := f_EPTF_LGenBase_declareFsmEvent(c_behavName, c_firstInputName)
|
| v_secondInput := f_EPTF_LGenBase_declareFsmEvent(c_behavName, c_secondInputName)
|
| v_thirdInput := f_EPTF_LGenBase_declareFsmEvent(c_behavName, c_thirdInputName)
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent(c_behavNameNot2Call, c_firstInputName)
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent(c_behavNameNot2Call, c_secondInputName)
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent(c_behavNameNot2Call, c_thirdInputName)
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("TestEntityType",{c_behavNameNot2Call,c_behavName});
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eGroup","TestEntityType",25});
|
|
|
| var integer vl_tIdx := f_EPTF_LGenBase_declareCompactFsmTable({
|
| name := "activateListenersTestFsm",
|
| // [0]
|
| stateList := {"idle"},
|
| timerList := {},
|
| table := {
|
| {eventToListen := {v_behavOK,v_secondInput,fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{refers(f_EPTF_LGenBase_Test_msgStep),{}}}, omit,0}
|
| }
|
| }
|
| }
|
| }
|
| );
|
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= 0, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1)
|
| v_dummyInt := f_EPTF_LGenBase_activateFsm(pl_eIdx:= 1, pl_tIdx:= vl_tIdx, pl_sIdx:=0, pl_tcIdx:= -1)
|
|
|
| v_listenerNot2CallIdx := f_EPTF_LGenBase_addListener(refers(f_EPTF_LGenBase_Test_listenerMustNotBeCalled), {-1});
|
|
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeBehavior )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeGeneral )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeEntity )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeEntityIndex )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeFSMOfEntity )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeBehaviorOfEntity )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeSourceEntity )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeSourceFsm )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeSourceEntityIndex )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeFsmOfSourceEntity )
|
| f_EPTF_LGenBase_Test_activateListeners( c_EPTF_LGenBase_eventTypeBehaviorOfSourceEntity )
|
|
|
| //Event to be dispatched to the behavior and general listeners
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_secondInput, omit, omit},{}});
|
| if(v_calledListeners != {2,2,0,0,0,0,0,0,0,0,0,0}){
|
| log(v_calledListeners)
|
| setverdict(fail)
|
| }
|
| v_calledListeners := c_initCalledListeners;
|
|
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_thirdInput, omit, omit},{}});
|
| if(v_calledListeners != {2,0,0,0,0,0,0,0,0,0,0,0}){
|
| log(v_calledListeners)
|
| log(match(v_calledListeners,{2,0,0,0,0,0,0,0,0,0,0,0}))
|
| setverdict(fail)
|
| }
|
| v_calledListeners := c_initCalledListeners;
|
|
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_secondInput, {1, omit}, omit},{}});
|
| if(v_calledListeners != {2,2,2,0,2,0,2,0,0,0,0,0}){
|
| log(v_calledListeners)
|
| log(match(v_calledListeners,{2,2,2,0,2,0,2,0,0,0,0,0}))
|
| setverdict(fail)
|
| }
|
| v_calledListeners := c_initCalledListeners;
|
|
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_secondInput, {1, 0}, omit},{}});
|
| if(v_calledListeners != {2,2,2,1,2,2,2,0,0,0,0,0}){
|
| log(v_calledListeners)
|
| log(match(v_calledListeners,{2,2,2,1,2,2,2,0,0,0,0,0}))
|
| setverdict(fail)
|
| }
|
| v_calledListeners := c_initCalledListeners;
|
|
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_secondInput, {1, 0}, {1, omit}},{}});
|
| if(v_calledListeners != {2,2,2,1,2,2,2,2,0,2,0,2}){
|
| log(v_calledListeners)
|
| log(match(v_calledListeners,{2,2,2,1,2,2,2,2,0,2,0,2}))
|
| setverdict(fail)
|
| }
|
| v_calledListeners := c_initCalledListeners;
|
|
|
| f_EPTF_LGenBase_dispatchEvent({{v_behavOK, v_secondInput, {1, 0}, {1, 0}},{}});
|
| if(v_calledListeners != {2,2,2,1,2,2,2,2,2,2,2,2}){
|
| log(v_calledListeners)
|
| log(match(v_calledListeners,{2,2,2,1,2,2,2,2,2,2,2,2}))
|
| setverdict(fail)
|
| }
|
| /*
|
| var integer vl_count := sizeof(v_activatedIdxs[c_EPTF_LGenBase_eventTypeBehavior]);
|
| for ( var integer vl_i := 0; vl_i < vl_count ; vl_i := vl_i+1 )
|
| {
|
| f_EPTF_LGenBase_deactivateBehaviorListener(v_behavOK, v_activatedIdxs[vl_i]);
|
| }
|
|
|
| var EPTF_LGenBase_ReportedEventDescriptor vl_event := {{v_behavOK, v_secondInput, {1, 0}, {1, omit}},{}};
|
|
|
| f_EPTF_LGenBase_reportEvent4Behavior(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4Generic(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4Entity(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4EntityIdx(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4BehaviorOfEntity(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4Fsm(vl_event,false,vl_event.event.bIdx, vl_event.event.iIdx);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4FSMOfEntity(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4SourceEntity(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4SourceEntityIndex(vl_event);
|
| log(v_calledListeners)
|
| f_EPTF_LGenBase_reportEvent4BehaviorOfSourceEntity(vl_event);
|
| log(v_calledListeners)
|
| */
|
| f_EPTF_Base_cleanup_CT()
|
| setverdict(pass);
|
| }
|
| } // group listeners
|
|
|
| function f_EPTF_LGenBase_Test_entityCounts()
|
| runs on EPTF_LGenBase_CT
|
| return EPTF_IntegerList{
|
| var EPTF_IntegerList vl_ret := {}
|
| vl_ret[0] := f_EPTF_LGenBase_getETypeAvailableByName("et1");
|
| vl_ret[1] := f_EPTF_LGenBase_getETypeAvailableByName("et2");
|
| vl_ret[2] := f_EPTF_LGenBase_getETypeAvailableByName("et3");
|
| vl_ret[3] := f_EPTF_LGenBase_getETypeAvailableByName("et4");
|
| vl_ret[4] := f_EPTF_LGenBase_getETypeAvailableByName("et1-2");
|
| vl_ret[5] := f_EPTF_LGenBase_getETypeAvailableByName("et1-3");
|
| vl_ret[6] := f_EPTF_LGenBase_getETypeAvailableByName("et2-4");
|
| return vl_ret;
|
| }
|
|
|
| testcase tc_EPTF_LGenBase_Test_entityCounts() runs on EPTF_LGenBase_Test_CT{
|
| f_EPTF_LGenBase_init("tc_EPTF_LGenBase_Test_entityCounts", 0, "e_", orig);
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b1", 17, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b2", 5, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b3", -1, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b4", 16, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et1", {"b1"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et2", {"b2"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et3", {"b3"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et4", {"b4"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et1-2", {"b1","b2"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et1-3", {"b1","b3"});
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et2-4", {"b2","b4"});
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eg1", "et1-2", 3})
|
| if({14,2,-1,16,2,14,2} != f_EPTF_LGenBase_Test_entityCounts()){
|
| log(f_EPTF_LGenBase_Test_entityCounts())
|
| setverdict(fail);
|
| }
|
| setverdict(pass)
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eg2", "et1-3", 16})
|
| if({0,2,-1,16,0,0,2} != f_EPTF_LGenBase_Test_entityCounts()){
|
| log(f_EPTF_LGenBase_Test_entityCounts())
|
| setverdict(fail);
|
| }
|
| setverdict(pass);
|
| f_EPTF_Base_cleanup_CT()
|
| }
|
|
|
| testcase tc_EPTF_LGenBase_Test_entityCounts2() runs on EPTF_LGenBase_Test_CT{
|
| f_EPTF_LGenBase_init("tc_EPTF_LGenBase_Test_entityCounts", 0, "e_", orig);
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType("b1", 100, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et1", {"b1"});
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eg1", "et1", 20})
|
| if(80 != f_EPTF_LGenBase_getETypeAvailableByName("et1")){
|
| setverdict(fail);
|
| }
|
| setverdict(pass);
|
| f_EPTF_Base_cleanup_CT()
|
| }
|
|
|
| // test cases for using external templates
|
| group externalTemplateTests
|
| {
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Testcase: tc_LGenBase_Test_externalTemplates
|
| //
|
| // Purpose:
|
| // Testcase to check the 'external templates' feature
|
| //
|
| // 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
|
| //
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_LGenBase_Test_externalTemplates() runs on EPTF_LGenBase_Test_CT
|
| {
|
| const charstring extTemplName1 := "dummy";
|
| const charstring extTemplName2 := "dummy2";
|
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {extTemplName1, tsp_dummyTemplatePath, true}, {extTemplName2,
|
| "file_not_exist.txt", 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);
|
| // check dummy template exist, other one not exist
|
| if ( f_EPTF_LGenBase_getExtTemplIdx(extTemplName1) >= 0 and
|
| f_EPTF_LGenBase_getExtTemplIdx(extTemplName2) == -1 )
|
| {
|
| log("External template loaded OK");
|
| }
|
| else
|
| {
|
| log("Could not load external templates");
|
| setverdict(fail);
|
| }
|
|
|
| // 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, {"VEGETABLE"}, {"FRUIT", "FISH", "MEAT"})
|
| 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 content1 := "", content2:="";
|
|
|
| // 5.1 get content by position-based parameter assign
|
| var integer templateItemIdx := f_EPTF_LGenBase_getTemplateItemIdxFromSet(setId, templTypeIdx);
|
| if (templateItemIdx < 0)
|
| {
|
| log("Template type not found in template set");
|
| setverdict(fail);
|
| }
|
| if(f_EPTF_LGenBase_getTemplateContentFast(setId, templateItemIdx, {"carrot", "apple", "salmon", "pork"}, content1))
|
| {
|
| log("Positional parameter substitution done OK");
|
| log("Result:\n", 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, {{"FRUIT","apple"}, {"VEGETABLE","carrot"}, {"MEAT","pork"}}, content2))
|
| {
|
| log("Dictionary-based parameter substitution done OK");
|
| log("Result:\n", content2);
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Parameter substitution failed");
|
| setverdict(fail);
|
| }
|
|
|
| if(content1 != content2)
|
| {
|
| log("Substituted contents are not equal!");
|
| setverdict(fail);
|
| }
|
|
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| function f_EPTF_LGenBase_TemplateContentGetter_Dummy(
|
| in integer pl_extTemplateIdx,
|
| in EPTF_LGenBase_TemplParamSubstList pl_dictionary,
|
| inout charstring pl_content
|
| )
|
| runs on EPTF_LGenBase_extTemplate_CT
|
| return boolean
|
| {
|
| pl_content := c_LGenBase_TemplateContentGetter_Dummy_Content;
|
| return true;
|
| }
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Testcase: tc_LGenBase_Test_externalTemplates_fixedPosition
|
| //
|
| // Purpose:
|
| // Testcase to check the 'external templates fixed position' feature
|
| //
|
| // 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
|
| //
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_LGenBase_Test_externalTemplates_fixedPosition() runs on EPTF_LGenBase_extTemplate_CT
|
| {
|
| const charstring extTemplName1 := "dummy";
|
| const charstring extTemplName2 := "dummy2";
|
| var charstring content1;
|
| var charstring content2;
|
|
|
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {extTemplName1, tsp_dummyTemplatePath, true}, {extTemplName2,
|
| "file_not_exist.txt", false} }
|
|
|
| // 1. load the external template list
|
| log("Init component and load external template list");
|
| f_EPTF_LGenBase_extTemplate_init_CT(
|
| "LGenBase Fiexed Postion Template Test",
|
| pl_extTemplLoadList := extTemplLoadList,
|
| pl_templateGetterMode := { fixedPosGetter := { orderedMacroNameList := {"FRUIT", "VEGETABLE", "MEAT", "SPICE"}}} );
|
| // check dummy template exist, other one not exist
|
| if ( f_EPTF_LGenBase_getExtTemplIdx(extTemplName1) >= 0 and
|
| f_EPTF_LGenBase_getExtTemplIdx(extTemplName2) == -1 )
|
| {
|
| log("External template loaded OK");
|
| }
|
| else
|
| {
|
| setverdict(fail, "Could not load external templates");
|
| f_EPTF_Base_stop();
|
| }
|
|
|
| var integer extTemplIdx := f_EPTF_LGenBase_getExtTemplIdx(extTemplName1);
|
|
|
| if(f_EPTF_LGenBase_applyTemplateContentGetter(extTemplIdx, c_LGenBase_extTemplate_dummyTemplate_Substitution_Dictionary, content1) and
|
| content1 == c_LGenBase_extTemplate_dummyTemplate_Substitution_Result)
|
| {
|
| log("Default External Template Content Function substitution done OK");
|
| log("Result:\n", content1);
|
| }
|
| else
|
| {
|
| setverdict(fail, "Default External Template Content Function substitution failed:\n" & content1);
|
| f_EPTF_Base_stop();
|
| }
|
|
|
| if(f_EPTF_LGenBase_extTemplFixedPos_getTemplateContent(extTemplIdx, c_LGenBase_extTemplate_dummyTemplate_Substitution_Dictionary, content2) and
|
| content2 == c_LGenBase_extTemplate_dummyTemplate_Substitution_Result)
|
| {
|
| log("f_EPTF_LGenBase_extTemplFixedPos_getTemplateContent paramter substitution done OK");
|
| log("Result:\n", content2);
|
| }
|
| else
|
| {
|
| setverdict(fail, "f_EPTF_LGenBase_extTemplFixedPos_getTemplateContent parameter substitution failed:\n" & content1);
|
| f_EPTF_Base_stop();
|
| }
|
|
|
| f_EPTF_LGenBase_setTemplateContentGetter(refers(f_EPTF_LGenBase_TemplateContentGetter_Dummy));
|
|
|
| if(f_EPTF_LGenBase_applyTemplateContentGetter(-1, {}, content1) and
|
| content1 == c_LGenBase_TemplateContentGetter_Dummy_Content) {
|
| log("f_EPTF_LGenBase_setTemplateContentGetter properly changed template getter function pointer");
|
| }
|
| else {
|
| setverdict(fail, "f_EPTF_LGenBase_setTemplateContentGetter did not set template getter function pointer to expected function. Result:\n" & content1);
|
| }
|
|
|
| setverdict(pass);
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Testcase: tc_LGenBase_Test_extendTemplateType
|
| //
|
| // Purpose:
|
| // Testcase to check runtime modification of a declared template type
|
| //
|
| // Requirement:
|
| // dummy_template.txt external template file is available on filesystem
|
| //
|
| // Action:
|
| // - Loads an external template, creates template set, declares a template types and assigns with external template
|
| // - extend template type with new optional parameters
|
| // - registers callback functions to parameters
|
| // - sets start and finish callback
|
| // - checks if parameter substitution is correct after template type modification
|
| //
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_LGenBase_Test_extendTemplateType() runs on EPTF_LGenBase_Test_CT
|
| {
|
| const charstring extTemplName := "dummy";
|
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {extTemplName, tsp_dummyTemplatePath, true} }
|
| // load the external template list
|
| f_EPTF_LGenBase_init("LGenBase Templates Test", pl_extTemplLoadList := extTemplLoadList);
|
| // create a new template set
|
| var integer setId := f_EPTF_LGenBase_createTemplateSet();
|
| // declare a new template type
|
| var EPTF_LGenBase_TemplateTypeKey templTypeKey1 := {"MYBEHAVOUR", "dummy1"};
|
| var EPTF_LGenBase_TemplateTypeKey templTypeKey2 := {"MYBEHAVOUR", "dummy2"};
|
| var integer templTypeIdx1 := f_EPTF_LGenBase_declareTemplateType(templTypeKey1, {"VEGETABLE"}, {"FRUIT"})
|
|
|
| var integer templTypeIdx2 := f_EPTF_LGenBase_declareTemplateTypeWithCallbacks(
|
| templTypeKey2,
|
| { {"FRUIT",omit} }, // mandatory parameters
|
| { {"FISH",omit}, {"SPICE",omit}, {"MEAT",omit}, {"VEGETABLE",refers(parameterCallback)} } // optional parameters
|
| )
|
| // assign declared template type to 'dummy' template
|
| var integer templateItemIdx1 := f_EPTF_LGenBase_assignExtTemplToTemplType3(setId, templTypeKey1, extTemplName);
|
| var integer templateItemIdx2 := f_EPTF_LGenBase_assignExtTemplToTemplType3(setId, templTypeKey2, extTemplName);
|
|
|
| //extend template type wuth new param
|
| if (f_EPTF_LGenBase_extendTemplateType(templTypeIdx1, {"MEAT", "FISH"}))
|
| {
|
| log("Extending template type OK");
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Extending template type failed");
|
| setverdict(fail);
|
| }
|
| //register param callbacks and extend with new param
|
| if (f_EPTF_LGenBase_extendTemplateTypeWithCallback(templTypeIdx1, { {"VEGETABLE", refers(parameterCallback)}, {"SPICE", refers(parameterCallback)} } ))
|
| {
|
| log("Extending template type1 OK");
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Extending template type1 failed");
|
| setverdict(fail);
|
| }
|
| if (f_EPTF_LGenBase_extendTemplateTypeWithCallback(templTypeIdx2, { {"SPICE", refers(parameterCallback)} } ))
|
| {
|
| log("Extending template type2 OK");
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Extending template type2 failed");
|
| setverdict(fail);
|
| }
|
| // register start abd finish callbacks
|
| f_EPTF_LGenBase_setStartCallbackToTemplateType(templTypeIdx2, refers(startCallback));
|
| f_EPTF_LGenBase_setFinishCallbackToTemplateType(templTypeIdx2, refers(finishCallback));
|
| // get substituted template content
|
| var charstring content1 := "", content2:="";
|
| var EPTF_IntegerList list := {};
|
| if (f_EPTF_LGenBase_getTemplateContentFastWithCallbackArgs(setId, templateItemIdx1, {"carrot", "apple", "pork", "salmon", "sugar" }, list, content1))
|
| {
|
| log("Substitution done OK");
|
| log("Result:\n", content1);
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Parameter substitution failed");
|
| setverdict(fail);
|
| }
|
| if (f_EPTF_LGenBase_getTemplateContentFastWithCallbackArgs(setId, templateItemIdx2, {"apple", "salmon", "sugar", "pork", "carrot" }, list, content2))
|
| {
|
| log("Substitution done OK");
|
| log("Result:\n", content2);
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("Parameter substitution failed");
|
| setverdict(fail);
|
| }
|
| // check substituted contents are equal
|
| if (content1 != content2)
|
| {
|
| log("Substituted contents are not equal, test failed");
|
| setverdict(fail);
|
| }
|
| // check start/finish callbacks called correctly
|
| if (list == {1,2,3})
|
| {
|
| log("start/finish callback OK, list:", list);
|
| setverdict(pass);
|
| }
|
| else
|
| {
|
| log("start/finish callback failed, list:", list);
|
| setverdict(fail);
|
| }
|
| f_EPTF_Base_cleanup_CT()
|
| }
|
| function startCallback(inout EPTF_IntegerList intList, inout EPTF_CharstringList paramvalues) runs on EPTF_LGenBase_Test_CT
|
| {
|
| log("+++++++++++++++++++++++++++++");
|
| log("HELLO, THIS IS START CALLBACK");
|
| log("I got contextArgs:", intList, " , param:", paramvalues);
|
| intList := {1,0,0}
|
| log("I return contextArgs:", intList, " , param:", paramvalues);
|
|
|
| }
|
| function finishCallback(inout EPTF_IntegerList intList, inout EPTF_CharstringList paramvalues) runs on EPTF_LGenBase_Test_CT
|
| {
|
| log("HELLO, THIS IS FINISH CALLBACK");
|
| log("I got contextArgs:", intList, " , param:", paramvalues);
|
| if (sizeof(intList)==3 and isvalue(intList[0]) and isvalue(intList[1]) and isvalue(intList[2]))
|
| {
|
| intList[2] := intList[0] + intList[1]
|
| }
|
| else {
|
| log(%definitionId, ": Error: call back context args are uninitialized!")
|
| setverdict(fail);
|
| stop
|
| }
|
| log("I return contextArgs:", intList, " , param:", paramvalues);
|
| log("+++++++++++++++++++++++++++++");
|
| }
|
| function parameterCallback(inout EPTF_IntegerList intList, inout charstring paramvalue)
|
| runs on EPTF_LGenBase_Test_CT
|
| {
|
| log("==>HELLO, THIS IS PARAM CALLBACK, I got contextArgs:", intList, " , param:", paramvalue);
|
| if (sizeof(intList)==3 and isvalue(intList[0]) and isvalue(intList[1]) and isvalue(intList[2]))
|
| {
|
| intList[1] :=intList[1]+ 1
|
| } else {
|
| }
|
| paramvalue := "@@@" & paramvalue & "@@@";
|
| log("==>HELLO, THIS IS PARAM CALLBACK, I return contextArgs:", intList, " , param:", paramvalue);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Testcase: tc_LGenBase_Test_configureTemplateSet
|
| //
|
| // Purpose:
|
| // Testcase to check configuring and using a template set belongs to a traffic case
|
| //
|
| // Requirement:
|
| // dummy_template.txt external template file is available on filesystem
|
| //
|
| // Action:
|
| // - Loads an external template by intiialization of LGenBase
|
| // - declares a template type
|
| // - declares a scenarion with a template set inside
|
| // - starts traffic case
|
| // - during traffic case substitutes template with sample values and logs content
|
| //
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_LGenBase_Test_configureTemplateSet() runs on EPTF_LGenBase_Test_CT
|
| {
|
| //constants
|
| const charstring c_extTemplName := "Dummy Template";
|
| const charstring c_entityType := "TemplateConfig EntityType";
|
| const charstring c_entityGroup := "TemplateConfig EntityGroup";
|
| const charstring c_trafficCase := "TemplateConfig TrafficCase";
|
| const charstring c_scenario := "TemplateConfig Scenario";
|
| const charstring c_fsmName := "TemplateConfig Test FSM";
|
| const EPTF_LGenBase_CompactFsmTable c_lGenFsm :=
|
| {
|
| name := c_fsmName,
|
| stateList := {"idle", "busy"},
|
| timerList := {},
|
| table :=
|
| {
|
| {
|
| eventToListen := { c_EPTF_LGenBase_bIdx, c_EPTF_LGenBase_inputIdx_testMgmt_startTC, fsm},
|
| cellRow :=
|
| {
|
| //state[0]==idle
|
| {{{refers(f_useTemplate),{}}}, omit,omit}
|
| }
|
| }
|
| }
|
| }
|
|
|
| // init component and load external template list
|
| var EPTF_LGenBase_ExtTemplLoadList extTemplLoadList := { {c_extTemplName, tsp_dummyTemplatePath, true} }
|
| f_EPTF_LGenBase_init("LGenBase Templates Config Test", pl_extTemplLoadList := extTemplLoadList);
|
|
|
| // declare template type
|
| var integer templTypeIdx := f_EPTF_LGenBase_declareTemplateType(
|
| {c_behavior, c_templTypeName}, // template typekey
|
| {"VEGETABLE"}, // mandatory params
|
| {"FRUIT", "FISH", "MEAT"} ); // optional params
|
| if (templTypeIdx < 0)
|
| {
|
| log("Could not declare template type");
|
| setverdict(fail);
|
| }
|
|
|
| v_dummyInt := f_EPTF_LGenBase_declareBehaviorType(c_behavior, 1, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareCompactFsmTable(c_lGenFsm);
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType(c_entityType, {c_behavior});
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup( { c_entityGroup, c_entityType, 1 } );
|
|
|
| //adding the behaviour
|
| var integer groupIdx := f_EPTF_LGenBase_entityGrpNameIndex(c_entityGroup);
|
| var integer groupBaseOffsetIdx := f_EPTF_LGenBase_getEGrpBaseOffset(groupIdx);
|
| log ("groupIdx: ",groupIdx," groupBaseOffsetIdx: ",groupBaseOffsetIdx);
|
|
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2(
|
| {
|
| name := c_trafficCase,
|
| fsmName := c_fsmName,
|
| entityType := c_entityType,
|
| customEntitySucc := ""
|
| });
|
|
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| {
|
| name := c_scenario,
|
| tcList := {
|
| {
|
| tcName := c_trafficCase,
|
| tcParamsList := {
|
| {target := {cpsToReach := 1.0}},
|
| {scheduler := { preDefinedName := orig }},
|
| {enableEntitiesAtStart := true},
|
| {enabledAtStart := true},
|
| {templateSet :=
|
| {
|
| // this is our template set contains only one template currently
|
| { c_behavior, c_templTypeName, c_extTemplName }
|
| }
|
| }
|
| }
|
| }
|
| },
|
| scParamsList := {}
|
| });
|
|
|
| f_EPTF_LGenBase_createScenario2EntityGroup( { c_entityGroup, c_scenario } );
|
| v_dummyBool := f_EPTF_LGenBase_wait4TestFinished(2.0)
|
| //f_EPTF_LGenBase_stopTrafficCase( c_entityGroup, c_scenario, c_trafficCase);
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| // constants for tc_LGenBase_Test_configureTemplateSet test case
|
| const charstring c_behavior := "TemplateConfig Behavior";
|
| const charstring c_templTypeName := "Dummy Template";
|
|
|
| // fsm callback function for tc_LGenBase_Test_configureTemplateSet test case
|
| function f_useTemplate(in EPTF_LGenBase_TestStepArgs pl_ptr) runs on EPTF_LGenBase_Test_CT
|
| {
|
| // get index of template set belongs to current traffic case
|
| var integer tset := f_EPTF_LGenBase_templateSetIdxOfStep(pl_ptr);
|
| if (tset < 0)
|
| {
|
| log("Traffic case doesn't have template set");
|
| setverdict(fail);
|
| return;
|
| }
|
| // get substituted template content
|
| // NOTE: using getTemplateContentFast could be more efficient
|
| var charstring content := "";
|
| if (not f_EPTF_LGenBase_getTemplateContentByTemplTypeKey(
|
| tset,
|
| {c_behavior, c_templTypeName},
|
| {"carrot", "apple", "salmon", "pork"},
|
| content) )
|
| {
|
| log("Parameter substitution didn't succeed");
|
| setverdict(fail);
|
| return;
|
| }
|
| log("Parameter substitution done OK");
|
| log("Result: ", content);
|
| setverdict(pass);
|
| v_LGenBase_testFinished := true
|
| }
|
|
|
| } // end of group externalTemplateTests
|
|
|
| group fsmVariablesAndStatistics{
|
|
|
| type component EPTF_LGenBase_VarAndStatTest_CT extends EPTF_LGenBase_Test_CT{
|
| var EPTF_BooleanList v_LGenBase_VarAndStatTest_stepsPassed := {false,false,false,false}
|
| var integer v_LGenBase_VarAndStatTest_behav := -1;
|
| var EPTF_IntegerList v_LGenBase_entityCalled := {};
|
| }
|
|
|
| //
|
| function f_LGenBase_Test_checkFSMVar(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr,
|
| in charstring pl_varName,
|
| in integer pl_scope,
|
| in float pl_expectedContent,
|
| in integer pl_passedIdx)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT
|
| {
|
| var charstring vl_name := ""
|
| select( pl_scope ){
|
| case ( c_EPTF_LGenBase_fsmObjectScopeFSM ){
|
| vl_name := f_EPTF_LGenBase_varNameOfFSMVar(pl_ptr.eIdx, pl_ptr.refContext.fCtxIdx, pl_varName);
|
| }
|
| case ( c_EPTF_LGenBase_fsmObjectScopeTC ){
|
| vl_name := f_EPTF_LGenBase_varNameOfTCVar(
|
| f_EPTF_LGenBase_tcIdxOfFSM(pl_ptr.eIdx, pl_ptr.refContext.fCtxIdx),
|
| pl_varName);
|
| }
|
| case else{
|
| setverdict(inconc,"Unknown scope: ",pl_scope)
|
| }
|
| }
|
| var integer vl_varId := f_EPTF_Var_getId(vl_name);
|
| var integer vl_recId := f_EPTF_LGenBase_fsmVarIdFromStep(pl_ptr)
|
| if(2 != sizeof(pl_ptr.refContext.fRefArgs)){
|
| setverdict ( fail );
|
| log("Invalid arguments: ",pl_ptr.refContext.fRefArgs);
|
| }else{
|
| if(pl_scope != pl_ptr.refContext.fRefArgs[1]){
|
| setverdict ( fail );
|
| log("The received scope is: ", pl_ptr.refContext.fRefArgs[1]);
|
| }else{
|
| if(vl_varId != vl_recId){
|
| setverdict ( fail );
|
| log("ID of ",vl_name,": ",vl_varId," instead of the received ",vl_recId);
|
| }else{
|
| var EPTF_Var_DirectContent vl_currentContent;
|
| f_EPTF_Var_getContent(vl_varId, vl_currentContent)
|
| if(pl_expectedContent != vl_currentContent.floatVal){
|
| setverdict ( fail );
|
| log("The value is: ",vl_currentContent," instead of ",pl_expectedContent);
|
| }else{
|
| v_LGenBase_VarAndStatTest_stepsPassed[pl_passedIdx] := true;
|
| }
|
| }
|
| }
|
| }
|
| }
|
| function f_LGenBase_Test_checkFSMVar1(in EPTF_LGenBase_TestStepArgs pl_ptr)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT
|
| {
|
| f_LGenBase_Test_checkFSMVar(pl_ptr, "var1ofFSM1", c_EPTF_LGenBase_fsmObjectScopeFSM, 1.0, 0)
|
| }
|
|
|
| function f_LGenBase_Test_checkFSMVar2(in EPTF_LGenBase_TestStepArgs pl_ptr)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT
|
| {
|
| f_LGenBase_Test_checkFSMVar(pl_ptr, "TCvar2ofFSM1", c_EPTF_LGenBase_fsmObjectScopeTC, 2.0, 1)
|
| }
|
|
|
| function f_LGenBase_Test_checkFSMVar3(in EPTF_LGenBase_TestStepArgs pl_ptr)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT
|
| {
|
| f_LGenBase_Test_checkFSMVar(pl_ptr, "TCvar1ofFSM1", c_EPTF_LGenBase_fsmObjectScopeTC, 3.0, 2)
|
| }
|
|
|
| function f_LGenBase_Test_checkFSMVar4(in EPTF_LGenBase_TestStepArgs pl_ptr)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT
|
| {
|
| f_LGenBase_Test_checkFSMVar(pl_ptr, "var2ofFSM1", c_EPTF_LGenBase_fsmObjectScopeFSM, 4.0, 3)
|
| }
|
|
|
| group tcFsmVariables{
|
| const EPTF_LGenBase_FsmVarDeclaratorList c_LGenBase_Test_vars1 :={
|
| {
|
| name := "var1ofFSM1",
|
| initValue := {floatVal := 1.0},
|
| scope := FSM
|
| },
|
| {
|
| name := "TCvar2ofFSM1",
|
| initValue := {floatVal := 2.0},
|
| scope := TC
|
| },
|
| {
|
| name := "TCvar1ofFSM1",
|
| initValue := {floatVal := 3.0},
|
| scope := TC
|
| },
|
| {
|
| name := "var2ofFSM1",
|
| initValue := {floatVal := 4.0},
|
| scope := FSM
|
| }
|
| }
|
|
|
| const EPTF_LGenBase_FsmVarDeclaratorList c_LGenBase_Test_varsInt :={
|
| {
|
| name := "var1ofFSM1",
|
| initValue := {intVal := 1},
|
| scope := FSM
|
| },
|
| {
|
| name := "TCvar2ofFSM1",
|
| initValue := {intVal := 2},
|
| scope := TC
|
| },
|
| {
|
| name := "TCvar1ofFSM1",
|
| initValue := {intVal := 3},
|
| scope := TC
|
| },
|
| {
|
| name := "var2ofFSM1",
|
| initValue := {intVal := 4},
|
| scope := FSM
|
| }
|
| }
|
|
|
| function f_LGenBase_Test_fsmVariables_init(
|
| in integer pl_eCount := 3,
|
| in charstring pl_compName := "tc_LGenBase_Test_fsmVariables",
|
| in integer pl_firstGroupSize := 0)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_EPTF_LGenBase_init(pl_compName);
|
| v_LGenBase_VarAndStatTest_behav := f_EPTF_LGenBase_declareBehaviorType("b1", -1, null, null, null);
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input1");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input2");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input3");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input4");
|
| v_dummyInt := f_EPTF_LGenBase_declareEntityType("et1", {"b1"});
|
| v_dummyInt := f_EPTF_LGenBase_declareFunction("checkFSMVar1", {testStepFunction:= refers(f_LGenBase_Test_checkFSMVar1)})
|
| v_dummyInt := f_EPTF_LGenBase_declareFunction("checkFSMVar2", {testStepFunction:= refers(f_LGenBase_Test_checkFSMVar2)})
|
| v_dummyInt := f_EPTF_LGenBase_declareFunction("checkFSMVar3", {testStepFunction:= refers(f_LGenBase_Test_checkFSMVar3)})
|
| v_dummyInt := f_EPTF_LGenBase_declareFunction("checkFSMVar4", {testStepFunction:= refers(f_LGenBase_Test_checkFSMVar4)})
|
| if(0 < pl_firstGroupSize){
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eg0", "et1", pl_firstGroupSize})
|
| }
|
| v_dummyInt := f_EPTF_LGenBase_createEntityGroup({"eg1", "et1", pl_eCount})
|
| }
|
|
|
| const charstring c_LGenBase_Test_fsmVariablesFSMName := "tc_LGenBase_Test_fsmVariables_FSM1"
|
| const EPTF_LGenBase_FsmTableDeclarator c_LGenBase_Test_fsmVariablesFSM :=
|
| {
|
| name := c_LGenBase_Test_fsmVariablesFSMName,
|
| fsmParams := {
|
| {stateList := {"idle"}},
|
| {varList := c_LGenBase_Test_vars1}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := {"b1","input1",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{"checkFSMVar1",{varNames := {"var1ofFSM1"}}}}, omit, omit}
|
| }
|
| },
|
| {eventToListen := {"b1","input2",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{"checkFSMVar2",{varNames := {"TCvar2ofFSM1"}}}}, omit, omit}
|
| }
|
| },
|
| {eventToListen := {"b1","input3",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{"checkFSMVar3",{varNames := {"TCvar1ofFSM1"}}}}, omit, omit}
|
| }
|
| },
|
| {eventToListen := {"b1","input4",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{"checkFSMVar4",{varNames := {"var2ofFSM1"}}}}, omit, omit}
|
| }
|
| },
|
| {eventToListen := {"b1","input5",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {{{c_EPTF_LGenBase_stepName_fsmVarSet,{varParams := {"TCvar2ofFSM1",{floatVal := 9.5}}}}}, omit, omit}
|
| }
|
| }
|
| }
|
| }
|
| }
|
|
|
| function f_LGenBase_Test_fsmVariablesCheck(
|
| in integer pl_fsmCtxIdx := 0,
|
| in integer pl_eOffset := 0)
|
| runs on EPTF_LGenBase_VarAndStatTest_CT{
|
|
|
| f_EPTF_LGenBase_dispatchEvent({
|
| {v_LGenBase_VarAndStatTest_behav,0,{pl_eOffset+1,pl_fsmCtxIdx},omit},
|
| {}
|
| })
|
| f_EPTF_LGenBase_dispatchEvent({
|
| {v_LGenBase_VarAndStatTest_behav,1,{pl_eOffset+1,pl_fsmCtxIdx},omit},
|
| {}
|
| })
|
| f_EPTF_LGenBase_dispatchEvent({
|
| {v_LGenBase_VarAndStatTest_behav,2,{pl_eOffset+1,pl_fsmCtxIdx},omit},
|
| {}
|
| })
|
| f_EPTF_LGenBase_dispatchEvent({
|
| {v_LGenBase_VarAndStatTest_behav,3,{pl_eOffset+1,pl_fsmCtxIdx},omit},
|
| {}
|
| })
|
| if({true,true,true,true} == v_LGenBase_VarAndStatTest_stepsPassed){
|
| setverdict ( pass );
|
| }else{
|
| setverdict ( fail, log2str(v_LGenBase_VarAndStatTest_stepsPassed))
|
| }
|
| var EPTF_LGenBase_TestStepArgs vl_args := c_EPTF_LGenBase_emptyTestStepArgs
|
| vl_args.refContext.fCtxIdx := pl_fsmCtxIdx
|
| vl_args.refContext.fRefArgs := {1,c_EPTF_LGenBase_fsmObjectScopeFSM}
|
| vl_args.eIdx :=pl_eOffset+1
|
| var integer vl_varid1 := f_EPTF_LGenBase_fsmVarIdFromStep(vl_args)
|
| vl_args.eIdx :=pl_eOffset+2
|
| var integer vl_varid2 := f_EPTF_LGenBase_fsmVarIdFromStep(vl_args)
|
| if(vl_varid1 == vl_varid2){
|
| setverdict ( fail, "The ID of FSM variables of entity#1 and 2 are the same." );
|
| }
|
| var EPTF_Var_DirectContent vl_currentContent1;
|
| var EPTF_Var_DirectContent vl_currentContent2;
|
| f_EPTF_Var_getContent(vl_varid1, vl_currentContent1)
|
| f_EPTF_Var_getContent(vl_varid2, vl_currentContent2)
|
| if(vl_currentContent1 != vl_currentContent2){
|
| setverdict ( fail, "The content of the variables differ in different entities: ", vl_currentContent1,", ",vl_currentContent2);
|
| }
|
|
|
| vl_args.refContext.fRefArgs := {1,c_EPTF_LGenBase_fsmObjectScopeTC}
|
| vl_args.eIdx :=pl_eOffset+1
|
| vl_varid1 := f_EPTF_LGenBase_fsmVarIdFromStep(vl_args)
|
| vl_args.eIdx :=pl_eOffset+2
|
| vl_varid2 := f_EPTF_LGenBase_fsmVarIdFromStep(vl_args)
|
| if(vl_varid1 != vl_varid2){
|
| setverdict ( fail, "The IDs of TC scope variables are different: ",vl_varid1,", ",vl_varid2 );
|
| }
|
| }
|
|
|
| ///////////////////////////////////////////////////////////
|
| // Testcase: tc_LGenBase_Test_fsmVariables
|
| //
|
| // Purpose:
|
| // Declares 2 variables with FSM scope, and 2 variables with TC scope
|
| // Declares 4 test steps which get the variables as step arguments
|
| // The steps check if
|
| // - the variable ID retrieved from the step argument is proper
|
| // - the initial content of the variable is proper
|
| // The testcase checks also if the varID of the same TC scope
|
| // variables of different entities are the same
|
| //
|
| ///////////////////////////////////////////////////////////
|
| testcase tc_LGenBase_Test_fsmVariables()
|
| runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_LGenBase_Test_fsmVariables_init()
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input5");
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable(c_LGenBase_Test_fsmVariablesFSM);
|
| //log(v_LGenBase_fsmTables)
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC1",
|
| "tc_LGenBase_Test_fsmVariables_FSM1",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC2",
|
| "tc_LGenBase_Test_fsmVariables_FSM1",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| { "SC1",
|
| {
|
| {"TC1",{{target := {cpsToReach := 0.0}}}},
|
| {"TC2",{{target := {cpsToReach := 0.0}}}}
|
| },
|
| {}
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg1","SC1"},false)
|
| f_LGenBase_Test_fsmVariablesCheck()
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
| }
|
|
|
| testcase tc_LGenBase_Test_fsmVariables2() runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_LGenBase_Test_fsmVariables_init()
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input5");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input6");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input7");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input8");
|
| //log("------ Before declareFSMTable")
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable(
|
| {
|
| name := "tc_LGenBase_Test_fsmVariables2_FSM",
|
| fsmParams := {
|
| {stateList := {"idle"}},
|
| {varList := c_LGenBase_Test_vars1},
|
| {statisticList := {
|
| {"statMax1",{{"var1ofFSM1"},{"TCvar1ofFSM1"}},c_EPTF_StatHandler_Method_Max,{floatVal := 0.0},FSM},
|
| {"statMax2",{{"var1ofFSM1"},{"TCvar1ofFSM1"}},c_EPTF_StatHandler_Method_Max,{floatVal := 0.0},TC},
|
| {"statMin1",{{"var1ofFSM1"}},c_EPTF_StatHandler_Method_Min,{floatVal := 0.0},TC},
|
| {"statMin2",{{"TCvar1ofFSM1"},{"var1ofFSM1"}},c_EPTF_StatHandler_Method_Min,{floatVal := 0.0},TC}
|
| }}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := {"b1","input1",fsm},
|
| cellRow := {
|
| {//state[0]==idle
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 3.27}}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input2",fsm},
|
| cellRow := {
|
| {//state[0]==idle
|
| {//Cell
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Increment variable",{varParams := {"var1ofFSM1",{floatVal := 2.9}}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input3",fsm},
|
| cellRow := {
|
| {//state[0]==idle
|
| {//Cell
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Increment variable",{varParams := {"var1ofFSM1", omit}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input4",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Decrement variable",{varParams := {"var1ofFSM1",{floatVal := 1.8}}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input5",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Decrement variable",{varParams := {"var1ofFSM1",omit}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input6",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Set variable",{varParams := {"var2ofFSM1",{floatVal := 17.4}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar1ofFSM1",{floatVal := 3.27}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar2ofFSM1",{floatVal := 45.27}}}},
|
| {"LGenBase: Add variables",{varNames := {"var1ofFSM1","var2ofFSM1","TCvar1ofFSM1","TCvar2ofFSM1"}}
|
| }
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input7",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{floatVal := 7.1}}}},
|
| {"LGenBase: Set variable",{varParams := {"var2ofFSM1",{floatVal := 17.4}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar2ofFSM1",{floatVal := 3.27}}}},
|
| {"LGenBase: Subtract variables",{varNames := {"var1ofFSM1","var2ofFSM1","TCvar2ofFSM1"}}
|
| }
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {"b1","input8",fsm},
|
| cellRow := {
|
| //state[0]==idle
|
| {
|
| {
|
| {"LGenBase: Reset variable",{varNames := {"var1ofFSM1"}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| }
|
| }
|
| }
|
| }
|
| );
|
| //log("-------------",v_LGenBase_fsmTables)
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC1",
|
| "tc_LGenBase_Test_fsmVariables2_FSM",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC2",
|
| "tc_LGenBase_Test_fsmVariables2_FSM",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| { "SC1",
|
| {
|
| {"TC1",{{target := {cpsToReach := 0.0}}}},
|
| {"TC2",{{target := {cpsToReach := 0.0}}}}
|
| },
|
| {}
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg1","SC1"},false)
|
| var EPTF_Var_DirectContent vl_content;
|
| var integer vl_var1ofFSM1E0TC1 := f_EPTF_Var_getId(f_EPTF_LGenBase_varNameOfFSMVar(0,1,"var1ofFSM1"))
|
| var integer vl_var1ofFSM1E1TC1 := f_EPTF_Var_getId(f_EPTF_LGenBase_varNameOfFSMVar(1,1,"var1ofFSM1"))
|
| var integer vl_var1ofFSM1E2TC1 := f_EPTF_Var_getId(f_EPTF_LGenBase_varNameOfFSMVar(2,1,"var1ofFSM1"))
|
| var integer vl_statMax1ET0TC1 := f_EPTF_LGenBase_fsmVarIdOfStat("statMax1", 0, 0, c_EPTF_LGenBase_fsmObjectScopeFSM)
|
| var integer vl_statMax1ET1TC1 := f_EPTF_LGenBase_fsmVarIdOfStat("statMax1", 1, 1, c_EPTF_LGenBase_fsmObjectScopeFSM)
|
| var integer vl_statMax2ET1TC1 := f_EPTF_LGenBase_fsmVarIdOfStat("statMax2", 1, 1, c_EPTF_LGenBase_fsmObjectScopeTC)
|
| var integer vl_statMax2ET2TC1 := f_EPTF_LGenBase_fsmVarIdOfStat("statMax2", 2, 1, c_EPTF_LGenBase_fsmObjectScopeTC)
|
|
|
| if(vl_statMax1ET0TC1 == vl_statMax1ET1TC1){
|
| setverdict ( fail );
|
| }
|
| if(vl_statMax2ET1TC1 != vl_statMax2ET2TC1){
|
| setverdict ( fail );
|
| }
|
| //var1ofFSM1 declaration
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 1.0})){
|
| log(match(vl_content, {floatVal := 1.0}))
|
| setverdict ( fail );
|
| }
|
| f_EPTF_Var_getContent(vl_statMax1ET0TC1,vl_content);
|
| if(not match(vl_content, {floatVal := 3.0})){
|
| log(vl_content)
|
| log(match(vl_content, {floatVal := 3.0}))
|
| setverdict ( fail );
|
| }
|
| f_EPTF_Var_getContent(vl_statMax1ET1TC1,vl_content);
|
| if(not match(vl_content, {floatVal := 3.0})){
|
| log(vl_content)
|
| log(match(vl_content, {floatVal := 3.0}))
|
| setverdict ( fail );
|
| }
|
| //set
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,0,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 3.27})){
|
| log(match(vl_content, {floatVal := 3.27}))
|
| setverdict ( fail );
|
| }
|
| f_EPTF_Var_getContent(vl_statMax1ET0TC1,vl_content);
|
| log(vl_content)
|
| f_EPTF_Var_getContent(vl_statMax1ET1TC1,vl_content);
|
| log(vl_content)
|
| //inc
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,1,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 10.0})){
|
| log(match(vl_content, {floatVal := 10.0}))
|
| setverdict ( fail );
|
| }
|
| //inc with omit
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,2,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 8.1})){
|
| log(match(vl_content, {floatVal := 8.1}))
|
| setverdict ( fail );
|
| }
|
| //dec
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,3,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 5.3})){
|
| log(vl_content)
|
| var EPTF_Var_DirectContent vl_temp := {floatVal := 5.3};
|
| log(vl_content.floatVal-vl_temp.floatVal)
|
| log(match(vl_content, {floatVal := 5.3}))
|
| setverdict ( fail );
|
| }
|
| //dec with omit
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,4,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 6.1})){
|
| log(match(vl_content, {floatVal := 6.1}))
|
| setverdict ( fail );
|
| }
|
| //add
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,5,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 65.94})){
|
| log(vl_content)
|
| log(match(vl_content, {floatVal := 65.94}))
|
| setverdict ( fail );
|
| }
|
| //subtract
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,6,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := (14.129999 .. 14.130001)})){
|
| log(vl_content)
|
| var EPTF_Var_DirectContent vl_temp := {floatVal := 14.13};
|
| log(vl_content.floatVal - vl_temp.floatVal)
|
| log(match(vl_content, {floatVal := 14.13}))
|
| setverdict ( fail );
|
| }
|
| //reset
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,7,{1,1},omit},{}});
|
| f_EPTF_Var_getContent(vl_var1ofFSM1E1TC1, vl_content);
|
| if(not match(vl_content, {floatVal := 1.0})){
|
| log(match(vl_content, {floatVal := 1.0}))
|
| setverdict ( fail );
|
| }
|
| setverdict ( pass );
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| modulepar EPTF_LGenBase_FsmVarParams tsp_unboundParams
|
| testcase tc_LGenBase_Test_fsmVariables2Int() runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_LGenBase_Test_fsmVariables_init()
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input5");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input6");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input7");
|
| v_dummyInt := f_EPTF_LGenBase_declareFsmEvent("b1","input8");
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkVarEqual",refers( f_EPTF_LGenBase_checkVarEqual)})
|
| log("------ Before declareFSMTable")
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable(
|
| {
|
| name := "tc_LGenBase_Test_fsmVariables2_FSM",
|
| fsmParams := {
|
| {stateList := {"idle"}},
|
| {varList := c_LGenBase_Test_varsInt}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := {"b1","input1",fsm},
|
| cellRow := {
|
| {//state[0]==idle
|
| {
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 3}}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 3}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Increment variable",{varParams := {"var1ofFSM1",{intVal := 3}}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 10}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Increment variable",{varNames := {"var1ofFSM1"}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 8}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Increment variable",{varParams := {"var1ofFSM1", omit}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 8}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Decrement variable",{varParams := {"var1ofFSM1",{intVal := 2}}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 5}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Decrement variable",{varParams := {"var1ofFSM1",omit}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 6}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Set variable",{varParams := {"var2ofFSM1",{intVal := 17}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar1ofFSM1",{intVal := 3}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar2ofFSM1",{intVal := 45}}}},
|
| {"LGenBase: Add variables",{varNames := {"var1ofFSM1","var2ofFSM1","TCvar1ofFSM1","TCvar2ofFSM1"}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 65}}}},
|
|
|
| {"LGenBase: Set variable",{varParams := {"var1ofFSM1",{intVal := 7}}}},
|
| {"LGenBase: Set variable",{varParams := {"var2ofFSM1",{intVal := 17}}}},
|
| {"LGenBase: Set variable",{varParams := {"TCvar2ofFSM1",{intVal := 3}}}},
|
| {"LGenBase: Subtract variables",{varNames := {"var1ofFSM1","var2ofFSM1","TCvar2ofFSM1"}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 14}}}},
|
|
|
| {"LGenBase: Reset variable",{varNames := {"var1ofFSM1"}}},
|
| {"checkVarEqual",{varParams := {"var1ofFSM1",{intVal := 1}}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| }
|
| }
|
| }
|
| }
|
| );
|
| //log("-------------",v_LGenBase_fsmTables)
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC1",
|
| "tc_LGenBase_Test_fsmVariables2_FSM",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| "TC2",
|
| "tc_LGenBase_Test_fsmVariables2_FSM",
|
| "et1",
|
| ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| { "SC1",
|
| {
|
| {"TC1",{{target := {cpsToReach := 0.0}}}},
|
| {"TC2",{{target := {cpsToReach := 0.0}}}}
|
| },
|
| {}
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg1","SC1"},false)
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,0,{1,1},omit},{}});
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
| }
|
|
|
| testcase tc_LGenBase_Test_test() runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_LGenBase_Test_fsmVariables_init()
|
| v_dummyInt := f_EPTF_LGenBase_declareFunction("Finished",{customFinishFunction := refers(f_EPTF_LGenBase_TestFinished)});
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable( {
|
| name := "EPTF_FSM_Tc_Succ",
|
| fsmParams := {
|
| {stateList := {"idle"}}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := {c_EPTF_LGenBase_behavior,c_EPTF_LGenBase_inputName_testMgmt_startTC,fsm},
|
| cellRow := {
|
| {{
|
| {c_EPTF_LGenBase_stepName_trafficSuccess, omit}
|
| }, omit, omit}
|
| }
|
| }
|
| }
|
| }
|
| }
|
| )
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2(
|
| {
|
| name := "TC_Succ",
|
| fsmName := "EPTF_FSM_Tc_Succ",
|
| entityType := "et1",
|
| customEntitySucc := ""
|
| }
|
| )
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| {
|
| name := "SC_PH_0",
|
| tcList := {
|
| {
|
| tcName := "TC0_declarator2",
|
| tcParamsList := {
|
| {tcTypeName := "TC_Succ"},
|
| {startDelay := 0.0},
|
| {target := { cpsToReach := 1.0 }},
|
| {scheduler := {preDefinedName := poisson}},
|
| {enableEntitiesAtStart := true},
|
| {enabledAtStart := true},
|
| {ranges := {
|
| {name := "myRange_MSB", enableSplit := true, baseOffset := 10, count := 30},
|
| {name := "myRange_middle", enableSplit := false, baseOffset := 10, count := 30},
|
| {name := "myRange_LSB", enableSplit := false, baseOffset := 0, count := 9}
|
| }
|
| },
|
| {params := {
|
| {aName := "myApplication1", pName := "header", pValue := "$EXTPATH/sip_support/templates/deregister.header"},
|
| {aName := "myApplication2", pName := "boost", pValue := "true"}
|
| }
|
| },
|
| {trafficStartFinish := {
|
| {nrOfExecStart := {count := 5, actions := {}}},
|
| //{nrOfSuccesses := {count := 5,actions := {}}},
|
| //{nrOfGrpLoop := {count := 1,actions := {}}},
|
| //{execTime := {time := 7.0,actions := {}}},
|
| {anythingFinished := {actions := {
|
| {enableTc := {tcName := "TC1_declarator2", aMode := available}}/*,
|
| {disableTc := {tcName := "TC0_declarator2"}}*/
|
| }}}
|
| }
|
| }
|
| }
|
| },
|
| {
|
| tcName := "TC1_declarator2",
|
| tcParamsList := {
|
| {tcTypeName := "TC_Succ"},
|
| {startDelay := 0.0},
|
| {target := { cpsToReach := 2.0 }},
|
| {scheduler := {preDefinedName := imst2}},
|
| {entitySelection := random},
|
| {enableEntitiesAtStart := true},
|
| {enabledAtStart := false},
|
| {trafficStartFinish := {
|
| {nrOfExecStart := {count := 5,actions := {}}},
|
| // {execTime := {time := 15.0,actions := {}}},
|
| {anythingFinished := {actions := {
|
| {customFinishFunction := "Finished"}
|
| }}}
|
| }
|
| }
|
| }
|
| }
|
| },
|
| scParamsList := {
|
| {enabled := true}/*,
|
| {phaseListName := "BasicPhases"},
|
| {phaseFinishConditions := {
|
| {
|
| phase := "preamble",
|
| conditions := {
|
| {
|
| tcStopped := "TC1_declarator2"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| conditions := {
|
| {
|
| tcStopped := "TC0_declarator2"
|
| }
|
| }
|
| }
|
| }
|
| },
|
| {phaseStateChangeActions := {
|
| {
|
| phase := "preamble",
|
| state := RUNNING,
|
| actions := {
|
| {
|
| startScenario := "This should have been implemented :)"
|
| }
|
| }
|
| },
|
| {
|
| phase := "preamble",
|
| state := STOPPING,
|
| actions := {
|
| {
|
| stopTc := "TC1_declarator2"
|
| }
|
| }
|
| },
|
| {
|
| phase := "preamble",
|
| state := FINISHED,
|
| actions := {
|
| {
|
| customAction := "Finished"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| state := RUNNING,
|
| actions := {
|
| {
|
| startScenario := "This should have been implemented :)"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| state := STOPPING,
|
| actions := {
|
| {
|
| stopTc := "TC0_declarator2"
|
| }
|
| }
|
| }
|
| }
|
| }*/
|
| }
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| {
|
| name := "SC_PH_1",
|
| tcList := {
|
| {
|
| tcName := "TC0_declarator2",
|
| tcParamsList := {
|
| {tcTypeName := "TC_Succ"},
|
| {target := { cpsToReach := 1.0 }},
|
| {scheduler := {preDefinedName := imst}},
|
| {enableEntitiesAtStart := true},
|
| {enabledAtStart := true},
|
| {ranges := {
|
| {name := "myRange_MSB", enableSplit := true, baseOffset := 10, count := 30},
|
| {name := "myRange_middle", enableSplit := false, baseOffset := 10, count := 30},
|
| {name := "myRange_LSB", enableSplit := false, baseOffset := 0, count := 9}
|
| }},
|
| {params := {
|
| {aName := "myApplication1", pName := "header", pValue := "$EXTPATH/sip_support/templates/deregister.header"},
|
| {aName := "myApplication2", pName := "boost", pValue := "true"}
|
| }},
|
| {trafficStartFinish := {
|
| {nrOfExecStart := {count := 5,actions := {}}},
|
| {execTime := {time := 12.3,actions := {}}},
|
| {nrOfSuccesses := {count := 5,actions := {}}},
|
| //nrOfGrpLoop := 1,
|
| {anythingFinished := {actions := {
|
| {enableTc := {tcName := "TC1_declarator2", aMode := enableIfPreviousSuccess}},
|
| {disableTc := {tcName := "TC0_declarator2"}}
|
| }}}
|
| }}
|
| }
|
| },
|
| {
|
| tcName := "TC1_declarator2",
|
| tcParamsList := {
|
| {tcTypeName := "TC_Succ"},
|
| {target := { cpsToReach := 2.0 }},
|
| {scheduler := {preDefinedName := orig}},
|
| {enableEntitiesAtStart := true},
|
| {enabledAtStart := false},
|
| {trafficStartFinish := {
|
| {nrOfExecStart := {count := 5,actions := {}}},
|
| {execTime := {time := 15.0,actions := {}}},
|
| {anythingFinished := {actions := {
|
| {customFinishFunction := "Finished"}
|
| }}}
|
| }
|
| }
|
| }
|
| }
|
| },
|
| scParamsList := {
|
| {enabled := true}/*,
|
| {phaseListName := "BasicPhases"},
|
| {phaseFinishConditions := {
|
| {
|
| phase := "preamble",
|
| conditions := {
|
| {
|
| tcStopped := "TC1_declarator2"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| conditions := {
|
| {
|
| tcStopped := "TC0_declarator2"
|
| }
|
| }
|
| }
|
| }
|
| },
|
| {phaseStateChangeActions := {
|
| {
|
| phase := "preamble",
|
| state := RUNNING,
|
| actions := {
|
| {
|
| startScenario := "This should have been implemented :)"
|
| }
|
| }
|
| },
|
| {
|
| phase := "preamble",
|
| state := STOPPING,
|
| actions := {
|
| {
|
| stopTc := "TC1_declarator2"
|
| }
|
| }
|
| },
|
| {
|
| phase := "preamble",
|
| state := FINISHED,
|
| actions := {
|
| {
|
| customAction := "Finished"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| state := RUNNING,
|
| actions := {
|
| {
|
| startScenario := "This should have been implemented :)"
|
| }
|
| }
|
| },
|
| {
|
| phase := "loadgen",
|
| state := STOPPING,
|
| actions := {
|
| {
|
| stopTc := "TC0_declarator2"
|
| }
|
| }
|
| }
|
| }
|
| }*/
|
| }
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg1","SC_PH_0"});
|
| if(f_EPTF_LGenBase_wait4TestFinished()){
|
| setverdict(pass)
|
| }
|
| f_EPTF_Base_cleanup_CT()
|
| }
|
|
|
| group fsmStatMeasure{
|
| function f_EPTF_LGenBase_checkVarEqual(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| var integer vl_varId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmVarParamsFromStep(pl_ptr, vl_varId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent
|
| f_EPTF_Var_getContent(vl_varId, vl_varContent)
|
| if(not match(vl_param,vl_varContent)){
|
| log("The variables don't match")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_checkFloatVarInRange(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| var integer vl_varId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmVarParamsFromStep(pl_ptr, vl_varId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent
|
| f_EPTF_Var_getContent(vl_varId, vl_varContent)
|
| if(not match(vl_varContent, {floatVal := (vl_param.floatVal*0.95 .. vl_param.floatVal*1.05)})){
|
| log("The variables don't match")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_checkStatMeasEqual(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| var integer vl_statId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmStatMeasParamsFromStep(pl_ptr, vl_statId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent
|
| f_EPTF_StatMeasure_stat2Var(vl_statId, vl_varContent)
|
| if(not match(vl_param,vl_varContent)){
|
| log("The statistic value doesn't match with the given one")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_checkFloatStatInRange(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| var integer vl_statId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmStatMeasParamsFromStep(pl_ptr, vl_statId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent
|
| f_EPTF_StatMeasure_stat2Var(vl_statId, vl_varContent)
|
| if(not match(vl_varContent, {floatVal := (vl_param.floatVal*0.95 .. vl_param.floatVal*1.05)})){
|
| log("The statistic value doesn't match with the given one")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_checkChronoEqual(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_Test_CT{
|
| var integer vl_statId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmStatMeasParamsFromStep(pl_ptr, vl_statId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent := {floatVal := 0.0}
|
| v_dummyBool := f_EPTF_StatMeasure_getStat_chrono(vl_statId, vl_varContent.floatVal)
|
| if(not match(vl_param,vl_varContent)){
|
| log("The statistic value doesn't match with the given one")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_checkChronoInRange(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| var integer vl_statId
|
| var EPTF_Var_DirectContent vl_param
|
| f_EPTF_LGenBase_fsmStatMeasParamsFromStep(pl_ptr, vl_statId, vl_param)
|
| var EPTF_Var_DirectContent vl_varContent
|
| f_EPTF_StatMeasure_stat2Var(vl_statId, vl_varContent)
|
| if(not match(vl_varContent, {floatVal := (vl_param.floatVal*0.95 .. vl_param.floatVal*1.05)})){
|
| log("The statistic value doesn't match with the given one")
|
| log(match(vl_param.floatVal,vl_varContent.floatVal))
|
| setverdict(fail)
|
| }else{
|
| setverdict(pass)
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_refreshSnapshot(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| f_EPTF_SchedulerComp_refreshSnapshotTime();
|
| }
|
|
|
| function f_EPTF_LGenBase_VarAndStatTestFinished(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| v_LGenBase_testFinished := true
|
| }
|
| testcase tc_LGenBase_Test_fsmStatMeasure()
|
| runs on EPTF_LGenBase_VarAndStatTest_CT{
|
| f_LGenBase_Test_fsmVariables_init()
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkVarEqual",refers( f_EPTF_LGenBase_checkVarEqual)})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkFloatVarInRange",refers( f_EPTF_LGenBase_checkFloatVarInRange )})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkStatMeasEqual",refers( f_EPTF_LGenBase_checkStatMeasEqual)})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkFloatStatInRange",refers( f_EPTF_LGenBase_checkFloatStatInRange )})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkChronoEqual",refers( f_EPTF_LGenBase_checkChronoEqual)})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkChronoInRange",refers( f_EPTF_LGenBase_checkChronoInRange )})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"finished",refers(f_EPTF_LGenBase_VarAndStatTestFinished)})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"refreshSnapshot",refers(f_EPTF_LGenBase_refreshSnapshot)})
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable(
|
| {
|
| name := "fsmStatMeasure_FSM",
|
| fsmParams := {
|
| {timerList := {{"time",3.27},{"time2",5.93}}},
|
| {stateList := {"idle"}},
|
| {statMeasStatList := {
|
| {"chrono1","",chrono,FSM},
|
| {"chrono2","",chrono,TC}
|
| }}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := {"b1","input1",fsm},
|
| cellRow := {
|
| {
|
| {
|
| {"refreshSnapshot",omit},
|
| {c_EPTF_LGenBase_stepName_timerStart,{timerName := "time"}},
|
| {c_EPTF_LGenBase_stepName_timerStart,{timerName := "time2"}},
|
| {c_EPTF_LGenBase_stepName_fsmStartChrono,{statMeasName := "chrono1"}},
|
| {c_EPTF_LGenBase_stepName_fsmStartChrono,{statMeasName := "chrono2"}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {c_EPTF_LGenBase_specialBName_timerTimeout,"time",fsm},
|
| cellRow := {
|
| {
|
| {
|
| {c_EPTF_LGenBase_stepName_fsmStopChrono,{statMeasName := "chrono1"}},
|
| {c_EPTF_LGenBase_stepName_fsmStopChrono,{statMeasName := "chrono2"}},
|
| {"checkChronoInRange",{statMeasParams := {"chrono1",{floatVal := 3.27}}}},
|
| {"checkChronoInRange",{statMeasParams := {"chrono2",{floatVal := 3.27}}}}
|
| },
|
| omit, omit
|
| }
|
| }
|
| },
|
| {eventToListen := {c_EPTF_LGenBase_specialBName_timerTimeout,"time2",fsm},
|
| cellRow := {
|
| {
|
| {
|
| {"checkChronoInRange",{statMeasParams := {"chrono1",{floatVal := 3.27}}}},
|
| {"checkChronoInRange",{statMeasParams := {"chrono2",{floatVal := 3.27}}}},
|
| {c_EPTF_LGenBase_stepName_fsmResetChrono,{statMeasName := "chrono1"}},
|
| {c_EPTF_LGenBase_stepName_fsmResetChrono,{statMeasName := "chrono2"}},
|
| {c_EPTF_LGenBase_stepName_fsmStartChrono,{statMeasName := "chrono1"}},
|
| {c_EPTF_LGenBase_stepName_fsmStartChrono,{statMeasName := "chrono2"}},
|
| {"checkChronoEqual",{statMeasParams := {"chrono1",{floatVal := 0.0}}}},
|
| {"checkChronoEqual",{statMeasParams := {"chrono2",{floatVal := 0.0}}}},
|
| {"finished",omit}
|
| },
|
| omit, omit
|
| }
|
| }
|
| }
|
| }
|
| }
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareTrafficCaseType({
|
| "TC1",
|
| "fsmStatMeasure_FSM",
|
| "et1",
|
| {}
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| { "SC1",
|
| {
|
| {"TC1",{
|
| {target := {cpsToReach := 50.0}}
|
| }
|
| }
|
| },
|
| {}
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg1","SC1"},false)
|
| f_EPTF_LGenBase_dispatchEvent({{v_LGenBase_VarAndStatTest_behav,0,{0,0},omit},{}})
|
| v_dummyBool := f_EPTF_LGenBase_wait4TestFinished()
|
| f_EPTF_Base_cleanup_CT();
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_statCreateTimerActionHandler(
|
| in EPTF_ScheduledAction pl_action, in integer pl_eventIndex) runs on EPTF_LGenBase_CT
|
| return boolean{
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log(%definitionId&": ",pl_action)
|
| }
|
| f_EPTF_LGenBase_dispatchEvent({{c_EPTF_LGenBase_bIdx,pl_action.actionId[2],{pl_action.actionId[0],pl_action.actionId[1]},omit},{}})
|
| return true
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_statCreateScheduleAction(
|
| in EPTF_LGenBase_TestStepArgs pl_ptr
|
| ) runs on EPTF_LGenBase_CT{
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log(%definitionId&": ",pl_ptr.eIdx," ",pl_ptr.refContext.fCtxIdx," ",pl_ptr.stepArgs[0],",",pl_ptr)
|
| }
|
| var float vl_duration := int2float(pl_ptr.eIdx+1)/10.0
|
| f_EPTF_SchedulerComp_refreshSnapshotTime();
|
| var integer vl_eventId //dummy
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log("Snapshot time: ",f_EPTF_SchedulerComp_snapshotTime())
|
| log("vl_duration: ",vl_duration)
|
| }
|
| if(not f_EPTF_SchedulerComp_scheduleAction(
|
| f_EPTF_SchedulerComp_snapshotTime()+vl_duration,
|
| refers(f_EPTF_LGenBase_Test_statCreateTimerActionHandler),
|
| {pl_ptr.eIdx,pl_ptr.refContext.fCtxIdx,pl_ptr.refContext.fRefArgs[0]},
|
| vl_eventId))
|
| {
|
| f_EPTF_Base_stop()
|
| }
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_statCreatePostproc(
|
| in integer pl_idx,
|
| in EPTF_IntegerList pl_argList)
|
| runs on LGenBase_Test_StatCreate_CT{
|
| var EPTF_Var_DirectContent vl_content
|
| f_EPTF_Var_getContent(pl_idx, vl_content)
|
| var integer vl_state := f_EPTF_LGenBase_getTcState(0)
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log(%definitionId&": ",vl_content," state of tc:",c_EPTF_LGenBase_stateNames[vl_state])
|
| }
|
| v_statCreateValues[sizeof(v_statCreateValues)] := vl_content.floatVal
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_tcCreated(
|
| in integer pl_tcIdx
|
| ) runs on LGenBase_Test_StatCreate_CT{
|
| var charstring vl_name := f_EPTF_LGenBase_varNameOfTCVar(0,"vf_95")
|
| var integer vl_varId := f_EPTF_Var_getId(vl_name)
|
| f_EPTF_Var_addPostProcFn(vl_varId, {refers(f_EPTF_LGenBase_Test_statCreatePostproc),{}})
|
| }
|
|
|
| function f_EPTF_LGenBase_Test_tcStartedOrStopped_FT(in integer pl_tcIdx, in boolean pl_started)
|
| runs on LGenBase_Test_StatCreate_CT{
|
| if(pl_started){
|
| log(%definitionId&": v_statCreateValues := {}")
|
| v_statCreateValues := {}
|
| }
|
| }
|
|
|
| type component LGenBase_Test_StatCreate_CT extends EPTF_LGenBase_Test_CT {
|
| var EPTF_FloatList v_statCreateValues := {}
|
| const integer c_initVal := 3
|
| const float c_timer := 1.4
|
| const float c_p95InitVal := 0.0
|
| const integer c_entities := 100
|
| const integer c_incVal := 4
|
| const EPTF_StatMeasure_StatParams c_stat95Params := {
|
| percentile95 := {
|
| scale := {
|
| min := 0.0,
|
| max := int2float(c_entities/*-1*/)/10.0,
|
| n := c_entities+1,
|
| scale := linear}
|
| }
|
| }
|
| }
|
| testcase tc_EPTF_LGenBase_Test_statCreate()
|
| runs on LGenBase_Test_StatCreate_CT{
|
| f_EPTF_LGenBase_init("")
|
| var integer vl_incEvent := f_EPTF_LGenBase_declareFsmEvent(c_EPTF_LGenBase_behavior,"incrementVar");
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log("vl_incEvent==",vl_incEvent)
|
| }
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkChronoEqual",refers( f_EPTF_LGenBase_checkChronoEqual)})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"checkChronoInRange",refers( f_EPTF_LGenBase_checkChronoInRange )})
|
| v_dummyInt := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"statCreateScheduleAction",refers(f_EPTF_LGenBase_Test_statCreateScheduleAction)})
|
| v_dummyInt := f_EPTF_LGenBase_addtrafficCaseCreatedCallback(refers(f_EPTF_LGenBase_Test_tcCreated))
|
| f_EPTF_LGenBase_registerTcStartedCallback(refers( f_EPTF_LGenBase_Test_tcStartedOrStopped_FT ))
|
| v_dummyInt := f_EPTF_LGenBase_addGeneralEventListener(
|
| c_EPTF_LGenBase_bIdx,
|
| c_EPTF_LGenBase_inputIdx_testMgmt_testFinished,
|
| refers(f_EPTF_LGenBase_Test_testFinishedListener), {})
|
| v_dummyInt := f_EPTF_LGenBase_declareFSMTable(
|
| {
|
| name := "XCAP_getFsm",
|
| fsmParams := {
|
| {stateList := {"idle","waitingForResponse"}},
|
| {timerList := {
|
| {name := "T_userWatchdog",startValue :=c_timer}
|
| }}
|
| ,{varList := {
|
| {name := "vf_rtt", initValue := {floatVal := 0.0}, scope := FSM}
|
| ,{name := "vf_95", initValue := {floatVal := 0.0}, scope := TC}
|
| ,{name := "vFSM2", initValue := {intVal := c_initVal}, scope := FSM}
|
| }}
|
| ,{statMeasStatList := {
|
| {name := "mean_rtt", varName := "vf_95",statType := mean, scope := TC}
|
| }}
|
| ,{statMeasWithParamsList := {
|
| {
|
| name := "minChrono",
|
| providerVarName := "vf_95",
|
| targetVarName := "",
|
| statMeasParams := {
|
| statType := min},
|
| scope := TC
|
| },
|
| {
|
| name := "chrono_rtt",
|
| providerVarName := "",
|
| targetVarName := "vf_95",
|
| statMeasParams := {
|
| statType := chrono},
|
| scope := FSM
|
| },
|
| {
|
| name := "p95_rtt",
|
| providerVarName := "vf_95",
|
| targetVarName := "",
|
| statMeasParams := {
|
| params := c_stat95Params
|
| },
|
| scope := TC
|
| }
|
| }}
|
| ,{statHandlerStatList := {{
|
| name := "shTC1",
|
| providers := {
|
| {statMeas := "p95_rtt"}
|
| },
|
| statMethod := c_EPTF_StatHandler_Method_Percentile95,
|
| statResetValue := {floatVal := c_p95InitVal},
|
| scope := TC
|
| }
|
| }}
|
| },
|
| table := {
|
| classicTable := {
|
| {eventToListen := { bName := "EPTF_CLL_LGenBase", iName := "LGenBase: Start_the_traffic_case!", eventType := fsm },
|
| cellRow := {
|
| //state==idle
|
| {actionList := {//XCAPget_DOT: idle -> waitingForResponse [label="i:startTC\no:request\nstart(T_userWatchdog)"]
|
| {stepOrFunctionName := "statCreateScheduleAction", contextArgs :={stepContextArgs := {vl_incEvent}}}
|
| //,{stepOrFunctionName := "LGenBase: Reset chronometer", contextArgs :={statMeasName := "chrono_rtt"}}
|
| ,{stepOrFunctionName := c_EPTF_LGenBase_stepName_fsmStartChrono, contextArgs :={statMeasName := "chrono_rtt"}}
|
| ,{stepOrFunctionName := c_EPTF_LGenBase_stepName_fsmVarInc, contextArgs :={varParams := {"vFSM2",{intVal := c_incVal}}}}
|
| },
|
| nextStateCalculation := omit,
|
| nextState := "waitingForResponse"
|
| }
|
| //state==waitingForResponse
|
| ,{actionList :=omit, nextStateCalculation := omit, nextState := omit}
|
| }
|
| },
|
| {eventToListen := { bName := "EPTF_CLL_LGenBase", iName := "incrementVar", eventType := fsm },
|
| cellRow := {
|
| //state==idle
|
| {actionList :=omit, nextStateCalculation := omit, nextState := omit},
|
| //state==waitingForResponse
|
| {actionList := {
|
| {stepOrFunctionName := c_EPTF_LGenBase_stepName_fsmStopChrono, contextArgs :={statMeasName := "chrono_rtt"}},
|
| {stepOrFunctionName := c_EPTF_LGenBase_stepName_trafficSuccess, contextArgs := omit}},
|
| nextStateCalculation := omit,
|
| nextState := "idle"
|
| }
|
| }
|
| }
|
| }//table
|
| }
|
| }//fsm //XCAPget_DOT:}
|
| )
|
| 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 := c_entities})
|
| v_dummyInt := f_EPTF_LGenBase_declareTcType2({
|
| name := "TC_Delayed",
|
| fsmName := "XCAP_getFsm",
|
| entityType := "Entity_Tc_A",
|
| customEntitySucc := ""
|
| })
|
| v_dummyInt := f_EPTF_LGenBase_declareScenarioType3(
|
| {
|
| name := "Scenario_Simple",
|
| tcList := {
|
| {
|
| tcName := "TC_Delayed",
|
| tcParamsList := {
|
| {enabledAtStart := true},
|
| {enableEntitiesAtStart := true},
|
| {entityFinishConditions := {{nrOfSuccesses := 1}}},
|
| {target := {cpsToReach := 1111.0}},
|
| {trafficFinishedActions := {{testFinished := {}}}},
|
| {trafficStartFinish := {
|
| {nrOfExecStart := {count := c_entities,actions := {}}}
|
| }}
|
| }
|
| }
|
| },
|
| scParamsList := {}
|
| })
|
| f_EPTF_LGenBase_createScenario2EntityGroup({"eg0", "Scenario_Simple"},true)
|
| if(f_EPTF_LGenBase_wait4TestFinished(int2float(c_entities)+2.0)){
|
| var integer vl_temp := f_EPTF_LGenBase_fsmStatMeasIdOfTC(0,"mean_rtt")
|
| if( -1 == vl_temp){
|
| log("f_EPTF_LGenBase_fsmStatMeasIdOfTC(0,""mean_rtt"") == ",vl_temp)
|
| setverdict(fail)
|
| }
|
| var integer vl_statId95 := f_EPTF_LGenBase_fsmStatMeasIdOfTC(0, "p95_rtt")
|
| var charstring vl_name := f_EPTF_LGenBase_varNameOfTCVar(0,"vf_95")
|
| var integer vl_varIdx0 := f_EPTF_Var_getId(vl_name)
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log("StatMeasID of TC stat p95_rtt: ",vl_statId95)
|
| }
|
| for ( var integer vl_i := 0; vl_i < c_entities ; vl_i := vl_i+1 ){
|
| var integer vl_statIdOfStatMeas := f_EPTF_LGenBase_fsmStatMeasIdOfFSM(vl_i, 0, "chrono_rtt")
|
| var integer vl_varIdOfStatMeas := f_EPTF_StatMeasure_getCreatedVarIdx(vl_statIdOfStatMeas)
|
| if(vl_varIdx0 != vl_varIdOfStatMeas){
|
| log("The created variable ID of the chrono stat#",vl_i," is ",vl_varIdOfStatMeas,
|
| " instead of ",vl_varIdx0)
|
| setverdict(fail)
|
| }
|
| var integer vl_varIdInc := f_EPTF_Var_getId(f_EPTF_LGenBase_varNameOfFSMVar(vl_i, 0, "vFSM2"))
|
| var EPTF_Var_DirectContent vl_contentInc
|
| f_EPTF_Var_getContent(vl_varIdInc, vl_contentInc)
|
| if(c_initVal+c_incVal != vl_contentInc.intVal){
|
| log("Content of variable to be incremented: ",match(c_initVal+c_incVal, vl_contentInc.intVal))
|
| setverdict(fail)
|
| }
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log("StatMeasID of stat chrono_rtt: ",vl_statIdOfStatMeas)
|
| log("Created variable ID of stat chrono_rtt: ",vl_varIdOfStatMeas)
|
| }
|
| }
|
| var integer vl_testVar
|
| f_EPTF_Var_newFloat("testVar", 0.0, vl_testVar)
|
| var integer vl_testStatId := f_EPTF_StatMeasure_newStatWithParams(vl_testVar, c_stat95Params)
|
| for ( var integer vl_i := 0; vl_i < sizeof(v_statCreateValues) ; vl_i := vl_i+1 ){
|
| f_EPTF_Var_adjustContent(vl_testVar, {floatVal := v_statCreateValues[vl_i]})
|
| }
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log(v_statCreateValues)
|
| }
|
| var float vl_expected, vl_measured
|
| f_EPTF_StatMeasure_getStat_percentile95(vl_testStatId, vl_expected)
|
| f_EPTF_StatMeasure_getStat_percentile95(vl_statId95, vl_measured)
|
| if(not match(vl_measured, vl_expected)){
|
| log(match(vl_measured, vl_expected))
|
| setverdict(fail)
|
| }
|
| var integer vl_varSh := f_EPTF_LGenBase_fsmVarIdOfTCStat("shTC1", 0)
|
| if(-1<vl_varSh){
|
| //timer t1
|
| //t1.start(0.1)
|
| //t1.timeout
|
| var EPTF_Var_DirectContent vl_currentContent
|
| f_EPTF_Var_getContent(vl_varSh, vl_currentContent)
|
| if(vl_measured == vl_currentContent.floatVal){
|
| setverdict(pass)
|
| }else{
|
| setverdict(inconc,"content(",vl_currentContent,")!= vl_measured(",vl_measured,")")
|
| }
|
| }else{
|
| setverdict(fail,"vl_varSh < 0")
|
| }
|
| f_EPTF_LGenBase_restoreScenario("eg0", "Scenario_Simple", false)
|
| for ( var integer vl_i := 0; vl_i < c_entities ; vl_i := vl_i+1 ){
|
| var integer vl_varIdInc := f_EPTF_Var_getId(f_EPTF_LGenBase_varNameOfFSMVar(vl_i, 0, "vFSM2"))
|
| var EPTF_Var_DirectContent vl_contentInc
|
| f_EPTF_Var_getContent(vl_varIdInc, vl_contentInc)
|
| if(c_initVal != vl_contentInc.intVal){
|
| log("Content of variable to be incremented: ",match(c_initVal+c_incVal, vl_contentInc.intVal))
|
| setverdict(fail)
|
| }
|
| }
|
| v_statCreateValues := {}
|
| f_EPTF_LGenBase_enableScenarioOnEntityGroup(0, 0, true)
|
| if(f_EPTF_LGenBase_wait4TestFinished(int2float(c_entities)+2.0)){
|
| f_EPTF_StatMeasure_getStat_percentile95(vl_statId95, vl_measured)
|
| f_EPTF_StatMeasure_disableStat(vl_testStatId)
|
| f_EPTF_Var_adjustContent(vl_testVar, {floatVal := 0.0})
|
| f_EPTF_StatMeasure_initStatValue(vl_testStatId)
|
| f_EPTF_StatMeasure_enableStat(vl_testStatId)
|
| for ( var integer vl_i := 0; vl_i < sizeof(v_statCreateValues) ; vl_i := vl_i+1 ){
|
| f_EPTF_Var_adjustContent(vl_testVar, {floatVal := v_statCreateValues[vl_i]})
|
| }
|
| f_EPTF_StatMeasure_getStat_percentile95(vl_testStatId, vl_expected)
|
|
|
| if(vl_expected == vl_measured){
|
| setverdict ( pass );
|
| }else{
|
| if(tsp_EPTF_LGenBaseTestDebug) {
|
| log(v_statCreateValues)
|
| }
|
| setverdict(fail,"Second run: "&log2str(vl_measured)&" instead of ",vl_expected)
|
| }
|
| }else{
|
| setverdict(fail,"Not finished at second run")
|
| }
|
| }else{
|
| setverdict(fail,"Not fini
|