| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_StatCapture_Test_Testcases |
| // |
| // Purpose: |
| // This module contains a test application for the Statistics Capture Control feature. |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_StatCapture_Test_Testcases { |
| |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_StatMeasure_Definitions all; |
| import from EPTF_CLL_StatMeasure_Functions all; |
| //import from EPTF_CLL_Scheduler_Definitions all; |
| //import from EPTF_CLL_RBTScheduler_Functions all; |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_StatCapture_Definitions all; |
| import from EPTF_CLL_StatCapture_Functions all; |
| import from TCCFileIO_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Logging_Functions all; |
| import from EPTF_StatCapture_Test_Definitions all; |
| import from EPTF_StatCapture_Test_Functions all; |
| import from EPTF_CLL_StatCapture_Functions all; |
| |
| group BasicTest { |
| |
| testcase tc_StatCapture_Test_perf() runs on EPTF_StatCapture_Test_CT{ |
| f_StatCapture_Test_init("comparePerformance"); |
| var integer vl_varId:=-1, vl_statId:=-1, vl_grpId:=-1, vl_fd:=-1; |
| var EPTF_IntegerList vl_grpStatIdList:={}; |
| var EPTF_StatCapture_Statistics vl_stat; |
| var float vl_time; |
| |
| f_EPTF_Var_newInt("var", 8, vl_varId); |
| vl_statId := f_EPTF_StatMeasure_newStat(vl_varId, content); |
| vl_stat := f_EPTF_StatCapture_createStatforCapture(vl_statId, "statistic"); |
| |
| vl_fd := f_EPTF_StatCapture_openNewStatLogFile("LogFile"); |
| vl_time:=f_EPTF_Base_getAbsTimeInSecs(); |
| f_EPTF_StatCapture_addNewGroup("group", 1.0, {vl_fd}, {vl_stat}, vl_grpId, vl_grpStatIdList); |
| vl_time := f_EPTF_Base_getAbsTimeInSecs() - vl_time; |
| action("Elapsed time: ", log2str(vl_time)); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| testcase tc_StatCapture_Test_perf2() runs on EPTF_StatCapture_Test_CT{ |
| f_StatCapture_Test_init("comparePerformance"); |
| var integer vl_varId:=-1, vl_statId:=-1, vl_grpId:=-1, vl_fd:=-1; |
| var EPTF_IntegerList vl_grpStatIdList:={}; |
| var EPTF_StatCapture_Statistics vl_stat; |
| timer TL_time := 1.0; |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientBehavior(self)); |
| TL_time.start; |
| TL_time.timeout; |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| function f_EPTF_StatCapture_Test_clientBehavior(in EPTF_StatCapture_CT pl_server, in charstring pl_groupName := "group") |
| runs on EPTF_StatCaptureClient_Test_CT{ |
| action("client"); |
| f_EPTF_StatCaptureClient_init("alma", pl_server); |
| f_EPTF_StatMeasure_init_CT("alma"); |
| var integer vl_varId:=-1, vl_statId:=-1, vl_grpId:=-1, vl_fd:=-1; |
| var EPTF_IntegerList vl_grpStatIdList:={}; |
| var EPTF_StatCapture_Statistics vl_stat; |
| var float vl_time; |
| f_EPTF_Var_newInt("var", 80, vl_varId); |
| vl_statId := f_EPTF_StatMeasure_newStat(vl_varId, content); |
| action("start: ", log2str(f_EPTF_Base_getAbsTimeInSecs())); |
| action("IDX: ", log2str(f_EPTF_StatMeasure_createVarFromStat(vl_statId, "varstat"))) |
| f_EPTF_Var_refreshContent(vl_varId); |
| f_EPTF_StatCaptureClient_addStatsToGroup( pl_groupName,{"varstat"}, sampledAtSync); |
| timer t_timer:=0.5; |
| t_timer.start; |
| t_timer.timeout; |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_Demo |
| // |
| // Purpose: |
| // Demo test case |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // |
| // Expected Result: The tc is passed if all checks are true |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_StatCapture_Test_Demo() runs on EPTF_StatCapture_Test_CT { |
| f_StatCapture_Test_init("myStatCapture_Demo"); |
| log("StatCapture_Demo"); |
| |
| var integer vl_var1ID:=-1, vl_var2ID:= -1; //we are going to have 2 Variables |
| var integer vl_stat1ID:=-1, vl_stat2ID:=-1, vl_stat3ID := -1; //and 3 Statistics |
| |
| f_EPTF_Var_newInt("var1", 10, vl_var1ID); |
| //f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= 10}); not necessary |
| |
| vl_stat1ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content); |
| var EPTF_StatCapture_Statistics vl_stat1 := f_EPTF_StatCapture_createStatforCapture(vl_stat1ID, "mystat1name"); //other two parameters are left on default values |
| |
| vl_stat2ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta); |
| var EPTF_StatCapture_Statistics vl_stat2 := f_EPTF_StatCapture_createStatforCapture(vl_stat2ID, "mystat2name"); //other two parameters are left on default values |
| |
| f_EPTF_Var_newFloat("var2", 10.0, vl_var2ID); |
| |
| vl_stat3ID := f_EPTF_StatMeasure_newStat(vl_var2ID, deltaSum); |
| var EPTF_StatCapture_Statistics vl_stat3 := f_EPTF_StatCapture_createStatforCapture(vl_stat3ID, "mystat3name"); //other two parameters are left on default values |
| |
| var integer vl_groupidx1 := -1; |
| var integer vl_groupidx2 := -1; |
| var integer v_groupstatidx11, v_groupstatidx12, v_groupstatidx21; |
| var EPTF_IntegerList vl_group1statidxList, vl_group2statidxList; |
| |
| var integer fd1 := f_EPTF_StatCapture_openNewStatLogFile("FirstFile"); |
| var integer fd2 := f_EPTF_StatCapture_openNewStatLogFile("SecondFile"); |
| |
| f_EPTF_StatCapture_addNewGroup("group1", 1.0,{fd1}, { vl_stat1, vl_stat2, vl_stat3}, vl_groupidx1, vl_group1statidxList); |
| //f_EPTF_StatCapture_addListOfStatistics(vl_groupidx1, {vl_stat1, vl_stat2}, vl_group1statidxList); |
| |
| f_EPTF_StatCapture_addNewGroup("group2", 1.0,{fd2}, { vl_stat3 }, vl_groupidx2, vl_group2statidxList); |
| //f_EPTF_StatCapture_addStatistics(vl_groupidx2, vl_stat3, v_groupstatidx21); |
| |
| f_EPTF_StatCapture_startCaptureAll(); |
| /*f_EPTF_StatMeasure_enableStat(vl_stat1ID); |
| f_EPTF_StatMeasure_enableStat(vl_stat2ID); |
| f_EPTF_StatMeasure_enableStat(vl_stat3ID); */ //not necessary, as default is enable==true |
| |
| timer t_wait := 10.0; |
| t_wait.start; |
| |
| timer t_adjust := 1.0; |
| t_adjust.start; |
| |
| var integer vl_now := 1; |
| |
| alt { |
| [] t_adjust.timeout{ |
| f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= vl_now}); |
| f_EPTF_Var_adjustContent(vl_var2ID, {floatVal:= int2float(vl_now)}); vl_now := vl_now * 2; t_adjust.start; repeat;} |
| [] t_wait.timeout { |
| f_EPTF_StatCapture_stopGroupCapture(vl_groupidx2); |
| f_EPTF_StatCapture_InactivateStatistics(vl_groupidx2, vl_group2statidxList[0]); |
| f_EPTF_StatCapture_setTimerPeriod(vl_groupidx1, 5.0); |
| f_EPTF_StatCapture_startGroupCapture(vl_groupidx2); |
| } |
| } |
| setverdict(pass); |
| //f_EPTF_StatCapture_stopCaptureAll(); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_1 |
| // |
| // Purpose: |
| // Test case 1:logging groups to files |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // |
| // Expected Result: The tc is passed if all checks are true |
| // |
| /////////////////////////////////////////////////////////// |
| |
| testcase tc_EPTF_StatCapture_Test_1() runs on EPTF_StatCapture_Test_CT { |
| f_StatCapture_Test_init("myStatCapture_Demo"); |
| log("StatCapture_tc1"); |
| |
| var integer vl_var1ID, vl_var2ID:= -1; |
| var integer vl_stat1ID, vl_stat2ID, vl_stat3ID, vl_stat4ID := -1; |
| |
| f_EPTF_Var_newInt("var1",10,vl_var1ID); |
| |
| vl_stat1ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content); |
| var EPTF_StatCapture_Statistics vl_stat1 := f_EPTF_StatCapture_createStatforCapture(vl_stat1ID, "mystat1name"); //other two parameters are left on default values |
| |
| vl_stat2ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta); |
| var EPTF_StatCapture_Statistics vl_stat2 := f_EPTF_StatCapture_createStatforCapture(vl_stat2ID, "mystat2name"); //other two parameters are left on default values |
| |
| f_EPTF_Var_newFloat("var2",10.0,vl_var2ID); |
| |
| vl_stat3ID := f_EPTF_StatMeasure_newStat(vl_var2ID, deltaSum); |
| var EPTF_StatCapture_Statistics vl_stat3 := f_EPTF_StatCapture_createStatforCapture(vl_stat3ID, "mystat3name"); //other two parameters are left on default values |
| |
| vl_stat4ID := f_EPTF_StatMeasure_newStat(vl_var2ID, content); |
| var EPTF_StatCapture_Statistics vl_stat4 := f_EPTF_StatCapture_createStatforCapture(vl_stat4ID, "mystat4name"); //other two parameters are left on default values |
| |
| var integer vl_groupidx1, vl_groupidx2, vl_groupidx3 := -1; |
| var EPTF_IntegerList vl_group1statidxList, vl_group2statidxList, vl_group3statidxList; |
| |
| var integer fd1 := f_EPTF_StatCapture_openNewStatLogFile("FirstFile"); |
| var integer fd2 := f_EPTF_StatCapture_openNewStatLogFile("SecondFile"); |
| |
| f_EPTF_StatCapture_addNewGroup("group1", 1.0,{}, {vl_stat1, vl_stat2, vl_stat3}, vl_groupidx1, vl_group1statidxList); //log to default file (set cfg name for default file) |
| f_EPTF_StatCapture_addNewGroup("group2", 1.0,{fd1}, { vl_stat3 }, vl_groupidx2, vl_group2statidxList); |
| f_EPTF_StatCapture_addNewGroup("group3", 2.0,{fd1,fd2}, { vl_stat3, vl_stat4}, vl_groupidx3, vl_group3statidxList); |
| |
| // f_EPTF_StatCapture_addNewGroup("group3", 3.0,{5}, {stat3, vl_stat4}, vl_groupidx3, vl_group3statidxList); //wrong parameter (fd not valid) results in verdict fail |
| |
| f_EPTF_StatCapture_startCaptureAll(); |
| |
| timer t_wait := 10.0; |
| t_wait.start; |
| |
| timer t_adjust := 1.0; |
| t_adjust.start; |
| |
| var integer vl_now := 1; |
| |
| alt { |
| [] t_adjust.timeout{ |
| f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= vl_now}); |
| f_EPTF_Var_adjustContent(vl_var2ID, {floatVal:= int2float(vl_now)}); vl_now := vl_now * 2; t_adjust.start; repeat;} |
| [] t_wait.timeout {} |
| } |
| setverdict(pass); |
| f_EPTF_StatCapture_stopCaptureAll(); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_2 |
| // |
| // Purpose: |
| // Test case 2: (Statistics with periodicreset == true) |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // |
| // Expected Result: The tc is passed if all checks are true |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_2() runs on EPTF_StatCapture_Test_CT { |
| f_StatCapture_Test_init("myStatCapture_Demo"); |
| log("StatCapture_tc2"); |
| |
| var integer vl_var1ID := -1; |
| var integer vl_stat1ID, vl_stat2ID, vl_stat3ID, vl_stat4ID, vl_stat5ID, vl_stat6ID, vl_stat7ID, vl_stat8ID, vl_stat9ID, vl_stat10ID, vl_stat11ID, vl_stat12ID, vl_stat13ID, |
| vl_stat14ID := -1; |
| |
| f_EPTF_Var_newInt("var1",10,vl_var1ID); |
| |
| vl_stat1ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content); |
| var EPTF_StatCapture_Statistics vl_stat1 := f_EPTF_StatCapture_createStatforCapture(vl_stat1ID, "content"); //other two parameters are left on default values |
| |
| // vl_stat2ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content); |
| // var EPTF_StatCapture_Statistics vl_stat2 := f_EPTF_StatCapture_createStatforCapture(vl_stat2ID, "contentreset", true); //periodicreset:=true |
| // content reset does not have any effect |
| |
| vl_stat3ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta); |
| var EPTF_StatCapture_Statistics vl_stat3 := f_EPTF_StatCapture_createStatforCapture(vl_stat3ID, "delta"); //other two parameters are left on default values |
| |
| vl_stat4ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta); |
| var EPTF_StatCapture_Statistics vl_stat4 := f_EPTF_StatCapture_createStatforCapture(vl_stat4ID, "deltareset", true); //periodicreset:=true |
| |
| vl_stat5ID := f_EPTF_StatMeasure_newStat(vl_var1ID, deltaSum); |
| var EPTF_StatCapture_Statistics vl_stat5 := f_EPTF_StatCapture_createStatforCapture(vl_stat5ID, "deltasum"); //other two parameters are left on default values |
| |
| vl_stat6ID := f_EPTF_StatMeasure_newStat(vl_var1ID, deltaSum); |
| var EPTF_StatCapture_Statistics vl_stat6 := f_EPTF_StatCapture_createStatforCapture(vl_stat6ID, "deltasumreset", true); //periodicreset:=true |
| |
| vl_stat7ID := f_EPTF_StatMeasure_newStat(vl_var1ID, min); |
| var EPTF_StatCapture_Statistics vl_stat7 := f_EPTF_StatCapture_createStatforCapture(vl_stat7ID, "min"); //other two parameters are left on default values |
| |
| vl_stat8ID := f_EPTF_StatMeasure_newStat(vl_var1ID, min); |
| var EPTF_StatCapture_Statistics vl_stat8 := f_EPTF_StatCapture_createStatforCapture(vl_stat8ID, "minreset", true); //periodicreset:=true |
| |
| vl_stat9ID := f_EPTF_StatMeasure_newStat(vl_var1ID, max); |
| var EPTF_StatCapture_Statistics vl_stat9 := f_EPTF_StatCapture_createStatforCapture(vl_stat9ID, "max"); //other two parameters are left on default values |
| |
| vl_stat10ID := f_EPTF_StatMeasure_newStat(vl_var1ID, max); |
| var EPTF_StatCapture_Statistics vl_stat10 := f_EPTF_StatCapture_createStatforCapture(vl_stat10ID, "maxreset", true); //periodicreset:=true |
| |
| vl_stat11ID := f_EPTF_StatMeasure_newStat(vl_var1ID, mean); |
| var EPTF_StatCapture_Statistics vl_stat11 := f_EPTF_StatCapture_createStatforCapture(vl_stat11ID, "mean"); //other two parameters are left on default values |
| |
| vl_stat12ID := f_EPTF_StatMeasure_newStat(vl_var1ID, mean); |
| var EPTF_StatCapture_Statistics vl_stat12 := f_EPTF_StatCapture_createStatforCapture(vl_stat12ID, "meanreset", true); //periodicreset:=true |
| |
| vl_stat13ID := f_EPTF_StatMeasure_newStat(vl_var1ID, standardDev); |
| var EPTF_StatCapture_Statistics vl_stat13 := f_EPTF_StatCapture_createStatforCapture(vl_stat13ID, "standardDev"); //other two parameters are left on default values |
| |
| vl_stat14ID := f_EPTF_StatMeasure_newStat(vl_var1ID, standardDev); |
| var EPTF_StatCapture_Statistics vl_stat14 := f_EPTF_StatCapture_createStatforCapture(vl_stat14ID, "standardDevreset", true); //periodicreset:=true |
| |
| var integer vl_groupidx1 := -1; |
| var EPTF_IntegerList vl_group1statidxList; |
| |
| var integer fd1 := f_EPTF_StatCapture_openNewStatLogFile("FirstFile"); |
| |
| //f_EPTF_StatCapture_addNewGroup("group1", 1.0,{fd1}, {vl_stat1, vl_stat2, vl_stat3, vl_stat4, vl_stat5, vl_stat6}, vl_groupidx1, vl_group1statidxList); |
| f_EPTF_StatCapture_addNewGroup("group1", 1.0,{fd1}, { vl_stat1, vl_stat3, vl_stat5, vl_stat6, vl_stat7, vl_stat8, vl_stat9, vl_stat10, vl_stat11, vl_stat12, vl_stat13, vl_stat14}, vl_groupidx1, vl_group1statidxList); |
| |
| f_EPTF_StatCapture_startCaptureAll(); |
| |
| timer t_wait := 10.0; |
| t_wait.start; |
| |
| timer t_adjust := 1.0; |
| t_adjust.start; |
| |
| var integer vl_now := 1; |
| |
| alt { |
| [] t_adjust.timeout{ |
| f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= vl_now}); |
| vl_now := vl_now * 2; t_adjust.start; repeat;} |
| [] t_wait.timeout {} |
| } |
| setverdict(pass); |
| f_EPTF_StatCapture_stopCaptureAll(); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| |
| // Test case 3: (handling large logfiles) |
| // run Test case 2 with setting the config file parameters as follows: |
| // tsp_EPTF_StatCapture_def_capture_file := "DefaultFile" |
| // tsp_EPTF_StatCapture_max_file_size := 200 //200 byte |
| // tsp_EPTF_StatCapture_max_nrof_files := 3 |
| // |
| |
| }//group BasicTest |
| |
| group RegressionTest { |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_init |
| // |
| // Purpose: |
| // To test the functions f_StatCapture_init and f_StatCapture_cleanup |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // 1. Init the component |
| // 2. Check the component variables |
| // |
| // Expected Result: The tc is passed if all checks are true |
| // |
| /////////////////////////////////////////////////////////// |
| |
| testcase tc_EPTF_StatCapture_Test_init() runs on EPTF_StatCapture_Test_CT { |
| var charstring vl_name:="EPTF_StatCapture_Test_CT_name"; |
| f_StatCapture_Test_init(vl_name);// It calls f_EPTF_StatCapture_init(); |
| f_EPTF_StatCapture_Test_setVerdict(f_StatCapture_Test_checkInit(vl_name)); |
| f_EPTF_Base_cleanup_CT(); //to avoid influence of f_EPTF_StatCapture_Test_cleanup which corrects the fault. |
| f_EPTF_StatCapture_Test_setVerdict(f_StatCapture_Test_checkCleanup(vl_name)); |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_get_time |
| // |
| // Purpose: |
| // To test the function f_EPTF_StatCapture_get_time |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // 1. init the component |
| // 2. Call the function f_EPTF_StatCapture_get_time |
| // 3. Check its format (with a patterned template) |
| // Expected Result: The tc is passed if the format is correct |
| // |
| /////////////////////////////////////////////////////////// |
| |
| testcase tc_EPTF_StatCapture_Test_get_time() runs on EPTF_StatCapture_Test_CT { |
| var charstring vl_name:="EPTF_StatCapture_Test_CT_name"; |
| f_StatCapture_Test_init(vl_name);// It calls f_EPTF_StatCapture_init(); |
| var charstring vl_acttime := f_EPTF_StatCapture_get_time(); |
| var template charstring tl_time := pattern "[0-9]#(4,4)\-[0-9][0-9]\-[0-9][0-9]_[0-9][0-9].[0-9][0-9].[0-9][0-9]"; |
| log(match(vl_acttime, tl_time)); |
| f_EPTF_StatCapture_Test_setVerdict(match(vl_acttime, tl_time)); |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_openNewStatLogFile |
| // |
| // Purpose: |
| // To test the function f_EPTF_StatCapture_openNewStatLogFile |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // 1. Init the component |
| // 2 Call f_EPTF_StatCapture_openNewStatLogFile |
| // 3. Close it by f_FIO_close; |
| // 4 Open it for reading by f_FIO_open_rdonly(). |
| // The filename can be get from the component variable v_StatCapture_logfilenames |
| // 5. Close the file |
| // Expected Result: The tc is passed if the file opening was successful |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_openNewStatLogFile() runs on EPTF_StatCapture_Test_CT { |
| var charstring vl_name:="EPTF_StatCapture_Test_CT_name"; |
| var charstring vl_userfilename:="TestFile" |
| f_StatCapture_Test_init(vl_name);// It calls f_EPTF_StatCapture_init(); |
| var integer vl_fd := f_EPTF_StatCapture_openNewStatLogFile(vl_userfilename ); |
| var charstring vl_filename:= ""; |
| f_FIO_close(vl_fd) |
| //test: |
| f_EPTF_StatCapture_getFileName(1,"",vl_filename) |
| f_EPTF_Logging_debug(tsp_EPTF_StatCapture_Test_debug, vl_filename); |
| vl_fd:=-1; |
| vl_fd:=f_FIO_open_rdonly(vl_filename); |
| f_EPTF_Logging_debug(tsp_EPTF_StatCapture_Test_debug, vl_filename & " " & int2str(vl_fd)); |
| f_EPTF_StatCapture_Test_setVerdict(vl_fd!=-1); |
| if(vl_fd!=-1) { f_FIO_close(vl_fd) }; |
| f_EPTF_Base_cleanup_CT(); |
| }//tc_ |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_complex |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCapture_openNewStatLogFile, f_EPTF_StatCapture_createStatforCapture, |
| // f_EPTF_StatCapture_startCaptureAll, f_EPTF_StatCapture_stopCaptureAll, f_EPTF_StatCapture_openNewStatLogFile, |
| // f_EPTF_StatCapture_addNewGroup, f_EPTF_StatCapture_dumpStringforGroup |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // 1. Create 2 variables, the first has type of integer, the second one has type of float |
| // 2. Create 3 stats to them: content for var1, delta for var1 and deltaSum for var2 |
| // 3. Create one group with sample time 1.0 s |
| // 4. Generate statistic by adjusting the variables in every 1 second according to rule x:=2*x |
| // 5. Read the created log files, concatenate their content and check the result |
| // Execute it for readable and/or gnuplot file format by setting "tsp_EPTF_StatCapture_fileFormat" |
| // |
| // Expected Result: The tc is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_complex() runs on EPTF_StatCapture_Test_CT { |
| |
| timer T_1s:=1.0;T_1s.start;T_1s.timeout; //just to get a different timestamp for our files |
| |
| var charstring vl_name:="EPTF_StatCapture_Test_component"; |
| |
| f_StatCapture_Test_init(vl_name);// It calls f_EPTF_StatCapture_init(); |
| |
| var integer vl_var1ID:=-1, vl_var2ID:= -1; |
| var integer vl_stat1ID:=-1, vl_stat2ID:=-1, vl_stat3ID:=-1; |
| |
| //var1 |
| f_EPTF_Var_newInt("var1",10,vl_var1ID); |
| vl_stat1ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content); |
| var EPTF_CharstringList vl_statNames:= {"Int1Content","Int1Delta","Float2deltaSum"}; |
| var EPTF_StatCapture_Statistics vl_stat1 := f_EPTF_StatCapture_createStatforCapture(vl_stat1ID, vl_statNames[0], false); //other two parameters are left on default values |
| vl_stat2ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta); |
| var EPTF_StatCapture_Statistics vl_stat2 := f_EPTF_StatCapture_createStatforCapture(vl_stat2ID, vl_statNames[1],false);//other two parameters are left on default values |
| |
| //var2 |
| f_EPTF_Var_newFloat("var2",10.0,vl_var2ID); |
| vl_stat3ID := f_EPTF_StatMeasure_newStat(vl_var2ID, deltaSum); |
| var EPTF_StatCapture_Statistics vl_stat3 := f_EPTF_StatCapture_createStatforCapture(vl_stat3ID, vl_statNames[2],false);//other two parameters are left on default values |
| f_EPTF_Logging_debug(tsp_EPTF_StatCapture_Test_debug,"=========CreateaStatFor passed========="); |
| |
| var integer vl_groupidx1:=-1; |
| var EPTF_IntegerList vl_group1statidxList; |
| |
| var float vl_sampleTime0 := 1.0; |
| f_EPTF_StatCapture_addNewGroup("group1", vl_sampleTime0,{}, {vl_stat1, vl_stat2, vl_stat3}, vl_groupidx1, vl_group1statidxList); |
| //log to default file (set cfg name for default file) |
| log("=========AddGroup passed=========") |
| f_EPTF_StatCapture_Test_genarateStat(vl_var1ID,vl_var2ID, 10.0, 0.95); |
| |
| //test the files just created: |
| //log(">>>v_StatCapture_logfilenames: ",v_StatCapture_logfilenames); |
| var template charstring tl:= ""; |
| var charstring vl_fileName :=""; |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {intVal:= 0}, {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {intVal:=-9}, {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {intVal:= 1}, {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {intVal:=+2}, {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {intVal:=+4}, {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {intVal:=+8}, {floatVal:=+6.000000} }, |
| { { intVal :=32} , {intVal:=+16}, {floatVal:=+22.000000} }, |
| { { intVal :=64} , {intVal:=+32}, {floatVal:=+54.000000} }, |
| { { intVal :=128} , {intVal:=+64}, {floatVal:=+118.000000} }, |
| { { intVal :=256} , {intVal:=128}, {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(0, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_complex_fromConfigFile |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCapture_parseConfigGroup,f_EPTF_StatCapture_startCaptureAll,f_EPTF_StatCapture_stopCaptureAll |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // Set in the config file: tsp_EPTF_StatCapture_max_file_size := 200 //200 byte |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // 1. Create 2 variables, the first ahas type of integer, the second one has type of float |
| // 2. Create 3 stats to them: content for var1, delta for var1 and deltaSum for var2 |
| // 3. Create one group with sample time 1.0 s |
| // 4. Generate statistic by adjusting the variables in every 1 second according to rule x:=2*x |
| // 5. Read the created log files, concatenate/merge their content and check the result |
| // Execute it for readable and/or gnuplot file format by setting "tsp_EPTF_StatCapture_fileFormat" |
| // |
| // Expected Result: The tc is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_complex_fromConfigFile() runs on EPTF_StatCapture_Test_CT { |
| |
| timer T_1s:=1.0;T_1s.start;T_1s.timeout; //just to get a different timestamp for our files |
| |
| var charstring vl_name:="EPTF_StatCapture_Test_component"; |
| f_StatCapture_Test_init(vl_name);// It calls f_EPTF_StatCapture_init(); |
| |
| var integer vl_var1ID:=-1, vl_var2ID:= -1; |
| var integer vl_stat1ID:=-1, vl_stat2ID:=-1, vl_stat3ID:=-1; |
| |
| f_EPTF_Var_newInt("var1",10,vl_var1ID); |
| f_EPTF_Var_newFloat("var2",10.0,vl_var2ID); |
| f_EPTF_StatCapture_parseConfigGroup(); |
| |
| var EPTF_CharstringList vl_statNames:= { } |
| for (var integer i:=0;i<sizeof(tsp_EPTF_StatCapture_captureGroups[0].statistics);i:=i+1){ |
| vl_statNames[i]:=tsp_EPTF_StatCapture_captureGroups[0].statistics[i].statName; |
| } |
| |
| f_EPTF_StatCapture_Test_genarateStat(vl_var1ID,vl_var2ID, 10.0, 0.95); |
| |
| //test the files just created: |
| //log(">>>v_StatCapture_logfilenames: ",v_StatCapture_logfilenames); |
| var template charstring tl:= ""; |
| var charstring vl_fileName :=""; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {intVal:= 0}, {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {intVal:=-9}, {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {intVal:= 1}, {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {intVal:=+2}, {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {intVal:=+4}, {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {intVal:=+8}, {floatVal:=+6.000000} }, |
| { { intVal :=32} , {intVal:=+16}, {floatVal:=+22.000000} }, |
| { { intVal :=64} , {intVal:=+32}, {floatVal:=+54.000000} }, |
| { { intVal :=128} , {intVal:=+64}, {floatVal:=+118.000000} }, |
| { { intVal :=256} , {intVal:=128}, {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile( |
| 0, |
| tsp_EPTF_StatCapture_captureGroups[0].groupName, |
| tsp_EPTF_StatCapture_captureGroups[0].timerPeriod, |
| vl_statNames, |
| vl_expectedResults |
| ); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_clientServer_GroupAll |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCaptureClient_init, f_EPTF_StatCaptureClient_AddStatsToGroup, |
| // f_EPTF_StatCaptureClient_startGroupAll, f_EPTF_StatCaptureClient_stopGroupAll |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The test is basically the same as tc_EPTF_StatCapture_Test_complex just |
| // the statistics and the logging is on 2 separate component. |
| // |
| // Expected Result: The testcase is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_clientServer_groupAll() runs on EPTF_StatCapture_Test_CT { |
| action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self)); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_clientServer_maxWaitTime |
| // |
| // Purpose: |
| // To test if the variable timeouts if the response is delayed. |
| // StatcaptureClient addStatsToGroup function is called and even if the |
| // component is not able to process any incoming messages the |
| // variable should not timeout on the server component. |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // StatcaptureClient calls the f_EPTF_StatCaptureClient_addStatsToGroup |
| // function 2 times and then the component is disabled to handle any |
| // incoming messages until the variable timer timeouts. |
| // On the server component the test waits for more than max wait time. |
| // And then it checks if the variable timeout-error appears in the log. |
| // The test passes if there is no such error. |
| // |
| // Expected Result: |
| // Test should pass |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_clientServer_maxWaitTime() runs on f_EPTF_StatCapture_Test_CheckWarning_CT { |
| action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_EPTF_StatCapture_Test_CheckWarning_init(vl_name); |
| f_EPTF_StatCapture_Test_CheckWarning_setWarning("*Connection establishment is unsuccessful*"); |
| |
| var float pl_maxWaitTime := 0.1234; |
| f_EPTF_Var_setMaxWaitTime(pl_maxWaitTime); |
| f_EPTF_Var_setMaxWaitTimeForByeAck(0.1); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_maxWaitTime_behaviour(self, pl_maxWaitTime)); |
| |
| timer vl_timer := pl_maxWaitTime + 1.0; |
| vl_timer.start; |
| vl_timer.timeout; |
| |
| if (f_EPTF_Base_checkExpectedError("*No response received for subscribe*")) { |
| setverdict(fail, "timeout detected in variable"); |
| } else { |
| setverdict(pass); |
| } |
| f_EPTF_Base_stop(none); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_clientServer_Group |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCaptureClient_init, f_EPTF_StatCaptureClient_AddStatsToGroup, |
| // f_EPTF_StatCaptureClient_startGroup, f_EPTF_StatCaptureClient_stopGroup |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The test is basically the same as tc_EPTF_StatCapture_Test_complex just |
| // the statistics and the logging is on 2 separate component. |
| // |
| // Expected Result: The testcase is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_clientServer_group() runs on EPTF_StatCapture_Test_CT { |
| action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self,"group1")); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_clientServer_restart |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCaptureClient_init, f_EPTF_StatCaptureClient_AddStatsToGroup, |
| // f_EPTF_StatCaptureClient_startGroup, f_EPTF_StatCaptureClient_stopGroup then startgroup again. |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The test is basically the same as tc_EPTF_StatCapture_Test_complex just |
| // the statistics and the logging is on 2 separate component. |
| // |
| // Expected Result: The testcase is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_clientServer_restart() runs on EPTF_StatCapture_Test_CT { |
| action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self,"group1",2)); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} }, |
| { { intVal :=512} , {floatVal:=+502.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_clientServer_delete |
| // |
| // Purpose: |
| // To test the functions f_EPTF_StatCaptureClient_init, f_EPTF_StatCaptureClient_AddStatsToGroup, |
| // f_EPTF_StatCaptureClient_startGroup, f_EPTF_StatCaptureClient_stopGroup then delete then start again. |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The test is basically the same as tc_EPTF_StatCapture_Test_complex just |
| // the statistics and the logging is on 2 separate component. |
| // |
| // Expected Result: The testcase is passed if the header, the body and the tail is the expected. |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_clientServer_delete() runs on EPTF_StatCapture_Test_CT { |
| action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self,"group1",2, true)); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} }, |
| { { intVal :=512} , {floatVal:=+502.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| |
| } |
| |
| const charstring c_test_GroupStatDirOK := "/tmp/"; |
| const charstring c_test_GroupStatDirWrong := "noSuchPiglet"; |
| const charstring c_test_GroupStatDirReadOnly := "/root/"; |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_getSetGroupStatDir |
| // |
| // Purpose: |
| // Demo test case for get|set group statistics dir |
| // [artf367628 AFS debug timebox: test set|get] |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // The testcase runs on EPTF_StatCapture_CT. Steps: |
| // |
| // Expected Result: The tc is passed if all checks are true |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_getSetGroupStatDir() runs on EPTF_StatCapture_Test_CT { |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| var charstring vl_GroupStatDir := ""; |
| |
| var charstring vl_test_GroupStatDir := f_EPTF_StatCapture_getGroupStatDirectory(); |
| // action("f_StatCapture_Test_init->",vl_test_GroupStatDir); |
| if(vl_test_GroupStatDir != vl_GroupStatDir){ |
| setverdict(fail, "GroupStat directory not changed. "); |
| } |
| f_EPTF_StatCapture_setGroupStatDirectory(c_test_GroupStatDirWrong); |
| vl_test_GroupStatDir := f_EPTF_StatCapture_getGroupStatDirectory(); |
| // action("f_EPTF_StatCapture_setGroupStatDirectory->",vl_test_GroupStatDir); |
| if(vl_test_GroupStatDir != c_test_GroupStatDirWrong){ |
| setverdict(fail, "GroupStat directory not changed. "); |
| } |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir |
| // |
| // Purpose: |
| // To test the function f_EPTF_StatCapture_handleSubscribeAndAddToGroup |
| // with set GroupStatDir |
| // [artf367628 AFS debug timebox: test set + open groupstat] |
| // |
| // Requirement: |
| // - |
| // |
| // Expected Result: The tc is passed if the file opening was successful |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir() runs on EPTF_StatCapture_Test_CT { |
| // action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| f_EPTF_StatCapture_setGroupStatDirectory(c_test_GroupStatDirOK); |
| var charstring vl_test_GroupStatDir := f_EPTF_StatCapture_getGroupStatDirectory(); |
| // action("tc_EPTF_StatCapture_Test_openNewStatLogFileWithFolder->",vl_test_GroupStatDir); |
| if(vl_test_GroupStatDir != c_test_GroupStatDirOK){ |
| setverdict(fail, "GroupStat directory not changed. "); |
| } |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self)); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| |
| }//tc_ |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir_negative_ReadOnly |
| // |
| // Purpose: |
| // To test the function f_EPTF_StatCapture_handleSubscribeAndAddToGroup |
| // with set GroupStatDir |
| // [artf367628 AFS debug timebox: test set + open groupstat negative] |
| // |
| // Requirement: |
| // - |
| // |
| // Expected Result: The tc is passed if the file opening was successful |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir_negative_ReadOnly() runs on EPTF_StatCapture_Test_CT { |
| // action("=========StatCapture server started=========") |
| var charstring vl_name:="EPTF_StatCapture_Test_mtc"; |
| f_StatCapture_Test_init(vl_name); |
| |
| f_EPTF_StatCapture_setGroupStatDirectory(c_test_GroupStatDirReadOnly); |
| var charstring vl_test_GroupStatDir := f_EPTF_StatCapture_getGroupStatDirectory(); |
| // action("tc_EPTF_StatCapture_Test_openNewStatLogFileWithFolder->",vl_test_GroupStatDir); |
| if(vl_test_GroupStatDir != c_test_GroupStatDirReadOnly){ |
| setverdict(fail, "GroupStat directory not changed. "); |
| } |
| |
| f_EPTF_Base_setNegativeTestMode(true); |
| f_EPTF_Base_setExpectedErrorMsg("*Cannot open new statistics log file\[*\] Permission*"); |
| |
| var EPTF_StatCaptureClient_Test_CT vl_client; |
| vl_client := EPTF_StatCaptureClient_Test_CT.create; |
| vl_client.start(f_EPTF_StatCapture_Test_clientServer_clientBehavior(self)); |
| |
| connect(self : sync_PCO, vl_client : sync_PCO); |
| alt{ |
| [] sync_PCO.receive { } |
| } |
| |
| setverdict(pass); |
| |
| var template charstring tl:= ""; |
| var float vl_sampleTime0 := 1.0; |
| var EPTF_CharstringList vl_statNames:= {"var1","varstat3"}; |
| |
| var EPTF_StatCapture_Test_DcArray vl_expectedResults := { |
| { { intVal :=10 } , {floatVal:=+0.000000} }, |
| { { intVal := 1 } , {floatVal:=-9.000000} }, |
| { { intVal := 2 } , {floatVal:=-8.000000} }, |
| { { intVal := 4 } , {floatVal:=-6.000000} }, |
| { { intVal := 8 } , {floatVal:=-2.000000} }, |
| { { intVal :=16 } , {floatVal:=+6.000000} }, |
| { { intVal :=32} , {floatVal:=+22.000000} }, |
| { { intVal :=64} , {floatVal:=+54.000000} }, |
| { { intVal :=128} , {floatVal:=+118.000000} }, |
| { { intVal :=256} , {floatVal:=+246.000000} } |
| } |
| f_EPTF_StatCapture_Test_checkCapturedFile(1, "group1", vl_sampleTime0, vl_statNames, vl_expectedResults); |
| f_EPTF_Base_cleanup_CT(); |
| |
| }//tc_ |
| |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_StatCapture_Test_openNewStatLogFile_sametime |
| // |
| // Purpose: |
| // To test the function f_EPTF_StatCapture_openNewStatLogFile |
| // create capture file on same time |
| // [artf382599: Investigate : SYS_SELFTEST_GenApp_MAP] |
| // |
| // Requirement: |
| // - |
| // |
| // Expected Result: The tc is passed if the all file opening was successful |
| // and create the required files |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| modulepar charstring tsp_EPTF_StatCapture_def_capture_file := "Default_Capture_File"; |
| testcase tc_StatCapture_Test_openNewStatLogFile_sametime() runs on EPTF_StatCapture_Test_CT{ |
| action("========= StatCapture_Test_openNewStatLogFile_sametime server started========="); |
| var charstring vl_name:="openNewStatLogFile_sametime"; |
| var charstring vl_statbasename:="bubu"; |
| f_EPTF_StatCapture_init(vl_name); |
| var integer vl_ret := f_EPTF_StatCapture_openNewStatLogFile(vl_statbasename); |
| timer TL_time := 2.0; |
| var EPTF_StatCaptureClient_Test_openNewStatLogFile_CT vl_client_1; |
| var EPTF_StatCaptureClient_Test_openNewStatLogFile_CT vl_client_2; |
| vl_client_1 := EPTF_StatCaptureClient_Test_openNewStatLogFile_CT.create; |
| vl_client_2 := EPTF_StatCaptureClient_Test_openNewStatLogFile_CT.create; |
| vl_client_1.start(f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior(self, vl_statbasename)); |
| vl_client_2.start(f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior(self, vl_statbasename)); |
| TL_time.start; |
| TL_time.timeout; |
| |
| setverdict(pass); |
| var charstring vl_fileName :=""; |
| var boolean vl_retval:= true; |
| var charstring vl_expectedLine0 := tsp_EPTF_StatCapture_def_capture_file; |
| vl_expectedLine0 := vl_expectedLine0 & "_" & vl_name & "_" & log2str(self) & "_*"; |
| var charstring vl_expectedLine1 := vl_statbasename; |
| vl_expectedLine1 := vl_expectedLine1 & "_" & vl_name & "_" & log2str(self) & "_*"; |
| |
| vl_retval := f_EPTF_StatCapture_getFileName(0, "", vl_fileName); |
| if(vl_retval == false) { |
| setverdict(fail,"tc_StatCapture_Test_openNewStatLogFile_sametime get filename [0]"); |
| } else { |
| action("tc_StatCapture_Test_openNewStatLogFile_sametime [0] - filename >> ",vl_fileName); |
| var template charstring vt_template0 := pattern vl_expectedLine0; |
| if(not match(vl_fileName, vt_template0)){ |
| setverdict(fail,match(vl_fileName, vt_template0)); |
| } else { |
| vl_retval := f_EPTF_StatCapture_getFileName(1, "", vl_fileName); |
| if(vl_retval == false) { |
| setverdict(fail,"tc_StatCapture_Test_openNewStatLogFile_sametime get filename [1]"); |
| } else { |
| action("tc_StatCapture_Test_openNewStatLogFile_sametime [1] - filename >> ",vl_fileName); |
| var template charstring vt_template1 := pattern vl_expectedLine1; |
| if(not match(vl_fileName, vt_template1)){ |
| setverdict(fail,match(vl_fileName, vt_template1)); |
| } |
| } |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| function f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior(in EPTF_StatCapture_CT pl_server, in charstring pl_statbasename := "base") |
| runs on EPTF_StatCaptureClient_Test_openNewStatLogFile_CT{ |
| action("client:StatCapture_Test_openNewStatLogFile_sametime-" & log2str(self)); |
| f_EPTF_StatCapture_init(pl_statbasename); |
| var integer vl_ret := f_EPTF_StatCapture_openNewStatLogFile(pl_statbasename); |
| timer TL_timer:=0.5; |
| TL_timer.start; |
| TL_timer.timeout; |
| setverdict(pass); |
| var charstring vl_fileName :=""; |
| var boolean vl_retval:= true; |
| var charstring vl_expectedLine0 := tsp_EPTF_StatCapture_def_capture_file; |
| vl_expectedLine0 := vl_expectedLine0 & "_" & pl_statbasename & "_" & log2str(self) & "_*"; |
| var charstring vl_expectedLine1 := pl_statbasename; |
| vl_expectedLine1 := vl_expectedLine1 & "_" & pl_statbasename & "_" & log2str(self) & "_*"; |
| |
| vl_retval := f_EPTF_StatCapture_getFileName(0, "", vl_fileName); |
| if(vl_retval == false) { |
| setverdict(fail,"f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior get filename [0]"); |
| } else { |
| action("f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior [0] - filename >> ",vl_fileName); |
| var template charstring vt_template0 := pattern vl_expectedLine0; |
| if(not match(vl_fileName, vt_template0)){ |
| setverdict(fail,match(vl_fileName, vt_template0)); |
| } else { |
| vl_retval := f_EPTF_StatCapture_getFileName(1, "", vl_fileName); |
| if(vl_retval == false) { |
| setverdict(fail,"f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior get filename [1]"); |
| } else { |
| action("f_EPTF_StatCapture_Test_openNewStatLogFile_clientBehavior [1] - filename >> ",vl_fileName); |
| var template charstring vt_template1 := pattern vl_expectedLine1; |
| if(not match(vl_fileName, vt_template1)){ |
| setverdict(fail,match(vl_fileName, vt_template1)); |
| } |
| } |
| } |
| } |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| //========== Test Objects (files to be tested)====================== |
| // 30 functions |
| //r: test is ready |
| //nr: test is not ready |
| //r function f_EPTF_StatCapture_init(in charstring pl_selfName) runs on EPTF_StatCapture_CT { |
| // function f_EPTF_StatCapture_addNewGroup(in charstring pl_groupname, in float pl_timerperiod,in EPTF_IntegerList pl_logfilesfd := {}, in EPTF_StatCapture_GroupStatistics pl_statList := {}, out integer pl_groupidx, |
| //r function f_EPTF_StatCapture_openNewStatLogFile(in charstring pl_userfilename) runs on EPTF_StatCapture_CT return integer{ |
| //nr function f_EPTF_StatCapture_deleteGroup(in integer pl_groupidx) runs on EPTF_StatCapture_CT { |
| // function f_EPTF_StatCapture_getGroupByName(in charstring pl_groupname, out integer pl_groupidx) runs on EPTF_StatCapture_CT return boolean{ |
| //r function f_EPTF_StatCapture_createStatforCapture(in integer pl_statID, in charstring pl_statname, in boolean pl_periodicreset := false, in boolean pl_activestat:= true) runs on EPTF_StatCapture_CT return EPTF_StatCapture_Statistics{ |
| //r function f_EPTF_StatCapture_addStatistics(in integer pl_groupidx, in EPTF_StatCapture_Statistics pl_stat, out integer pl_groupstatidx) runs on EPTF_StatCapture_CT { |
| //nr function f_EPTF_StatCapture_addListOfStatistics(in integer pl_groupidx, in EPTF_StatCapture_GroupStatistics pl_statList, out EPTF_IntegerList pl_groupstatidxList) runs on EPTF_StatCapture_CT { |
| //nr function f_EPTF_StatCapture_InactivateStatistics(in integer pl_groupidx, in integer pl_groupstatidx) runs on EPTF_StatCapture_CT { |
| //nr function f_EPTF_StatCapture_ActivateStatistics(in integer pl_groupidx, in integer pl_groupstatidx) runs on EPTF_StatCapture_CT { |
| //nr function f_EPTF_StatCapture_getStatisticsID(in EPTF_StatCapture_Statistics pl_stat, in integer pl_groupidx, out integer pl_groupstatidx) runs on EPTF_StatCapture_CT return boolean { |
| //nr function f_EPTF_StatCapture_setTimerPeriod(in integer pl_groupidx, in float pl_timerperiod) runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_startCaptureAll(in charstring pl_capturemode := "programmed") runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_startGroupCapture(in integer pl_groupidx, in charstring pl_capturemode := "programmed") runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_stopGroupCapture(in integer pl_groupidx, in boolean pl_valid := true) runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_stopCaptureAll(in boolean pl_valid := true) runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_handleEvent(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex) runs on EPTF_StatCapture_CT return boolean{ |
| //r function f_EPTF_StatCapture_parseConfigGroup() runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_cleanup() runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_addNewFileData(in integer pl_startfd ) runs on EPTF_StatCapture_CT return integer { //pl_idx is returned as groupID |
| //r function f_EPTF_StatCapture_checkFileDataUnique(in integer pl_startfd) runs on EPTF_StatCapture_CT return integer { |
| //r function f_EPTF_StatCapture_checkGroupName(in charstring pl_name, out integer pl_idx) runs on EPTF_StatCapture_CT return boolean { |
| //r function f_EPTF_StatCapture_dumpStringforGroup(in integer pl_groupidx, in charstring pl_logstring) runs on EPTF_StatCapture_CT { |
| //r function f_EPTF_StatCapture_dumpStringtoFile(in integer pl_fd, in charstring pl_logstring) runs on EPTF_StatCapture_CT { |
| //r external function f_EPTF_StatCapture_get_time(in charstring formatstring := "%Y-%m-%d_%H.%M.%S", in boolean milisec := false) return charstring; |
| // === |
| //nr function f_EPTF_StatCaptureControl_init(in charstring pl_selfName, in EPTF_NS_CT pl_NS_ServerCompRef, in boolean pl_autoControlEnabled := true) runs on EPTF_StatCaptureControl_CT { |
| // function f_EPTF_StatCaptureControl_User_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_StatCaptureControl_CT { |
| //nr function f_EPTF_StatCaptureControl_Execution_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_StatCaptureControl_CT { |
| //nr function f_EPTF_StatCaptureControl_Load_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_StatCaptureControl_CT { |
| //nr function f_EPTF_StatCaptureControl_cleanup() runs on EPTF_StatCaptureControl_CT { |
| |
| }//group RegressionTest |
| |
| control { |
| |
| execute(tc_EPTF_StatCapture_Test_init()); |
| execute(tc_EPTF_StatCapture_Test_get_time()); |
| execute(tc_EPTF_StatCapture_Test_openNewStatLogFile()); |
| execute(tc_EPTF_StatCapture_Test_complex()); |
| execute(tc_EPTF_StatCapture_Test_complex_fromConfigFile()); |
| execute(tc_EPTF_StatCapture_Test_clientServer_groupAll()); |
| execute(tc_EPTF_StatCapture_Test_clientServer_group()); |
| execute(tc_EPTF_StatCapture_Test_clientServer_restart()); |
| execute(tc_EPTF_StatCapture_Test_clientServer_delete()); |
| // [artf367628 AFS debug timebox: tests] |
| execute(tc_EPTF_StatCapture_Test_getSetGroupStatDir()); |
| execute(tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir()); |
| execute(tc_EPTF_StatCapture_Test_handleSubscribeAndAddToGroupWithGroupStatDir_negative_ReadOnly()); |
| // [artf382599 : create capture file on same time test] |
| execute(tc_StatCapture_Test_openNewStatLogFile_sametime()); |
| execute(tc_EPTF_StatCapture_Test_clientServer_maxWaitTime()); |
| |
| } |
| |
| } // end of module |