blob: 3848e42b561b0c5066a2b5a2ed785e62f7fd5d08 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 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_CLL_ExecCtrl_CLIFunctions
//
// Purpose:
// This module contains the implementation of EPTF_CLL_ExecCtrl
// Command Line Interface functions.
//
// Module depends on:
// <EPTF_CLL_ExecCtrl_CLIDefinitions>
// <EPTF_CLL_ExecCtrl_Functions>
// <EPTF_CLL_ExecCtrl_Definitions>
// <EPTF_CLL_ExecCtrl_ScenarioFunctions>
// <EPTF_CLL_ExecCtrl_PhaseFunctions>
// <EPTF_CLL_CLI_Functions>
// <EPTF_CLL_CLI_Definitions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_StatHandler_Functions>
//
// Module Parameters:
//
// Current Owner:
// Jozsef Gyurusi (ethjgi)
//
// Last Review Date:
// 2010-03-30
//
// Detailed Comments:
// This module contains the Command Line Interface handler functions
// for the EPTF_CLL_ExecCtrl.
//
// Public functions:
// <f_EPTF_ExecCtrl_CLI_init_CT>
//
// All other functions in this module are private!
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_ExecCtrl_CLIFunctions {
import from EPTF_CLL_ExecCtrl_CLIDefinitions all;
import from EPTF_CLL_ExecCtrl_Functions all;
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrl_PhaseFunctions all;
import from EPTF_CLL_ExecCtrl_ScenarioFunctions all;
import from EPTF_CLL_CLI_Functions all;
import from EPTF_CLL_CLI_Definitions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_StatHandler_Functions all;
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_CLI_init_CT
//
// Purpose:
// The init function of the ExecCtrl_CLI feature
//
// Parameters:
// pl_selfName - *in charstring* - the name of the component
// pl_nrOfClients - *in integer* - the number of the <EPTF_ExecCtrlClient_CT> components created by the user
// (this is the size of the default pool)
// pl_createLGenPools - *in boolean - if true, LGens in LGens pools are created automatically during init, otherwise
// the function <f_EPTF_ExecCtrl_LGenPool_createLGens> has to be called after the init function. Default: true
// pl_CLI_compRef - *in* <EPTF_CLI_CT> - the CLI component to use to register the commands into (default: null)
// pl_commandPrefix - *in charstring* - common prefix of all execCtrl commands (default: "")
// pl_loadModulepars - *in boolean - if true, module parameters are automatically loaded. Default: true
// pl_autoStart - *in boolean - if true, ExecCtrl is started automatically. Default: true
// pl_dataSource_compRef - *in* <EPTF_DataSource_CT> - DataSource component reference. Optional, if given, ExecCtrl will be able to behave
// as a DataSource Client. It means that datas can be requested from it and it will provide them in variables. This component can
// be for example the UIHandler component.
// pl_nofExternalStatHandlers - *in integer* - if >0: ExecCtrl TC and FSM statistics will be calculated on a separate StatHandler component,
// for 0: ExecCtrl will calculate the stats
// Note, that using external StatHandler component increases the internal traffic on the Variable interface (between ExecCtrl and StatHandler)
// Default: 0, which means that ExecCtrl will use its internal StatHandler (No extra internal traffic)
// pl_usePullModeForStats - *in* *boolean* - If true pull mode is used for StatHandler statistics (default: false)
//
// Return Value:
// -
//
// Detailed Comments:
// The function should be called before the ExecCtrl init functions
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_CLI_init_CT(
in charstring pl_selfName,
in integer pl_nrOfClients,
in boolean pl_createLGenPools := true,
in EPTF_CLI_CT pl_CLI_compRef := null,
in charstring pl_commandPrefix := "",
in boolean pl_loadModulepars := true,
in boolean pl_autoStart := true,
in EPTF_DataSource_CT pl_dataSource_compRef := null,
in integer pl_nofExternalStatHandlers := 0,
in boolean pl_usePullModeForStats := false
) runs on EPTF_ExecCtrl_CLI_CT {
if (v_ExecCtrl_CLI_initialized) {
return;
}
f_EPTF_ExecCtrl_init_CT(pl_selfName,pl_nrOfClients,pl_createLGenPools,pl_loadModulepars,pl_autoStart:=pl_autoStart, pl_dataSource_compRef := pl_dataSource_compRef,
pl_nofExternalStatHandlers:= pl_nofExternalStatHandlers, pl_usePullModeForStats := pl_usePullModeForStats);
f_EPTF_CLI_Client_init_CT(pl_selfName,pl_CLI_compRef);
// Base and Variable are implicitly initialized by these functions
v_ExecCtrl_CLI_commandPrefix := pl_commandPrefix;
//register execCtrl start commands:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_start,
"starts a traffic case/scenario/scenarioGroup/test execution",
refers(f_EPTF_ExecCtrl_CLI_startHandler)
);
//register execCtrl stop commands:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_stop,
"stops a traffic case/scenario/scenarioGroup/test execution",
refers(f_EPTF_ExecCtrl_CLI_stopHandler)
);
//register execCtrl terminate commands:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_terminate,
"terminates "&/*"a traffic case/scenario/"*/"scenarioGroup/test execution",
refers(f_EPTF_ExecCtrl_CLI_terminateHandler)
);
// register execCtrl setTargetCPS:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_setCPS,
"sets the target CPS for a traffic case/scenario",
refers(f_EPTF_ExecCtrl_CLI_setCPSHandler)
);
// register execCtrl getTargetCPS:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_getTargetCPS,
"returns the target CPS for a traffic case/scenario",
refers(f_EPTF_ExecCtrl_CLI_getTargetCPSHandler)
);
// register execCtrl getCurrentCPS:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_getCurrentCPS,
"returns the current CPS for a traffic case/scenario",
refers(f_EPTF_ExecCtrl_CLI_getCurrentCPSHandler)
);
// register execCtrl getWeight:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_getWeight,
"returns the weight of a traffic case inside a weighted scenario",
refers(f_EPTF_ExecCtrl_CLI_getWeightHandler)
);
// register execCtrl setWeight:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_setWeight,
"sets the weight of a traffic case inside a weighted scenario",
refers(f_EPTF_ExecCtrl_CLI_setWeightHandler)
);
// register execCtrl getTotalCounter command:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_getTotalCounter,
"prints out the specified accumulated statistics",
refers(f_EPTF_ExecCtrl_CLI_getTotalCounter)
);
// register execCtrl exitTTCN:
f_EPTF_CLI_Client_registerCommand(
v_ExecCtrl_CLI_commandPrefix&c_EPTF_ExecCtrl_CLI_exitTTCN,
"orders ExecCtrl to end the test execution and terminate the application",
refers(f_EPTF_ExecCtrl_CLI_exitTTCNHandler)
);
f_EPTF_Base_registerCleanup(refers(f_EPTF_ExecCtrl_CLI_cleanup_CT));
v_ExecCtrl_CLI_initialized := true;
}
private function f_EPTF_ExecCtrl_CLI_cleanup_CT() runs on EPTF_ExecCtrl_CLI_CT {
if(not v_ExecCtrl_CLI_initialized) {
return;
}
v_ExecCtrl_CLI_initialized := false;
}
group StartStopTerminate {
// handler of start command (c_EPTF_ExecCtrl_CLI_start)
private function f_EPTF_ExecCtrl_CLI_startHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - starts a traffic case/scenario/scenarioGroup/test execution\n"&
"Usage: "&pl_result&" <help|all|scGroup <scGroupName>|sc <scName>|tc <tcName>>\n"&
" help - print this help message\n"&
" all - start all scenarios and scenario groups that are enabled at start\n"&
" scGroup <scGroupName> - start a scenario group with\n"&
" name <scGroupName>\n"&
" sc <scName> - start the given scenario\n"&
" <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
" tc <tcName> - start the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="all") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_startAllHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_startTCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="sc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_startSCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="scGroup") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_startSCGroupHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|all|scGroup|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_startAllHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_remaining := pl_commandArgs;
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
f_EPTF_ExecCtrl_startAllScenarios();
pl_result := "All scenarios and scenario groups are started successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_startTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// start the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be started: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
var charstring vl_warning := "";
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
vl_warning := "Warning: Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" belongs to a weighted scenario: "&vl_eGrpName&"."&vl_scName&"\n";
}
var integer vl_tcOfScIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(vl_tcIdx);
f_EPTF_ExecCtrl_startTCOnLGens(vl_scIdx,vl_tcOfScIdx);
pl_result := vl_warning&"Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" started successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_startSCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 2) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
// get the Id of the scenario:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_globalName);
if (vl_scIdx==-1) {
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" cannot be started: Scenario not found";
return 3; // set nonzero exit code
}
if (not f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" cannot be started: Scenario is in a scenario group "&
f_EPTF_ExecCtrl_getScenarioGroupInstanceName(f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(vl_scIdx));
return 4; // set nonzero exit code
}
f_EPTF_ExecCtrl_startScenarioOnLGens(vl_scIdx);
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" started successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_startSCGroupHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
// get the Id of the scenario group:
var integer vl_scGrpIdx := f_EPTF_ExecCtrl_ScenarioGroup_getIdx(vl_globalName);
if (vl_scGrpIdx==-1) {
pl_result := "Scenario group "&vl_globalName&" cannot be started: Scenario group not found";
return 2; // set nonzero exit code
}
f_EPTF_ExecCtrl_ScenarioGroup_start(vl_scGrpIdx)
pl_result := "Scenario group "&vl_globalName&" started successfully.";
return 0; // OK
}
// handler of stop command (c_EPTF_ExecCtrl_CLI_stop)
private function f_EPTF_ExecCtrl_CLI_stopHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - stops a traffic case/scenario/scenarioGroup/test execution\n"&
"Usage: "&pl_result&" <help|all|scGroup <scGroupName>|sc <scName>|tc <tcName>>\n"&
" help - print this help message\n"&
" all - stop all scenarios and scenario groups\n"&
" scGroup <scGroupName> - stop a scenario group with\n"&
" name <scGroupName>\n"&
" sc <scName> - stop the given scenario\n"&
" <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
" tc <tcName> - stop the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="all") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_stopAllHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_stopTCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="sc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_stopSCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="scGroup") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_stopSCGroupHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|all|scGroup|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_stopAllHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_remaining := pl_commandArgs;
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
f_EPTF_ExecCtrl_stopAllScenarios();
pl_result := "All scenarios and scenario groups are stopped successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_stopTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be stopped: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
var charstring vl_warning := "";
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
vl_warning := "Warning: Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" belongs to a weighted scenario: "&vl_eGrpName&"."&vl_scName&"\n";
}
var integer vl_tcOfScIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(vl_tcIdx);
f_EPTF_ExecCtrl_stopTCOnLGens(vl_scIdx,vl_tcOfScIdx);
pl_result := vl_warning&"Traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" stopped successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_stopSCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 2) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
// get the Id of the scenario:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_globalName);
if (vl_scIdx==-1) {
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" cannot be stopped: Scenario not found";
return 3; // set nonzero exit code
}
if (not f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" cannot be stopped: Scenario is in a scenario group "&
f_EPTF_ExecCtrl_getScenarioGroupInstanceName(f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(vl_scIdx));
return 4; // set nonzero exit code
}
f_EPTF_ExecCtrl_stopScenarioOnLGens(vl_scIdx);
pl_result := "Scenario "&vl_eGrpName&"."&vl_scName&" stopped successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_stopSCGroupHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
// get the Id of the scenario group:
var integer vl_scGrpIdx := f_EPTF_ExecCtrl_ScenarioGroup_getIdx(vl_globalName);
if (vl_scGrpIdx==-1) {
pl_result := "Scenario group "&vl_globalName&" cannot be stopped: Scenario group not found";
return 2; // set nonzero exit code
}
//f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(vl_scGrpIdx)
//f_EPTF_ExecCtrl_ScenarioGroup_stopExecution(vl_scGrpIdx);
f_EPTF_ExecCtrl_ScenarioGroup_stop(vl_scGrpIdx);
pl_result := "Scenario group "&vl_globalName&" stopped successfully.";
return 0; // OK
}
// handler of terminate command (c_EPTF_ExecCtrl_CLI_terminate)
private function f_EPTF_ExecCtrl_CLI_terminateHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - terminates "&/*"a traffic case/scenario/"*/"scenarioGroup/test execution\n"&
"Usage: "&pl_result&" <help|all|scGroup <scGroupName>\n"&//"|sc <scName>|tc <tcName>>\n"&
" help - print this help message\n"&
" all - terminate the execution of all scenarios and scenario groups\n"&
" scGroup <scGroupName> - terminate the execution of a scenario group with\n"&
" name <scGroupName>";//"\n"&
// " sc <scName> - stop the given scenario\n"&
// " <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
// " tc <tcName> - stop the given traffic case\n"&
// " <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
// "Where\n"&
// " <EntityGroupName>: name of the entity group\n"&
// " <ScenarioName>: name of the scenario\n"&
// " <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="all") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_terminateAllHandler(vl_subCommandArgs,pl_result)
}
// if (vl_firstArg=="tc") {
// var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
// return f_EPTF_ExecCtrl_CLI_stopTCHandler(vl_subCommandArgs,pl_result)
// }
// if (vl_firstArg=="sc") {
// var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
// return f_EPTF_ExecCtrl_CLI_stopSCHandler(vl_subCommandArgs,pl_result)
// }
if (vl_firstArg=="scGroup") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_terminateSCGroupHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|all|scGroup|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_terminateAllHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_remaining := pl_commandArgs;
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
f_EPTF_ExecCtrl_terminateAllScenarios();
pl_result := "All scenarios and scenario groups are terminated successfully.";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_terminateSCGroupHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
// get the Id of the scenario group:
var integer vl_scGrpIdx := f_EPTF_ExecCtrl_ScenarioGroup_getIdx(vl_globalName);
if (vl_scGrpIdx==-1) {
pl_result := "Scenario group "&vl_globalName&" cannot be terminated: Scenario group not found";
return 2; // set nonzero exit code
}
f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(vl_scGrpIdx)
//f_EPTF_ExecCtrl_ScenarioGroup_stopExecution(vl_scGrpIdx);
//f_EPTF_ExecCtrl_ScenarioGroup_stop(vl_scGrpIdx);
pl_result := "Scenario group "&vl_globalName&" terminated successfully.";
return 0; // OK
}
} //~group StartStopTerminate
group CPS {
// setTargetCPS:
private function f_EPTF_ExecCtrl_CLI_setCPSHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - sets the target CPS for a traffic case/scenario\n"&
"Usage: "&pl_result&" <help|sc <scName> <CPSValue>|tc <tcName> <CPSValue>>\n"&
" help - print this help message\n"&
" sc <scName> <CPSValue> - sets the target CPS for the given scenario\n"&
" <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
" tc <tcName> <CPSValue> - sets the target CPS for the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case\n"&
" <CPSValue>: value of the CPS to set (float number)";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_setCPSTCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="sc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_setCPSSCHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_setCPSTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
var charstring vl_cpsStr := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
vl_remaining := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
if (vl_cpsStr=="") {
pl_result := "Syntax error: CPS value is expected after the TC name";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: Traffic case belongs to a weighted scenario: "&vl_eGrpName&"."&vl_scName;
return 4; // tc in weighted scenario cannot be stopped
}
// check the format of the CPS:
var charstring vl_floatStr := regexp(vl_cpsStr,c_EPTF_CLI_floatNumber,0);
if (vl_floatStr=="") {
vl_floatStr := regexp(vl_cpsStr,c_EPTF_CLI_integerNumber,0);
if (vl_floatStr=="") {
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: The CPS value is not a float value: "&vl_cpsStr;
return 5; // error
}
vl_floatStr := vl_floatStr&".0"; // create a float from the integer
}
var float vl_cps := str2float(vl_floatStr);
// var integer vl_tcOfScIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(vl_tcIdx);
// f_EPTF_ExecCtrl_setCps_TC(vl_scIdx,vl_tcOfScIdx,vl_cps);
f_EPTF_ExecCtrl_setCPSToReach_TC(vl_tcIdx,vl_cps);
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" set successfully to "&vl_cpsStr&".";
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_setCPSSCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
var charstring vl_cpsStr := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
vl_remaining := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 2) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>";
return 2; // set nonzero exit code
}
if (vl_cpsStr=="") {
pl_result := "Syntax error: CPS value is expected after the SC name";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
// get the Id of the scenario:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_globalName);
if (vl_scIdx==-1) {
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be set: Scenario not found";
return 3; // set nonzero exit code
}
if (not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be set: Scenario is not a weighted scenario";
return 4; // set nonzero exit code
}
// check the format of the CPS:
var charstring vl_floatStr := regexp(vl_cpsStr,c_EPTF_CLI_floatNumber,0);
if (vl_floatStr=="") {
vl_floatStr := regexp(vl_cpsStr,c_EPTF_CLI_integerNumber,0);
if (vl_floatStr=="") {
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be set: The CPS value is not a float value: "&vl_cpsStr;
return 5; // error
}
vl_floatStr := vl_floatStr&".0"; // create a float from the integer
}
var float vl_cps := str2float(vl_floatStr);
f_EPTF_ExecCtrl_setCPSToReach_SC(vl_scIdx,vl_cps);
pl_result := "CPS of scenario "&vl_eGrpName&"."&vl_scName&" set successfully to "&vl_cpsStr&".";
return 0; // OK
}
// getTargetCPS:
private function f_EPTF_ExecCtrl_CLI_getTargetCPSHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - returns the target CPS for a traffic case/scenario\n"&
"Usage: "&pl_result&" <help|sc <scName>|tc <tcName>>\n"&
" help - print this help message\n"&
" sc <scName> - returns the target CPS for the given scenario\n"&
" <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
" tc <tcName> - returns the target CPS for the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_getTargetCPSTCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="sc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_getTargetCPSSCHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_getTargetCPSTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: Traffic case belongs to a weighted scenario: "&vl_eGrpName&"."&vl_scName;
return 4; // tc in weighted scenario cannot be stopped
}
var float vl_cps := f_EPTF_ExecCtrl_getCPSToReach_TC(vl_tcIdx);
var charstring vl_cpsStr := float2str(vl_cps);
pl_result := "Target CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&": "&vl_cpsStr;
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_getTargetCPSSCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 2) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
// get the Id of the scenario:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_globalName);
if (vl_scIdx==-1) {
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be determined: Scenario not found";
return 3; // set nonzero exit code
}
if (not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be determined: Scenario is not a weighted scenario";
return 4; // set nonzero exit code
}
var float vl_cps := f_EPTF_ExecCtrl_getCPSToReach_SC(vl_scIdx);
var charstring vl_cpsStr := float2str(vl_cps);
pl_result := "Target CPS of scenario "&vl_eGrpName&"."&vl_scName&": "&vl_cpsStr;
return 0; // OK
}
// get current CPS
private function f_EPTF_ExecCtrl_CLI_getCurrentCPSHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - returns the current CPS for a traffic case/scenario\n"&
"Usage: "&pl_result&" <help|sc <scName>|tc <tcName>>\n"&
" help - print this help message\n"&
" sc <scName> - returns the current CPS for the given scenario\n"&
" <scName> has to be in the format: <EntityGroupName>.<ScenarioName>\n"&
" tc <tcName> - returns the current CPS for the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_getCurrentCPSTCHandler(vl_subCommandArgs,pl_result)
}
if (vl_firstArg=="sc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_getCurrentCPSSCHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|sc|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_getCurrentCPSTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Current CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: Traffic case not found";
return 3; // set nonzero exit code
}
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scName&".TC."&vl_tcName;
var charstring vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_CurrentCPS];
// CurrentCPS:
var integer vl_varIdx := f_EPTF_Var_getId(vl_statName);
if (vl_varIdx==-1) {
pl_result := "Current CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: CPS is not available yet";
return 0; // ok
}
var float vl_cps := f_EPTF_Var_getFloatValue(vl_varIdx);
var charstring vl_cpsStr := float2str(vl_cps);
pl_result := "Current CPS of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&": "&vl_cpsStr;
return 0; // OK
}
private function f_EPTF_ExecCtrl_CLI_getCurrentCPSSCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 2) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
// get the Id of the scenario:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_globalName);
if (vl_scIdx==-1) {
pl_result := "Current CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be determined: Scenario not found";
return 3; // set nonzero exit code
}
if (not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Current CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be determined: Scenario is not a weighted scenario";
return 4; // set nonzero exit code
}
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scName;
var charstring vl_statName := vl_namePrefix&".CurrentCPS";
// CurrentCPS:
var integer vl_varIdx := f_EPTF_Var_getId(vl_statName);
if (vl_varIdx==-1) {
pl_result := "Current CPS of scenario "&vl_eGrpName&"."&vl_scName&" cannot be determined: CPS is not available yet";
return 0; // ok
}
var float vl_cps := f_EPTF_Var_getFloatValue(vl_varIdx);
var charstring vl_cpsStr := float2str(vl_cps);
pl_result := "Current CPS of scenario "&vl_eGrpName&"."&vl_scName&": "&vl_cpsStr;
return 0; // OK
}
} //~group CPS
group TargetWeight {
// setTargetWeight:
private function f_EPTF_ExecCtrl_CLI_setWeightHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - sets the weight of a traffic case in a weighted scenario\n"&
"Usage: "&pl_result&" <help|tc <tcName> <WeightValue>>\n"&
" help - print this help message\n"&
" tc <tcName> <WeightValue> - sets the target weight for the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case\n"&
" <WeightValue>: value of the weight to set (float number)";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_setWeightTCHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_setWeightTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
var charstring vl_weightStr := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
vl_remaining := regexp(vl_remaining,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
if (vl_weightStr=="") {
pl_result := "Syntax error: Weight value is expected after the TC name";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
if (not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: Traffic case belongs to a non-weighted scenario: "&vl_eGrpName&"."&vl_scName;
return 4; // tc in weighted scenario cannot be stopped
}
// check the format of the Weight:
var charstring vl_floatStr := regexp(vl_weightStr,c_EPTF_CLI_floatNumber,0);
if (vl_floatStr=="") {
vl_floatStr := regexp(vl_weightStr,c_EPTF_CLI_integerNumber,0);
if (vl_floatStr=="") {
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be set: The weight value is not a float value: "&vl_weightStr;
return 5; // error
}
vl_floatStr := vl_floatStr&".0"; // create a float from the integer
}
var float vl_weight := str2float(vl_floatStr);
f_EPTF_ExecCtrl_setTCWeight(vl_tcIdx,vl_weight);
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" set successfully to "&vl_weightStr&".";
return 0; // OK
}
// getWeight:
private function f_EPTF_ExecCtrl_CLI_getWeightHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - returns the weight of a traffic case in a weighted scenario\n"&
"Usage: "&pl_result&" <help|tc <tcName>>\n"&
" help - print this help message\n"&
" tc <tcName> - returns the target weight for the given traffic case\n"&
" <tcName> has to be in the format: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>\n"&
"Where\n"&
" <EntityGroupName>: name of the entity group\n"&
" <ScenarioName>: name of the scenario\n"&
" <TrafficCaseName>: name of the traffic case";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
if (vl_firstArg=="tc") {
var charstring vl_subCommandArgs := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
return f_EPTF_ExecCtrl_CLI_getWeightTCHandler(vl_subCommandArgs,pl_result)
}
pl_result := "Syntax error in argument "&vl_firstArg&": Expecting <help|tc>";
return 1; // error;
}
private function f_EPTF_ExecCtrl_CLI_getWeightTCHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
var charstring vl_globalName := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
var charstring vl_remaining := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,1);
if (vl_remaining!="") {
pl_result := "Syntax error: Unexpected argument: "&vl_remaining;
return 1; // set nonzero exit code
}
var EPTF_CharstringList vl_splittedName := f_EPTF_CLI_splitString(vl_globalName,".",false);
if (sizeof(vl_splittedName) != 3) {
pl_result := "Syntax error in argument: "&vl_globalName&" Argument format should be: <EntityGroupName>.<ScenarioName>.<TrafficCaseName>";
return 2; // set nonzero exit code
}
var charstring vl_eGrpName := vl_splittedName[0];
var charstring vl_scName := vl_splittedName[1];
var charstring vl_tcName := vl_splittedName[2];
// get the Id of the traffic case:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if (vl_tcIdx==-1) {
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: Traffic case not found";
return 3; // set nonzero exit code
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
if (not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&" cannot be determined: Traffic case belongs to a non-weighted scenario: "&vl_eGrpName&"."&vl_scName;
return 4; // tc in weighted scenario cannot be stopped
}
var float vl_Weight := f_EPTF_ExecCtrl_getTCWeight(vl_tcIdx);
var charstring vl_weightStr := float2str(vl_Weight);
pl_result := "Target weight of traffic case "&vl_eGrpName&"."&vl_scName&"."&vl_tcName&": "&vl_weightStr;
return 0; // OK
}
} // ~group TargetWeight
group TotalCounter {
// getTotalCounter:
private function f_EPTF_ExecCtrl_CLI_getTotalCounter(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - returns the value of the given accumulated statistics\n"&
"Usage: "&pl_result&" <help|<CounterName>>\n"&
" help - print this help message\n"&
" <CounterName> - returns the value of this counter\n"&
"Where\n"&
" <CounterName>: should be one of "&log2str(c_EPTF_ExecCtrl_globalStatNames)&"\n";
return 0; // OK
}
var charstring vl_firstArg := regexp(pl_commandArgs,c_EPTF_CLI_anyWord&c_EPTF_CLI_everything,0);
//vl_firstArg should be one of c_EPTF_ExecCtrl_globalStatNames:
var charstring vl_globalStatName := vl_firstArg;
var charstring vl_globalStatNameFull := c_EPTF_ExecCtrl_statisticsRoot&"."&vl_globalStatName;
var charstring vl_dataVarName;
if (not f_EPTF_StatHandler_getVarNameByStatName(vl_globalStatNameFull, vl_dataVarName)){
pl_result := "Invalid statistics name: '"&vl_firstArg&"'. Should be one of "&log2str(c_EPTF_ExecCtrl_globalStatNames);
return 1; // error
}
var integer vl_varIdx := f_EPTF_Var_getId(vl_dataVarName);
if (vl_varIdx==-1) {
pl_result := "Invalid statistics name: '"&vl_firstArg&"'. Should be one of "&log2str(c_EPTF_ExecCtrl_globalStatNames);
return 2; // error
}
pl_result := int2str(f_EPTF_Var_getIntValue(vl_varIdx));
return 0; // ok
}
} // ~group TotalCounter
group ExitTTCN {
private function f_EPTF_ExecCtrl_CLI_exitTTCNHandler(in charstring pl_commandArgs, inout charstring pl_result) runs on EPTF_ExecCtrl_CLI_CT return integer {
if (pl_commandArgs=="help") {
pl_result := pl_result&" - orders ExecCtrl to end the test execution and terminate the application\n"&
"Usage: "&pl_result&" <help|>\n"&
" help - print this help message\n"&
" no arguments: - terminates test execution the same way as if the\n"&
" 'Exit' button was pressed on the GUI";
return 0; // OK
}
if (pl_commandArgs!="") {
pl_result := "Syntax error: Unexpected argument: "&pl_commandArgs&": Expecting <help|>";
return 1; // set nonzero exit code
}
pl_result := "Exiting from the application...";
f_EPTF_ExecCtrl_exit();
return 0; // OK;
}
} //~group ExitTTCN
} //~module EPTF_CLL_ExecCtrl_CLIFunctions