diff --git a/src/Logging/EPTF_CLL_Logging_Definitions.ttcn b/src/Logging/EPTF_CLL_Logging_Definitions.ttcn index 7061ac9001993be9725003846ce538f24660a88f..cda4dfad6100266331c056cc75a3bd1f4e6d6de4 100644 --- a/src/Logging/EPTF_CLL_Logging_Definitions.ttcn +++ b/src/Logging/EPTF_CLL_Logging_Definitions.ttcn @@ -266,6 +266,9 @@ type component EPTF_Logging_CT extends EPTF_Base_CT { private var integer v_EPTF_Logging_myMaskId; // the Id of my logging masks //private var EPTF_CharstringList v_EPTF_Logging_errorMsgs := {}; // the list of error messages - global var used in Common instead private var charstring v_EPTF_Logging_expectedError := ""; // the expected assert message at cleanup + private var EPTF_CharstringList v_EPTF_Logging_expectedWarnings := {} // the expected warning messagea checked at cleanup + private var EPTF_BooleanList v_EPTF_Logging_expectedWarning_logged := {} + public var EPTF_Logging_strList v_Logging_selectionList := {"EPTF_CLL", "EPTF_User"}; } diff --git a/src/Logging/EPTF_CLL_Logging_Functions.ttcn b/src/Logging/EPTF_CLL_Logging_Functions.ttcn index 593bdad86266a6445c687e7a164de9efe561562f..ec61adeebde1ccdbde4abf13c88b17d162a4351d 100644 --- a/src/Logging/EPTF_CLL_Logging_Functions.ttcn +++ b/src/Logging/EPTF_CLL_Logging_Functions.ttcn @@ -63,6 +63,7 @@ // <f_EPTF_Logging_checkExpectedError> // <f_EPTF_Logging_registerPreambleFn> // <f_EPTF_Logging_removePreambleFn> +// <f_EPTF_Logging_setExpectedWarningMsg> // /////////////////////////////////////////////////////////////// @@ -502,6 +503,10 @@ public function f_EPTF_Logging_init_CT(in charstring pl_selfName) runs on EPTF_L f_loggingUI_refreshVar := null; f_loggingUI_update := null; + v_EPTF_Logging_expectedWarnings := {} + v_EPTF_Logging_expectedWarning_logged := {} + + f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Logging_checkExpectedWarnings_preamble_FT)); // create my log masks: v_EPTF_Logging_myMaskId := f_EPTF_Logging_registerComponentMasks("EPTF_Logging", {"Warning", "Debug", "DebugM", "DebugV"}, EPTF_Logging_CLL); @@ -559,6 +564,7 @@ runs on EPTF_Logging_CT { return; } + f_EPTF_Logging_checkWarnings_at_cleanup(); v_EPTF_Logging_ComponentMask_List := {}; v_EPTF_Logging_preambleFnList := {}; v_EPTF_Logging_isRegisteredPreambleFn := false; @@ -1206,6 +1212,53 @@ runs on EPTF_Logging_CT } } +private function f_EPTF_Logging_checkExpectedWarnings_preamble_FT(in charstring pl_message) runs on EPTF_Logging_CT { + if (not match(pl_message,pattern "*Warning*")) { + return; + } + var charstring vl_pattern; + for (var integer i:=0; i<sizeof(v_EPTF_Logging_expectedWarnings); i:=i+1) { + vl_pattern := v_EPTF_Logging_expectedWarnings[i]; + if (match(pl_message,pattern vl_pattern)) { + v_EPTF_Logging_expectedWarning_logged[i] := true; // verdict is only pass if this warning is logged + } + } +} + +private function f_EPTF_Logging_checkWarnings_at_cleanup() runs on EPTF_Logging_CT { + for (var integer i:=0; i<sizeof(v_EPTF_Logging_expectedWarnings); i:=i+1) { + if (v_EPTF_Logging_expectedWarning_logged[i] == false) { + setverdict(fail, "Expected warning was not logged: ", v_EPTF_Logging_expectedWarnings[i]) + return; + } + } + setverdict(pass) +} + +/////////////////////////////////////////////////////////// +// Function: f_EPTF_Logging_setExpectedWarningMsg +// +// Purpose: +// Sets a warning message that is checked in cleanup if it was among the warning messages logged. +// +// Parameters: +// pl_expectedWarning - *in charstring* - the warning message pattern to expect as warning log +// +// Return Value: +// - +// +// Detailed Comments: +// The expected warning patterns are automatically checked in <f_EPTF_Logging_cleanup_CT>, +// and the verdict is set automatically to pass if all matches with any warning messages, and fail if any of them does not match. +// If this function is called more than once, several expected warning messages can be set +// +/////////////////////////////////////////////////////////// +public function f_EPTF_Logging_setExpectedWarningMsg(in charstring pl_expectedWarning) runs on EPTF_Logging_CT { + v_EPTF_Logging_expectedWarnings := v_EPTF_Logging_expectedWarnings & {pl_expectedWarning}; + v_EPTF_Logging_expectedWarning_logged := v_EPTF_Logging_expectedWarning_logged & {false} +} + + ////////////////////////////////////////////////////////// // Function: f_EPTF_Logging_logAll // diff --git a/test/DataSource/EPTF_DataSource_Test_Functions.ttcn b/test/DataSource/EPTF_DataSource_Test_Functions.ttcn index 8f91b552d73359e31e94278fdab2c7755a90b459..c8e2e18c8f245425a6c1cc5f0179a636ec5e87ec 100644 --- a/test/DataSource/EPTF_DataSource_Test_Functions.ttcn +++ b/test/DataSource/EPTF_DataSource_Test_Functions.ttcn @@ -255,7 +255,7 @@ group EPTF_DataSource_TestFunctions { const charstring c_EPTF_CLL_DataSourceClient_Test_DSOwnerValueHandlerParam := "ValueHandlerParam"; const charstring c_EPTF_CLL_DataSourceClient_Test_DSOwnerValueHandlerParam2 := "ValueHandlerParam2"; - function f_EPTF_CLL_DataSourceClient_Test_dsOwnerBehaviour(in charstring pl_selfName, in EPTF_DataSource_CT pl_sourceCompRef, in charstring pl_errMessage := "") runs on EPTF_CLL_DataSource_Client_CT { + function f_EPTF_CLL_DataSourceClient_Test_dsOwnerBehaviour(in charstring pl_selfName, in EPTF_DataSource_CT pl_sourceCompRef, in charstring pl_errMessage := "", in charstring pl_warningMessage := "") runs on EPTF_CLL_DataSource_Client_CT { f_EPTF_DataSourceClient_init_CT(pl_selfName,pl_sourceCompRef); var integer vl_varIdx; f_EPTF_Var_newInt(c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName&"."&c_EPTF_CLL_DataSourceClient_Test_DSOwnerDataVarName,0,vl_varIdx); @@ -273,6 +273,9 @@ group EPTF_DataSource_TestFunctions { f_EPTF_Base_setNegativeTestMode(); f_EPTF_Base_setExpectedErrorMsg(pl_errMessage); } + if (pl_warningMessage != "") { + f_EPTF_Logging_setExpectedWarningMsg(pl_warningMessage); + } f_EPTF_Base_wait4Shutdown(); } @@ -7615,7 +7618,7 @@ group setDataValueNonBlocking { } //this function initialize datasource and client for test setDataValue_nonBlocking - function f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init(in charstring pl_name, in charstring pl_errMessage := "") runs on EPTF_CLL_DataSource_Test_NonBlocking_CT { + function f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init(in charstring pl_name, in charstring pl_errMessage := "", in charstring pl_warningMessage := "") runs on EPTF_CLL_DataSource_Test_NonBlocking_CT { var charstring c_test := "DataSource_setDataValueNonBlocking" & pl_name; @@ -7625,7 +7628,7 @@ group setDataValueNonBlocking { // start DSClient DataOwner CT var EPTF_DataSource_CT vl_dataSourceComp := self; var EPTF_CLL_DataSource_Client_CT vl_client_owner := EPTF_CLL_DataSource_Client_CT.create; - vl_client_owner.start(f_EPTF_CLL_DataSourceClient_Test_dsOwnerBehaviour(c_test & "_DsOwner",vl_dataSourceComp, pl_errMessage)); + vl_client_owner.start(f_EPTF_CLL_DataSourceClient_Test_dsOwnerBehaviour(c_test & "_DsOwner",vl_dataSourceComp, pl_errMessage, pl_warningMessage)); v_Test_NonBlocking_clientRef := vl_client_owner; timer t_wait := 1.0; diff --git a/test/DataSource/EPTF_DataSource_Test_Testcases.ttcn b/test/DataSource/EPTF_DataSource_Test_Testcases.ttcn index 63035db0793622da207088b18e94b629691594b6..4e753020b9cfec4d60bf10fa7025a67b94c501f4 100644 --- a/test/DataSource/EPTF_DataSource_Test_Testcases.ttcn +++ b/test/DataSource/EPTF_DataSource_Test_Testcases.ttcn @@ -3631,7 +3631,7 @@ testcase tc_EPTF_CLL_DataSource_Test_setDataValue_nonblocking_setIntValToEptfVar /////////////////////////////////////////////////////////// testcase tc_EPTF_CLL_DataSource_Test_setDataValue_nonblocking_negative_bad_int_type() runs on EPTF_CLL_DataSource_Test_NonBlocking_CT { - f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init("negative_bad_int_type", "Error: EPTF_Var: ERROR:Cannot convert direct content*"); + f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init("negative_bad_int_type", pl_warningMessage := "EPTF_Var:Warning: ERROR:Cannot convert direct content*"); var EPTF_CLL_DataSource_Test_NonBlocking_Handler vl_handler := {dataValueHandler:=refers(f_EPTF_DataSourceTest_NonBlocking_setDataValue_getDataHandler)}; @@ -3663,7 +3663,7 @@ testcase tc_EPTF_CLL_DataSource_Test_setDataValue_nonblocking_negative_bad_int_t /////////////////////////////////////////////////////////// testcase tc_EPTF_CLL_DataSource_Test_setDataValue_nonblocking_negative_bad_intlist_type() runs on EPTF_CLL_DataSource_Test_NonBlocking_CT { - f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init("negative_bad_intlist_type", "Error: EPTF_Var: ERROR:Cannot convert direct content*"); + f_EPTF_CLL_DataSource_Test_setDataValue_nonBlocking_init("negative_bad_intlist_type", pl_warningMessage := "EPTF_Var:Warning: ERROR:Cannot convert direct content*"); var EPTF_CLL_DataSource_Test_NonBlocking_Handler vl_handler := {dataValueHandler:=refers(f_EPTF_DataSourceTest_NonBlocking_setDataValue_getDataHandler)}; diff --git a/test/DsRestAPI/EPTF_DsRestAPI_Test_Testcases.ttcn b/test/DsRestAPI/EPTF_DsRestAPI_Test_Testcases.ttcn index 23bdf61909d9c484a18de7007f7c4950fa07b8ea..f3788f36c49f27c354cf59ad2269d49c83ea2df6 100644 --- a/test/DsRestAPI/EPTF_DsRestAPI_Test_Testcases.ttcn +++ b/test/DsRestAPI/EPTF_DsRestAPI_Test_Testcases.ttcn @@ -1130,8 +1130,8 @@ testcase tc_EPTF_DsRestAPI_Test_DSServer_JSONviaHTTP() runs on DsRestAPI_Test_CT f_PutEnv("PYTHONDONTWRITEBYTECODE", "True"); - f_EPTF_DsRestAPI_init_CT("tc_EPTF_DsRestAPI_Test_DSServer_JSONviaHTTP"); - f_EPTF_DsRestAPI_Test_DS_init_CT("tc_EPTF_DsRestAPI_Test_DSServer_JSONviaHTTP",self); + f_EPTF_DsRestAPI_init_CT("tc_EPTF_DsRestAPI_Test_DSServer_JSON"); // component name should be the same as in tc_EPTF_DsRestAPI_Test_DSServer_JSON, because response contains PTC name + f_EPTF_DsRestAPI_Test_DS_init_CT("tc_EPTF_DsRestAPI_Test_DSServer_JSON",self); f_EPTF_DsRestAPI_start(tsp_EPTF_DsRestAPI_HTTPServer_RemoteAddress, tsp_EPTF_DsRestAPI_HTTPServer_RemotePort); diff --git a/test/Variable/EPTF_Variable_Test_Testcases.ttcn b/test/Variable/EPTF_Variable_Test_Testcases.ttcn index 6e8438f2aa0cd980fb6a57417941abc8dea48c66..1e05cc5d70b95e7c7a5a82401bec632e05953da3 100644 --- a/test/Variable/EPTF_Variable_Test_Testcases.ttcn +++ b/test/Variable/EPTF_Variable_Test_Testcases.ttcn @@ -4330,32 +4330,10 @@ testcase tc_EPTF_Var_SubscribeTest_pull_automaticRerouting_RouteUpdate() runs on f_EPTF_Base_stop(pass); } -function f_EPTF_Var_Test_adjustTest_checkExpectedWarning_preamble_FT(in charstring pl_message) runs on VariableTest_CT { - if (not match(pl_message,pattern "*Warning*")) { - return; - } - if (match(pl_message,pattern v_charstringVar)) { - v_boolVar := true; // verdict is only pass if this warning is logged - } -} - -function f_EPTF_Var_Test_adjustTest_checkWarning_cleanup() runs on VariableTest_CT { - if (v_boolVar == false) { - setverdict(fail, "Expected warning was not logged: ", v_charstringVar) - } else { - setverdict(pass) - } -} - - testcase tc_EPTF_Var_SubscribeTest_pull_with_adjustRemoteContent_negative() runs on VariableTest_CT{ f_EPTF_Var_init_CT("SubscribeTest_pull_with_adjustRemoteContent_negative"); f_EPTF_Var_setMaxWaitTime(0.2) - var charstring vl_expected_warning := "*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"; - v_charstringVar := vl_expected_warning; - f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_adjustTest_checkExpectedWarning_preamble_FT)); - f_EPTF_Base_registerCleanup(refers(f_EPTF_Var_Test_adjustTest_checkWarning_cleanup)); - v_boolVar := false; + f_EPTF_Logging_setExpectedWarningMsg("*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"); timer t_wait := 0.2; @@ -4388,11 +4366,7 @@ testcase tc_EPTF_Var_SubscribeTest_pull_with_adjustRemoteContent_negative() runs testcase tc_EPTF_Var_SubscribeTest_pull_noAlt_with_adjustRemoteContent_negative() runs on VariableTest_CT{ f_EPTF_Var_init_CT("SubscribeTest_pull_noAlt_with_adjustRemoteContent_negative"); f_EPTF_Var_setMaxWaitTime(0.2) - var charstring vl_expected_warning := "*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"; - v_charstringVar := vl_expected_warning; - f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_adjustTest_checkExpectedWarning_preamble_FT)); - f_EPTF_Base_registerCleanup(refers(f_EPTF_Var_Test_adjustTest_checkWarning_cleanup)); - v_boolVar := false; + f_EPTF_Logging_setExpectedWarningMsg("*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"); timer t_wait := 0.2; @@ -4425,11 +4399,7 @@ testcase tc_EPTF_Var_SubscribeTest_pull_noAlt_with_adjustRemoteContent_negative( testcase tc_EPTF_Var_SubscribeTest_pull_with_adjustContent_negative() runs on VariableTest_CT{ f_EPTF_Var_init_CT("SubscribeTest_pull_with_adjustContent_negative"); f_EPTF_Var_setMaxWaitTime(0.2) - var charstring vl_expected_warning := "*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"; - v_charstringVar := vl_expected_warning; - f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_adjustTest_checkExpectedWarning_preamble_FT)); - f_EPTF_Base_registerCleanup(refers(f_EPTF_Var_Test_adjustTest_checkWarning_cleanup)); - v_boolVar := false; + f_EPTF_Logging_setExpectedWarningMsg("*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"); timer t_wait := 0.2; @@ -4462,11 +4432,7 @@ testcase tc_EPTF_Var_SubscribeTest_pull_with_adjustContent_negative() runs on Va testcase tc_EPTF_Var_SubscribeTest_pull_noAlt_with_adjustContent_negative() runs on VariableTest_CT{ f_EPTF_Var_init_CT("SubscribeTest_pull_noAlt_with_adjustContent_negative"); f_EPTF_Var_setMaxWaitTime(0.2) - var charstring vl_expected_warning := "*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"; - v_charstringVar := vl_expected_warning; - f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_adjustTest_checkExpectedWarning_preamble_FT)); - f_EPTF_Base_registerCleanup(refers(f_EPTF_Var_Test_adjustTest_checkWarning_cleanup)); - v_boolVar := false; + f_EPTF_Logging_setExpectedWarningMsg("*Cannot convert direct content { floatVal := 1.000000 } to direct content { direct := { intVal := 0 } }. Types are incompatible*"); timer t_wait := 0.2;