| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_Variable_Test_Testcases |
| // |
| // Purpose: |
| // This module contains the testcases of generic EPTF Variable. |
| // |
| // Module depends on: |
| // <EPTF_Variable_Test_Definitions> |
| // <EPTF_Variable_Test_Functions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // |
| // |
| // Current Owner: |
| // EFLOATT |
| // |
| // Last Review Date: |
| // 2010-xx-xx |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_Variable_Test_Testcases { |
| //========================================================================= |
| // Import part |
| //========================================================================= |
| import from EPTF_Variable_Test_Definitions all; |
| import from EPTF_Variable_Test_Functions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Logging_Functions all; |
| //========================================================================= |
| // Testcases |
| //========================================================================= |
| |
| // check if the various EPTF Var types are working perfectly |
| testcase tc_EPTF_Var_CreateAndModifyTest() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_CreateAndModifyTest("test1",{})); |
| |
| vlc_VarTest1_CT.done; |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create("PTC1"); |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create("PTC2"); |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_SubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_SubscribeTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTestPull() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create("PTC1"); |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create("PTC2"); |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_SubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_SubscribeTest_SubscriberComponent("test2",{vlc_VarTest1_CT},pull)); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_AdjustTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_AdjustTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_AdjustTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_AdjustTestPull() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_AdjustTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_AdjustTest_SubscriberComponent("test2",{vlc_VarTest1_CT},pull)); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_UnsubscribeTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_UnsubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_UnsubscribeTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_GuardfunctionTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_GuardfunctionTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_GuardfunctionTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| |
| testcase tc_EPTF_Var_CalculationfunctionTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_CalculationfunctionTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_CalculationfunctionTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_PostprocfunctionTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_PostprocfunctionTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_PostprocfunctionTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| |
| testcase tc_EPTF_Var_BufferedTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_BufferedVariableTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_BufferedVariableTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_LongBufferedTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_LongBufferedVariableTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_LongBufferedVariableTest_SubscriberComponent("test2",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexSubscribeTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexSubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexSubscribeTest_SubscriberComponent1("test2",{vlc_VarTest1_CT,vlc_VarTest3_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexSubscribeTest_SubscriberComponent2("test3",{vlc_VarTest2_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexAdjustTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexAdjustTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexAdjustTest_SubscriberComponent1("test2",{vlc_VarTest1_CT,vlc_VarTest3_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexAdjustTest_SubscriberComponent2("test3",{vlc_VarTest2_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexBufferedTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexBufferedVariableTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexBufferedVariableTest_SubscriberComponent1("test2",{vlc_VarTest1_CT,vlc_VarTest3_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexBufferedVariableTest_SubscriberComponent2("test3",{vlc_VarTest2_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexDoubleBufferedTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexDoubleBufferedVariableTest_ProviderComponent("test1",{vlc_VarTest2_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexDoubleBufferedVariableTest_SubscriberComponent1("test2",{vlc_VarTest1_CT,vlc_VarTest3_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexDoubleBufferedVariableTest_SubscriberComponent2("test3",{vlc_VarTest2_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest2_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| |
| testcase tc_EPTF_Var_ComplexParalelAdjustTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexParalelAdjustTest_ProviderComponent("test1",{vlc_VarTest2_CT,vlc_VarTest3_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexParalelAdjustTest_SubscriberComponent1("test2",{vlc_VarTest1_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexParalelAdjustTest_SubscriberComponent2("test3",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexParalelSubscribeTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexParalelSubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT,vlc_VarTest3_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexParalelSubscribeTest_SubscriberComponent1("test2",{vlc_VarTest1_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexParalelSubscribeTest_SubscriberComponent2("test3",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexParalelUnsubscribeTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexParalelUnsubscribeTest_ProviderComponent("test1",{vlc_VarTest2_CT,vlc_VarTest3_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexParalelUnsubscribeTest_SubscriberComponent1("test2",{vlc_VarTest1_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexParalelUnsubscribeTest_SubscriberComponent2("test3",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_ComplexParalelBufferedTest() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| var VariableTest_CT vlc_VarTest1_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest2_CT := VariableTest_CT.create; |
| var VariableTest_CT vlc_VarTest3_CT := VariableTest_CT.create; |
| |
| connect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| connect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| vlc_VarTest1_CT.start(f_EPTF_Var_complexParalelBufferedTest_ProviderComponent("test1",{vlc_VarTest2_CT,vlc_VarTest3_CT})); |
| vlc_VarTest2_CT.start(f_EPTF_Var_complexParalelBufferedTest_SubscriberComponent1("test2",{vlc_VarTest1_CT})); |
| vlc_VarTest3_CT.start(f_EPTF_Var_complexParalelBufferedTest_SubscriberComponent2("test3",{vlc_VarTest1_CT})); |
| |
| vlc_VarTest1_CT.done; |
| vlc_VarTest2_CT.done; |
| vlc_VarTest3_CT.done; |
| |
| disconnect(vlc_VarTest1_CT:statusPort1,vlc_VarTest2_CT:statusPort1); |
| disconnect(vlc_VarTest1_CT:statusPort2,vlc_VarTest3_CT:statusPort1); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SimpleHashMapTest() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("MTC"); |
| f_EPTF_Var_CT_LogAll("----- START -------"); |
| f_EPTF_Var_init_CT("SimpleHashMapTest"); |
| f_EPTF_Var_CT_LogAll("----- INIT -------"); |
| |
| f_EPTF_Var_SimpleHashMap(); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Var_Test_createVarFromCfg |
| // |
| // Purpose: |
| // to test f_EPTF_Var_createVarFromCfg() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Var_init_CT() function with tsp_EPTF_Test_selfname |
| // - creates a <EPTF_Var_DirectContent> array using tsp_EPTF_Var_cfg, (name not contains tsp_EPTF_Test_selfname) |
| // - calls several times the f_EPTF_Var_createVarFromCfg() function with the created array |
| // - calls the f_EPTF_Var_getContent() function to get the content of the created EPTF Variable |
| // - matches the content with the expected one |
| // - matches the initiated RBtree with the expected one |
| // - creates a <EPTF_Var_DirectContent> array using tsp_EPTF_Var_cfg, (name contains tsp_EPTF_Test_selfname) |
| // - calls several times the f_EPTF_Var_createVarFromCfg() function with the created array and 3rd parameter set to false |
| // - calls the f_EPTF_Var_getContent() function to get the content of the created EPTF Variable |
| // - matches the content with the expected one |
| // |
| // Expected Result: |
| // created EPTF variable as same as the expected one |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Var_Test_createVarFromCfg() runs on VariableTest_CT { |
| |
| var integer vl_success := -1; |
| var EPTF_Var_InitialValueList vl_init; |
| var EPTF_Var_DirectContent vl_content; |
| |
| f_EPTF_Var_init_CT(tsp_EPTF_Test_selfname); |
| |
| for (var integer i := 0; i < sizeof(tsp_EPTF_Var_cfg); i := i + 1) { |
| vl_init[i] := tsp_EPTF_Var_cfg[i]; |
| vl_init[i].name := substr(tsp_EPTF_Var_cfg[i].name, lengthof(tsp_EPTF_Test_selfname) + 1, lengthof(tsp_EPTF_Var_cfg[i].name) - lengthof(tsp_EPTF_Test_selfname) - 1); |
| vl_init[i].initValue := tsp_EPTF_Var_cfg[i].initValue; |
| |
| vl_success := f_EPTF_Var_createVarFromCfg(vl_init[i].name); |
| if (vl_success != -1) { |
| f_EPTF_Var_getContent(vl_success, vl_content); |
| if(vl_content == vl_init[i].initValue) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong variable created: ", f_EPTF_Var_getName(vl_success), "expected: ", vl_init[i]); |
| setverdict(fail); |
| } |
| } else { |
| |
| log("Error: variable not created: ", vl_init[i].name); |
| setverdict(fail); |
| } |
| } |
| vl_init := tsp_EPTF_Var_cfg; |
| for (var integer i := 0; i < sizeof(tsp_EPTF_Var_cfg); i := i + 1) { |
| |
| vl_success := f_EPTF_Var_createVarFromCfg(vl_init[i].name, tsp_EPTF_Var_cfg, false); |
| if (vl_success != -1) { |
| f_EPTF_Var_getContent(vl_success, vl_content); |
| if(vl_content == vl_init[i].initValue) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong variable created: ", f_EPTF_Var_getName(vl_success), "expected: ", vl_init[i]); |
| setverdict(fail); |
| } |
| } else { |
| |
| log("Error: variable not created: ", vl_init[i].name); |
| setverdict(fail); |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Var_Test_loadVarFromCfg |
| // |
| // Purpose: |
| // to test f_EPTF_Var_loadVarFromCfg() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Var_init_CT() function with tsp_EPTF_Test_selfname |
| // - creates a <EPTF_Var_DirectContent> array using tsp_EPTF_Var_cfg, (name not contains tsp_EPTF_Test_selfname) |
| // - calls several times the f_EPTF_Var_createVarFromCfg() function with the created array |
| // - calls several times the f_EPTF_Var_loadVarFromCfg() function with the created array |
| // - calls the f_EPTF_Var_getContent() function to get the content of the loaded EPTF Variable |
| // - matches the content with the expected one |
| // - matches the initiated RBtree with the expected one |
| // - creates a <EPTF_Var_DirectContent> array using tsp_EPTF_Var_cfg, (name contains tsp_EPTF_Test_selfname) |
| // - calls several times the f_EPTF_Var_createVarFromCfg() function with the created array and 3rd parameter set to false |
| // - calls several times the f_EPTF_Var_loadVarFromCfg() function with the created array and 3rd parameter set to false |
| // - calls the f_EPTF_Var_getContent() function to get the content of the loaded EPTF Variable |
| // - matches the content with the expected one |
| // |
| // Expected Result: |
| // loaded EPTF variable as same as the expected one |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Var_Test_loadVarFromCfg() runs on VariableTest_CT { |
| |
| var integer vl_success := -1; |
| var EPTF_Var_InitialValueList vl_init; |
| var EPTF_Var_DirectContent vl_content; |
| |
| f_EPTF_Var_init_CT(tsp_EPTF_Test_selfname); |
| |
| for (var integer i := 0; i < sizeof(tsp_EPTF_Var_cfg); i := i + 1) { |
| vl_init[i] := tsp_EPTF_Var_cfg[i]; |
| vl_init[i].name := substr(tsp_EPTF_Var_cfg[i].name, lengthof(tsp_EPTF_Test_selfname) + 1, lengthof(tsp_EPTF_Var_cfg[i].name) - lengthof(tsp_EPTF_Test_selfname) - 1); |
| vl_init[i].initValue := tsp_EPTF_Var_cfg[i].initValue; |
| |
| vl_success := f_EPTF_Var_createVarFromCfg(vl_init[i].name); |
| vl_success := f_EPTF_Var_loadVarFromCfg(vl_init[i].name); |
| if (vl_success != -1) { |
| f_EPTF_Var_getContent(vl_success, vl_content); |
| if(vl_content == vl_init[i].initValue) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong variable loaded: ", f_EPTF_Var_getName(vl_success), "expected: ", vl_init[i]); |
| setverdict(fail); |
| } |
| } else { |
| |
| log("Error: variable not loaded: ", vl_init[i].name); |
| setverdict(fail); |
| } |
| } |
| vl_init := tsp_EPTF_Var_cfg; |
| for (var integer i := 0; i < sizeof(tsp_EPTF_Var_cfg); i := i + 1) { |
| |
| vl_success := f_EPTF_Var_createVarFromCfg(vl_init[i].name, tsp_EPTF_Var_cfg, false); |
| vl_success := f_EPTF_Var_loadVarFromCfg(vl_init[i].name, tsp_EPTF_Var_cfg, false); |
| if (vl_success != -1) { |
| f_EPTF_Var_getContent(vl_success, vl_content); |
| if(vl_content == vl_init[i].initValue) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong variable loaded: ", f_EPTF_Var_getName(vl_success), "expected: ", vl_init[i]); |
| setverdict(fail); |
| } |
| } else { |
| |
| log("Error: variable not loaded: ", vl_init[i].name); |
| setverdict(fail); |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Var_getRemote(_local) |
| // |
| // Purpose: |
| // to test parallel call of the f_EPTF_Var_getRemoteContent() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Var_init_CT() function with tsp_EPTF_Test_selfname |
| // - creates three EPTF variables |
| // - activates an altstep that calls f_EPTF_Var_getRemoteContent in parallel for each variables |
| // - the altstep checks if the f_EPTF_Var_getRemoteContent is called parallel indeed |
| // - the altstep checks if the content retuned by f_EPTF_Var_getRemoteContent is the correct value |
| // - the testcase checks if the f_EPTF_Var_getRemoteContent is called for all three variables |
| // |
| // Expected Result: |
| // the testcase should pass, the content retuned by f_EPTF_Var_getRemoteContent is the correct value |
| // The tc_EPTF_Var_getRemote_local will not block execution => no parallel getRemote is running |
| /////////////////////////////////////////////////////////// |
| type component Var_GetRemote_CT extends EPTF_Var_CT { |
| timer t_getRemote := 0.0; |
| var integer v_getRemoteCounter := 0; |
| var Var_GetRemote_CT v_remoteComp; |
| } |
| |
| altstep as_EPTF_Var_getRemote() runs on Var_GetRemote_CT { |
| [] t_getRemote.timeout { |
| if(v_getRemoteCounter==3) { |
| repeat; // runs only three times |
| } |
| t_getRemote.start; |
| var EPTF_Var_DirectContent vl_remoteValue; |
| v_getRemoteCounter := v_getRemoteCounter + 1; |
| var charstring vl_varName := "intVar"&int2str(v_getRemoteCounter); |
| f_EPTF_Var_getRemoteContent(v_remoteComp,vl_varName, vl_remoteValue); |
| // if v_remoteComp == self => f_EPTF_Var_getRemoteContent will not block |
| if (v_remoteComp != self) { |
| f_setverdictFail(v_getRemoteCounter==1); // the altstep should be activated inside f_EPTF_Var_getRemoteContent also |
| } |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(f_EPTF_Var_getId(vl_varName),vl_currentContent); |
| log("remote/current content of intVar is: ", vl_remoteValue,"/",vl_currentContent); |
| f_setverdictFail(vl_remoteValue!=vl_currentContent); // the two contents should be the same |
| repeat; |
| } |
| } |
| |
| testcase tc_EPTF_Var_getRemote_local() runs on Var_GetRemote_CT { |
| f_EPTF_Var_init_CT("getRemote_local"); |
| |
| v_remoteComp := self; |
| var integer vl_idx; |
| f_EPTF_Var_newInt("intVar1",1,vl_idx); |
| f_EPTF_Var_newInt("intVar2",2,vl_idx); |
| f_EPTF_Var_newInt("intVar3",3,vl_idx); |
| |
| t_getRemote.start; |
| var default vl_def := activate(as_EPTF_Var_getRemote()); |
| |
| timer t_wait := 2.0; |
| t_wait.start; t_wait.timeout; |
| f_setverdictFail(v_getRemoteCounter!=3); // the test should be executed for all three variables |
| f_EPTF_Base_stop(pass); |
| } |
| |
| function f_EPTF_Var_getRemote_behaviour() runs on Var_GetRemote_CT { |
| |
| f_EPTF_Var_init_CT("getRemote_behaviour"); |
| |
| var integer vl_idx; |
| f_EPTF_Var_newInt("intVar1",1,vl_idx); |
| f_EPTF_Var_newInt("intVar2",2,vl_idx); |
| f_EPTF_Var_newInt("intVar3",3,vl_idx); |
| |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| testcase tc_EPTF_Var_getRemote() runs on Var_GetRemote_CT { |
| f_EPTF_Var_init_CT("getRemote"); |
| |
| v_remoteComp := Var_GetRemote_CT.create; |
| v_remoteComp.start(f_EPTF_Var_getRemote_behaviour()); |
| |
| var integer vl_idx; |
| f_EPTF_Var_newInt("intVar1",1,vl_idx); |
| f_EPTF_Var_newInt("intVar2",2,vl_idx); |
| f_EPTF_Var_newInt("intVar3",3,vl_idx); |
| |
| t_getRemote.start; |
| var default vl_def := activate(as_EPTF_Var_getRemote()); |
| |
| timer t_wait := 2.0; |
| t_wait.start; t_wait.timeout; |
| f_setverdictFail(v_getRemoteCounter!=3); // the test should be executed for all three variables |
| f_EPTF_Base_stop(pass); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Var_adjustRemote_blocking |
| // |
| // Purpose: |
| // to test parallel call of the f_EPTF_Var_adjustRemoteContent_Blocking() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Var_init_CT() function with tsp_EPTF_Test_selfname |
| // - creates three EPTF variables |
| // - activates an altstep that calls f_EPTF_Var_adjustRemoteContent_Blocking in parallel for each variables |
| // - the altstep checks if the f_EPTF_Var_adjustRemoteContent_Blocking is called parallel indeed |
| // - the altstep checks if the content retuned by f_EPTF_Var_adjustRemoteContent_Blocking is the correct value |
| // - the testcase checks if the f_EPTF_Var_adjustRemoteContent_Blocking is called for all three variables |
| // - the testcase checks if the f_EPTF_Var_adjustRemoteContent_Blocking retuns false if the remote variable does not exsit |
| // - the testcase checks if the f_EPTF_Var_adjustRemoteContent_Blocking retuns false if the remote variable has a local provider |
| // |
| // Expected Result: |
| // the testcase should pass, the content retuned by f_EPTF_Var_adjustRemoteContent_Blocking is the correct value |
| /////////////////////////////////////////////////////////// |
| type component Var_AdjustRemote_CT extends EPTF_Var_CT { |
| timer t_getRemote := 0.0; |
| var integer v_getRemoteCounter := 0; |
| timer t_exit := 3.0; |
| } |
| |
| altstep as_EPTF_Var_adjustRemote_Blocking() runs on Var_AdjustRemote_CT { |
| [] t_getRemote.timeout { |
| if(v_getRemoteCounter==3) { |
| repeat; // runs only three times |
| } |
| t_getRemote.start; |
| v_getRemoteCounter := v_getRemoteCounter + 1; |
| var EPTF_Var_DirectContent vl_remoteValue := {intVal:=v_getRemoteCounter+1}; |
| var charstring vl_varName := "intVar"&int2str(v_getRemoteCounter); |
| f_setverdictFail(not f_EPTF_Var_adjustRemoteContent_Blocking(self,vl_varName, vl_remoteValue)); // should return true |
| f_setverdictFail(v_getRemoteCounter==1); // the altstep should be activated inside f_EPTF_Var_getRemoteContent also |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(f_EPTF_Var_getId(vl_varName),vl_currentContent); |
| log("remote/current content of intVar is: ", vl_remoteValue,"/",vl_currentContent); |
| f_setverdictFail(vl_remoteValue!=vl_currentContent); // the two contents should be the same |
| repeat; |
| } |
| [] t_exit.timeout { |
| log("Deadlock is detected. Exiting..."); |
| f_EPTF_Base_stopAll(fail); |
| } |
| } |
| |
| testcase tc_EPTF_Var_adjustRemote_blocking() runs on Var_AdjustRemote_CT { |
| f_EPTF_Var_init_CT("getRemote"); |
| |
| var integer vl_idx; |
| f_EPTF_Var_newInt("intVar1",1,vl_idx); |
| f_EPTF_Var_newInt("intVar2",2,vl_idx); |
| f_EPTF_Var_newInt("intVar3",3,vl_idx); |
| |
| t_getRemote.start; |
| t_exit.start; |
| var default vl_def := activate(as_EPTF_Var_adjustRemote_Blocking()); |
| |
| // below are two false tests (they should generate warnings also) |
| // adjusting a nonexistent variable: |
| var EPTF_Var_DirectContent vl_remoteValue := {intVal:=10}; |
| f_setverdictFail(f_EPTF_Var_adjustRemoteContent_Blocking(self,"intVar", vl_remoteValue)); // should return false |
| |
| // adjusting a existing variable with calcfn: |
| f_EPTF_Var_subscribeLocal(vl_idx,{calcFn := {null,{},{}}}); |
| f_setverdictFail(f_EPTF_Var_adjustRemoteContent_Blocking(self,"intVar3", vl_remoteValue)); // should return false |
| |
| timer t_wait := 2.0; |
| t_wait.start; t_wait.timeout; |
| f_setverdictFail(v_getRemoteCounter!=3); // the test should be executed for all three variables |
| f_EPTF_Base_stop(pass); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Var_Test_directContent_EmptyOctetString |
| // |
| // Purpose: |
| // to test if there is a problem in the f_EPTF_Var_direct2content function |
| // when a variable has an empty octetstring |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // A new variable with the type octetstring is created and then an empty |
| // octetstring type DirectContent will be adjusted to it. |
| // |
| // Expected Result: |
| // the testcase should pass or if the error exists then it will cause |
| // assertion failed error |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Var_Test_directContent_EmptyOctetString() |
| runs on EPTF_Var_CT |
| { |
| f_EPTF_Var_init_CT("pl_selfName") |
| var EPTF_Var_DirectContent vl_content; |
| vl_content.octetstringVal := ''O; |
| var integer vl_varIdOfMsg := -1; |
| f_EPTF_Var_newOctetstring("pl_name", '12'O, vl_varIdOfMsg) |
| |
| //there sould be a problem in this function |
| f_EPTF_Var_adjustContent(vl_varIdOfMsg, vl_content); |
| |
| timer t_wait; |
| t_wait.start( 15.0 ); |
| t_wait.timeout; |
| |
| setverdict ( pass ); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Variable_Test_directContent_unknownVal |
| // |
| // Purpose: |
| // to test if the newly introduced unknown value in directcontent |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - |
| // |
| // Expected Result: |
| // - |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Var_Test_directContent_unknownVal() |
| runs on EPTF_Var_CT |
| { |
| f_EPTF_Var_init_CT("Variable Component") |
| var EPTF_Var_DirectContent vl_content; |
| |
| vl_content.unknownVal := {intType}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| vl_content.unknownVal := {dataType := floatType}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| vl_content := {unknownVal := {boolType}}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| vl_content := {unknownVal := {dataType := charstringType}}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| vl_content.unknownVal := {omit}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| vl_content.unknownVal := {dataType := omit}; |
| log("\n vl_content: ", vl_content, "\n"); |
| |
| setverdict ( pass ); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkPeriodLength() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_init_CT("subscribeWithCustomPeriod_checkPeriodLength"); |
| |
| var default vl_def := activate(as_EPTF_Var_Test_subscribeWithCustomPeriod_updateVars()); |
| |
| f_EPTF_Var_newInt("intVar1",1,vl_intVarIdx); |
| |
| // set default sync period to 3.0 sec |
| f_EPTF_Var_setSyncInterval(3.0); |
| // set elementary period to 1.0 sec |
| f_EPTF_Var_setMinSyncInterval(1.0); |
| |
| f_EPTF_Var_subscribeRemote(self,"intVar1",sampled, v_remoteIntSubscrIdx,-,-); |
| |
| f_EPTF_Var_subscribeRemote(self,"intVar1",sampled, v_intVarRefreshA_10Idx,"intVarRefreshA_10",10); |
| f_EPTF_Var_subscribeRemote(self,"intVar1",sampled, v_intVarRefreshB_10Idx,"intVarRefreshB_10",10); |
| |
| f_EPTF_Var_subscribeRemote(self,"intVar1",sampled, v_intVarRefresh_20Idx,"intVarRefresh_20",20); |
| |
| timer t_wait; |
| |
| t_wait.start(5.0); t_wait.timeout; |
| |
| // add postproc to subscribers |
| f_EPTF_Var_addPostProcFn(v_remoteIntSubscrIdx, {refers(f_EPTF_Var_Test_remoteIntSubscr_PostProc), {}}); |
| f_EPTF_Var_addPostProcFn(v_intVarRefreshA_10Idx, {refers(f_EPTF_Var_Test_intVarRefreshA_10_PostProc), {}}); |
| f_EPTF_Var_addPostProcFn(v_intVarRefreshB_10Idx, {refers(f_EPTF_Var_Test_intVarRefreshB_10_PostProc), {}}); |
| f_EPTF_Var_addPostProcFn(v_intVarRefresh_20Idx, {refers(f_EPTF_Var_Test_intVarRefresh_20_PostProc), {}}); |
| |
| t_updateVars.start; |
| //We can't expect high precision since there are network communication elements |
| const float c_EPTF_Var_requiredPrecision := 0.5; |
| |
| // start an alt for 35 secs. |
| t_wait.start(35.2); t_wait.timeout; |
| |
| // check if the variables were updated correct number of times |
| if (f_getDifference(v_remoteIntSubscr_Period,3.0)>c_EPTF_Var_requiredPrecision) { |
| setverdict(fail, "Incorrect sync period: ",v_remoteIntSubscr_Period," instead of 3.0"); |
| } else |
| if (f_getDifference(v_intVarRefreshA_10_Period,1.0*10.0)>c_EPTF_Var_requiredPrecision) { |
| setverdict(fail, "Incorrect sync period for intVarRefreshA_10: ",v_intVarRefreshA_10_Period, |
| " instead of 10.0"); |
| } else |
| if (f_getDifference(v_intVarRefreshB_10_Period,1.0*10.0)>c_EPTF_Var_requiredPrecision) { |
| setverdict(fail, "Incorrect sync period for intVarRefreshB_10: ",v_intVarRefreshB_10_Period, |
| " instead of 10.0"); |
| } else |
| if (f_getDifference(v_intVarRefresh_20_Period,1.0*20.0)>c_EPTF_Var_requiredPrecision) { |
| setverdict(fail, "Incorrect sync period for intVarRefresh_20: ",v_intVarRefresh_20_Period, |
| " instead of 20.0"); |
| } else { |
| setverdict(pass); |
| } |
| |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| |
| |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(sampled, false); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_timelined() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(timeLine, false); |
| } |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_sampledAtSync() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(sampledAtSync, false); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_realtime() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(realtime, false); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_chained() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(sampled, true); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_sampledAtSync_chained() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(sampledAtSync, true); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_realtime_chained() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(realtime, true); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_timelined_chained() runs on Var_Test_SubscribeWithCustomPeriod_CT { |
| f_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange(timeLine, true); |
| } |
| |
| |
| private function f_EPTF_Var_UIVars_resetvariable( |
| in integer pl_idx, |
| in EPTF_IntegerList pl_argList) |
| runs on EPTF_Var_CT |
| { |
| var integer vl_start := f_EPTF_Var_getIntValue(pl_idx); |
| |
| action("f_EPTF_Var_UIVars_resetvariable [", pl_idx,":",vl_start, "]" , f_EPTF_Var_getName(pl_idx)); |
| if (vl_start!=0) |
| { |
| action("Reseting [", pl_idx, "]"); |
| f_EPTF_Var_setContent(pl_idx, {intVal := 0}); |
| } |
| } |
| |
| |
| testcase tc_EPTF_Var_Test_adjustSubscribedVarsInPostproc() runs on EPTF_Var_CT { |
| f_EPTF_Var_init_CT("adjustSubscribedVarsInPostproc"); |
| |
| var integer i,j,k; |
| f_EPTF_Var_newInt("i",-1,i); |
| f_EPTF_Var_addPostProcFn(i, { refers(f_EPTF_Var_UIVars_resetvariable), {}} ); |
| f_EPTF_Var_subscribeRemote(self,"i",realtime,j,"j"); |
| f_EPTF_Var_subscribeRemote(self,"j",realtime,k,"k"); |
| |
| f_EPTF_Var_adjustContent(i,{intVal:=1}); |
| timer t_wait := 11.0; |
| t_wait.start; t_wait.timeout; |
| action("tc_EPTF_Var_Test_adjustSubscribedVarsInPostproc - i:", f_EPTF_Var_getIntValue(i)," - j:", f_EPTF_Var_getIntValue(j)," - k:", f_EPTF_Var_getIntValue(k)); |
| |
| if (f_EPTF_Var_getIntValue(k)==0) { |
| setverdict(pass); |
| } else { |
| setverdict(fail); |
| } |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| //Negative tests testing tha case when the subscribe times out |
| group subscribeTimeout{ |
| const charstring c_varname := "var2Subscribe" |
| const charstring c_refVarname := "refVar2Subscribe" |
| function f_EPTF_Var_Test_subscribeServerBehavior() runs on EPTF_Var_CT { |
| f_EPTF_Var_init_CT("subscribeServerBlocking"); |
| var integer vl_varId; |
| f_EPTF_Var_newInt(c_varname, 1, vl_varId) |
| timer t_preparation := 1.0; |
| t_preparation.start; |
| t_preparation.timeout; |
| timer t1 |
| t1.start( 9.0 ) |
| while(t1.read < 2.0){} |
| f_EPTF_Base_wait4Shutdown() |
| } |
| function f_EPTF_Var_Test_checkServer(in EPTF_Var_CT pl_server)runs on EPTF_Var_CT{ |
| // just make an initial connection: |
| timer t_preparation := 2.0; |
| t_preparation.start; |
| var EPTF_Var_DirectContent vl_content; |
| f_EPTF_Var_getRemoteContent(pl_server,c_varname,vl_content); |
| if (vl_content != {intVal:=1}) { |
| setverdict(fail,"remote variable does not exist"); |
| f_EPTF_Base_stop(none); |
| } |
| t_preparation.timeout; // here server will not send answers |
| } |
| testcase tc_EPTF_Var_Test_subscribeTimeout() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| f_EPTF_Var_setMaxWaitTime(0.2) |
| f_EPTF_Base_setNegativeTestMode(); |
| f_EPTF_Base_setExpectedErrorMsg("*No response received for subscribe with data: *\"var2Subscribe\"realtime*"); |
| var EPTF_Var_CT vl_server := EPTF_Var_CT.create; |
| vl_server.start( f_EPTF_Var_Test_subscribeServerBehavior() ); |
| |
| // just make an initial connection: |
| f_EPTF_Var_Test_checkServer(vl_server); |
| |
| var integer vl_varId; |
| f_EPTF_Var_subscribeRemote(vl_server, c_varname, realtime, vl_varId) |
| timer t1; |
| t1.start( 1.0 ) |
| t1.timeout |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| // f_EPTF_Var_resubscribeRemote no longer blocks execution |
| testcase tc_EPTF_Var_Test_resubscribeTimeout() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| f_EPTF_Var_setMaxWaitTime(0.2) |
| //f_EPTF_Base_setNegativeTestMode(); |
| //f_EPTF_Base_setExpectedErrorMsg("*No response received for subscribe with data: *\"var2Subscribe\"realtime*"); |
| var EPTF_Var_CT vl_server := EPTF_Var_CT.create; |
| vl_server.start( f_EPTF_Var_Test_subscribeServerBehavior() ); |
| |
| // just make an initial connection: |
| f_EPTF_Var_Test_checkServer(vl_server); |
| |
| var integer vl_varId; |
| f_EPTF_Var_newInt("bubu", 11, vl_varId) |
| timer t1; |
| t1.start( 1.0 ) |
| f_EPTF_Var_resubscribeRemote(vl_server, c_varname, realtime, vl_varId) |
| if (t1.read < 0.2) { |
| setverdict(pass, "resubscribe did not block execution") |
| } else { |
| setverdict(fail, "resubscribe should not block execution. Execution time was longer than 0.2 sec.") |
| } |
| t1.timeout |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeRefTimeout() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| f_EPTF_Var_setMaxWaitTime(0.2) |
| f_EPTF_Base_setNegativeTestMode(); |
| f_EPTF_Base_setExpectedErrorMsg("*No response received for subscribe with data: *\"var2Subscribe\"realtime*"); |
| var EPTF_Var_CT vl_server := EPTF_Var_CT.create; |
| vl_server.start( f_EPTF_Var_Test_subscribeServerBehavior() ); |
| |
| // just make an initial connection: |
| f_EPTF_Var_Test_checkServer(vl_server); |
| |
| var integer vl_varId; |
| var EPTF_Var_ReferencedContent vl_local2subs := {intType, ''O}; |
| f_EPTF_Var_subscribeRemoteRef(vl_local2subs, vl_server, c_varname, realtime, vl_varId) |
| timer t1; |
| t1.start( 1.0 ) |
| t1.timeout |
| f_EPTF_Base_cleanup_CT() |
| } |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeRemote_negative() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("MTC"); |
| f_EPTF_Var_setMaxWaitTime(0.2) |
| f_EPTF_Base_setNegativeTestMode(); |
| f_EPTF_Base_setExpectedErrorMsg("*Variable *non-existent var* on component mtc does not exist. Subscribe failed by the subscriber*"); |
| |
| // subscribe to nonexistent var in pull mode: |
| var integer vl_subscriber_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "non-existent var", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber_idx, |
| pl_localName := "subscriber of non-existent var" |
| ); |
| timer t1; |
| t1.start( 1.0 ) |
| t1.timeout |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| // to test f_EPTF_Var_subscribeRemote_nonBlocking during connect & subscribe as well (artf542055) |
| testcase tc_EPTF_Var_Test_subscribeRemote_nonBlocking() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("Test_subscribeRemote_nonBlocking"); |
| f_EPTF_Var_setMaxWaitTime(0.2); |
| var VariableTest_CT vl_server := VariableTest_CT.create; |
| vl_server.start( f_EPTF_Var_Test_subscribeServerBehavior() ); |
| |
| var EPTF_Var_resubscribeRemoteResp_handler vl_subscribeCallback := { |
| handlerFn := refers(f_EPTF_Var_Test_subscribeRemote_nonBlocking_callBack), |
| argList := {} |
| } |
| |
| timer t1 := 1.0; |
| t1.start; |
| t1.timeout; |
| |
| var default vl_default := activate(as_EPTF_Var_Test_subscribeRemote_nonBlocking()); |
| t_subscribeRemote_nonblocking.start; |
| v_subscribeRemote_nonblockingHandlerCalled := 0; |
| |
| f_EPTF_Var_subscribeRemote_nonBlocking(vl_server, c_varname, realtime, "", -1, vl_subscribeCallback); |
| if(v_subscribeRemote_nonblockingHandlerCalled == 0){ |
| v_subscribeRemote_nonblockingHandlerCalled := 2; |
| } |
| |
| timer t2; |
| t2.start(1.0); |
| t2.timeout; |
| |
| deactivate(vl_default); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // callback function for tc_EPTF_Var_Test_subscribeRemote_nonBlocking |
| function f_EPTF_Var_Test_subscribeRemote_nonBlocking_callBack(in integer pl_idx, in boolean pl_result, in EPTF_IntegerList pl_argList) runs on VariableTest_CT { |
| |
| if(pl_result != true or pl_idx < 0){ |
| setverdict(fail,"Unsuccessful subscribe."); |
| f_EPTF_Base_stop(fail); |
| return; |
| } |
| |
| if(v_subscribeRemote_nonblockingHandlerCalled == 2){ |
| setverdict(pass,"Non-blocking mode works properly. Code is not blocked."); |
| f_EPTF_Base_stop(pass); |
| }else { |
| setverdict(fail,"Non-blocking mode does not work. Code is blocked."); |
| f_EPTF_Base_stop(fail); |
| } |
| } |
| |
| // default altstep for tc_EPTF_Var_Test_subscribeRemote_nonBlocking & tc_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel |
| altstep as_EPTF_Var_Test_subscribeRemote_nonBlocking() runs on VariableTest_CT { |
| |
| [] t_subscribeRemote_nonblocking.timeout{ |
| if(v_subscribeRemote_nonblockingHandlerCalled == 0){ |
| v_subscribeRemote_nonblockingHandlerCalled := 1; |
| } |
| repeat; |
| } |
| } |
| |
| // to test buffering in case of non blocking parallel subscribes(artf542055) |
| testcase tc_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("Test_subscribeRemote_nonBlocking_parallel"); |
| f_EPTF_Var_setMaxWaitTime(0.2); |
| var VariableTest_CT vl_server1 := VariableTest_CT.create; |
| var VariableTest_CT vl_server2 := VariableTest_CT.create; |
| vl_server1.start( f_EPTF_Var_Test_subscribeServerBehavior_nonBlocking() ); |
| vl_server2.start( f_EPTF_Var_Test_subscribeServerBehavior_nonBlocking() ); |
| |
| var EPTF_Var_resubscribeRemoteResp_handler vl_subscribeCallback := { |
| handlerFn := refers(f_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel_callBack), |
| argList := {} |
| } |
| |
| timer t1 := 1.0; |
| t1.start; |
| t1.timeout; |
| |
| var default vl_default := activate(as_EPTF_Var_Test_subscribeRemote_nonBlocking()); |
| t_subscribeRemote_nonblocking.start; |
| v_subscribeRemote_nonblockingHandlerCalled := 0; |
| |
| var charstring vl_localVarName := "localVar"; |
| |
| for(var integer i:=0; i<100; i:=i+1) { |
| f_EPTF_Var_subscribeRemote_nonBlocking(vl_server1, c_varname&int2str(i), realtime, vl_localVarName&"_server1_"&int2str(i), -1, vl_subscribeCallback); |
| } |
| for(var integer i:=0; i<100; i:=i+1) { |
| f_EPTF_Var_subscribeRemote_nonBlocking(vl_server2, c_varname&int2str(i), realtime, vl_localVarName&"_server2_"&int2str(i), -1, vl_subscribeCallback); |
| } |
| |
| if(v_subscribeRemote_nonblockingHandlerCalled == 0){ |
| v_subscribeRemote_nonblockingHandlerCalled := 2; |
| } |
| |
| timer t2 := 1.0; |
| t2.start; |
| t2.timeout; |
| |
| var integer vl_remoteValue := -1; |
| // check the values from server1 |
| for(var integer i:=0; i<100; i:=i+1) { |
| vl_remoteValue := f_EPTF_Var_getIntValue(i); |
| if(vl_remoteValue != i){ |
| setverdict(fail,"Value of local var: ",i," does not match with the remote value: ",vl_remoteValue); |
| f_EPTF_Base_stop(fail) |
| } |
| } |
| // check the values from server2 |
| for(var integer i:=100; i<200; i:=i+1) { |
| vl_remoteValue := f_EPTF_Var_getIntValue(i); |
| if(vl_remoteValue != i-100){ |
| setverdict(fail,"Value of local var: ",i," does not match with the remote value: ",vl_remoteValue); |
| f_EPTF_Base_stop(fail) |
| } |
| } |
| |
| deactivate(vl_default); |
| setverdict(pass,"All subscription to remote variable was OK. Non-blocking mode works properly in case of parallel subscribes."); |
| f_EPTF_Base_stop(pass); |
| } |
| |
| // server behavior function for tc_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel |
| function f_EPTF_Var_Test_subscribeServerBehavior_nonBlocking() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("subscribeServerBehavior_nonBlocking"); |
| var integer vl_remoteVarIndex := -1; |
| for(var integer i:=0; i<100; i:=i+1) { |
| f_EPTF_Var_newInt(c_varname&int2str(i), i, vl_remoteVarIndex); // vl_remoteVarIndex value does not matter |
| } |
| |
| timer t1; |
| t1.start( 9.0 ); |
| while(t1.read < 2.0){}; |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| // callback function for tc_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel |
| function f_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel_callBack(in integer pl_idx, in boolean pl_result, in EPTF_IntegerList pl_argList) runs on VariableTest_CT { |
| |
| if(pl_result != true or pl_idx < 0){ |
| setverdict(fail,"Unsuccessful subscribe."); |
| f_EPTF_Base_stop(fail); |
| return; |
| } |
| |
| if(v_subscribeRemote_nonblockingHandlerCalled == 2){ |
| // Non-blocking mode works properly. Code is not blocked. Continue the execution. |
| }else { |
| setverdict(fail,"Non-blocking mode does not work. Code is blocked."); |
| f_EPTF_Base_stop(fail); |
| } |
| } |
| |
| group SubsCanAdjust { |
| |
| function f_EPTF_Var_Test_subsCanAdjust_wait(in float pl_time) { |
| timer t_wait := pl_time; |
| t_wait.start; t_wait.timeout; |
| } |
| |
| testcase tc_EPTF_Var_Test_subsCanAdjust_flagTest() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| |
| var integer vl_mainVarIdx := -1; |
| f_EPTF_Var_newInt("mainVar",0,vl_mainVarIdx); |
| |
| var integer vl_subs1Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs1Idx, |
| pl_localName := "subs1" |
| ); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=true) { |
| setverdict(fail,"Initial value of subsCanAdjust flag is incorrect"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs1Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber after subscribe"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| var integer vl_subs2Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs2Idx, |
| pl_localName := "subs2" |
| ); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=false) { |
| setverdict(fail,"Updated value of subsCanAdjust flag is incorrect"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs1Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber after f_EPTF_Var_setSubsCanAdjustubscribe"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs2Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber after subscribe after f_EPTF_Var_setSubsCanAdjustubscribe"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| |
| var integer vl_subs21Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subs2", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs21Idx, |
| pl_localName := "subs21" |
| ); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs21Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber of the subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, true); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=true) { |
| setverdict(fail,"Changed value of subsCanAdjust flag is incorrect"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs1Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber after f_EPTF_Var_setSubsCanAdjustubscribe 2"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs2Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber after subscribe after f_EPTF_Var_setSubsCanAdjustubscribe"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getSubsCanAdjust(vl_mainVarIdx)!=f_EPTF_Var_getSubsCanAdjust(vl_subs21Idx)) { |
| setverdict(fail,"The subsCanAdjust flag is different in the subscriber of the subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| testcase tc_EPTF_Var_Test_subsCanAdjust_adjustMainTest() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| |
| var integer vl_mainVarIdx := -1; |
| f_EPTF_Var_newInt("mainVar",0,vl_mainVarIdx); |
| |
| var integer vl_subs1Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs1Idx, |
| pl_localName := "subs1" |
| ); |
| |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| f_EPTF_Var_adjustContent(vl_mainVarIdx,{intVal := 1}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=1) { |
| setverdict(fail,"Content of subscriber is not updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| var integer vl_subs2Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs2Idx, |
| pl_localName := "subs2" |
| ); |
| |
| f_EPTF_Var_adjustContent(vl_mainVarIdx,{intVal := 2}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_subs2Idx)!=2) { |
| setverdict(fail,"Content of subscriber is not updated after subscribed after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| var integer vl_subs21Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subs2", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs21Idx, |
| pl_localName := "subs21" |
| ); |
| |
| f_EPTF_Var_adjustContent(vl_mainVarIdx,{intVal := 3}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_subs21Idx)!=3) { |
| setverdict(fail,"Content of subscriber of subscriber is not updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| testcase tc_EPTF_Var_Test_subsCanAdjust_adjustSubsTest() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| |
| var integer vl_mainVarIdx := -1; |
| f_EPTF_Var_newInt("mainVar",0,vl_mainVarIdx); |
| |
| var integer vl_subs1Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs1Idx, |
| pl_localName := "subs1" |
| ); |
| |
| var integer vl_subs11Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subs1", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs11Idx, |
| pl_localName := "subs11" |
| ); |
| |
| // adjusting subscriber |
| // CanAdjust: false |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| // no wait: check adjust Nack |
| //f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| f_EPTF_Var_adjustContent(vl_subs1Idx,{intVal := 1}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_mainVarIdx)!=0) { |
| setverdict(fail,"Content of main var is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=0) { |
| setverdict(fail,"Content of subscriber is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs11Idx)!=0) { |
| setverdict(fail,"Content of subscriber of subsciber is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| // no wait: check adjust_Blocking Nack |
| //f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| if (true == f_EPTF_Var_adjustContent_Blocking(vl_subs1Idx,{intVal := 1})) { |
| setverdict(fail,"The return value of adjustContent_Blocking is wrong (should be false) after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_mainVarIdx)!=0) { |
| setverdict(fail,"Content of main var is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=0) { |
| setverdict(fail,"Content of subscriber is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs11Idx)!=0) { |
| setverdict(fail,"Content of subscriber of subsciber is updated after subsCanAdjust flag is set to false"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| // CanAdjust: true |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, true); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| f_EPTF_Var_adjustContent(vl_subs1Idx,{intVal := 2}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_mainVarIdx)!=2) { |
| setverdict(fail,"Content of main var is not updated after subsCanAdjust flag is set to true"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=2) { |
| setverdict(fail,"Content of subscriber is not updated after subsCanAdjust flag is set to true"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs11Idx)!=2) { |
| setverdict(fail,"Content of subscriber of subsciber is not updated after subsCanAdjust flag is set to true"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| // adjusting subscriber of subscriber |
| // CanAdjust: true |
| |
| f_EPTF_Var_adjustContent(vl_subs11Idx,{intVal := 3}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_mainVarIdx)!=3) { |
| setverdict(fail,"Content of main var is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=f_EPTF_Var_getIntValue(vl_mainVarIdx)) { |
| setverdict(fail,"Content of subscriber is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs11Idx)!=f_EPTF_Var_getIntValue(vl_mainVarIdx)) { |
| setverdict(fail,"Content of subscriber of subscriber is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| |
| // CanAdjust: false |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| f_EPTF_Var_adjustContent(vl_subs11Idx,{intVal := 4}); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if (f_EPTF_Var_getIntValue(vl_mainVarIdx)!=3) { |
| setverdict(fail,"Content of main var is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs1Idx)!=f_EPTF_Var_getIntValue(vl_mainVarIdx)) { |
| setverdict(fail,"Content of subscriber is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| if (f_EPTF_Var_getIntValue(vl_subs11Idx)!=f_EPTF_Var_getIntValue(vl_mainVarIdx)) { |
| setverdict(fail,"Content of subscriber of subscriber is not updated after adjusting content of subscriber of subscriber"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| |
| |
| function f_EPTF_Var_Test_subsCanAdjust_callBack(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_Var_CT { |
| var integer vl_ctrVarIdx := pl_argList[0]; |
| |
| if (vl_ctrVarIdx==-1) { |
| return; |
| } |
| f_EPTF_Var_adjustContent(vl_ctrVarIdx,{intVal := 1+f_EPTF_Var_getIntValue(vl_ctrVarIdx)}); |
| } |
| |
| testcase tc_EPTF_Var_Test_subsCanAdjust_callBack() runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("MTC"); |
| |
| |
| var integer vl_ctrVarIdx := -1; |
| f_EPTF_Var_newInt("callbackCounter",0,vl_ctrVarIdx); |
| |
| var integer vl_mainVarIdx := -1; |
| f_EPTF_Var_newInt("mainVar",0,vl_mainVarIdx); |
| |
| var integer vl_subs1Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "mainVar", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs1Idx, |
| pl_localName := "subs1" |
| ); |
| |
| var integer vl_subs11Idx := -1; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subs1", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subs11Idx, |
| pl_localName := "subs11" |
| ); |
| |
| f_EPTF_Var_addSubsCanAdjustNotifyFn(vl_ctrVarIdx,{refers(f_EPTF_Var_Test_subsCanAdjust_callBack),{vl_ctrVarIdx}}); |
| f_EPTF_Var_addSubsCanAdjustNotifyFn(vl_mainVarIdx,{refers(f_EPTF_Var_Test_subsCanAdjust_callBack),{vl_ctrVarIdx}}); |
| f_EPTF_Var_addSubsCanAdjustNotifyFn(vl_subs1Idx,{refers(f_EPTF_Var_Test_subsCanAdjust_callBack),{vl_ctrVarIdx}}); |
| f_EPTF_Var_addSubsCanAdjustNotifyFn(vl_subs11Idx,{refers(f_EPTF_Var_Test_subsCanAdjust_callBack),{vl_ctrVarIdx}}); |
| |
| // CanAdjust: false |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if( 3!=f_EPTF_Var_getIntValue(vl_ctrVarIdx)) { |
| setverdict(fail,"Callbacks were called "&log2str(f_EPTF_Var_getIntValue(vl_ctrVarIdx))&" times instead of 3"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| // CanAdjust: re-set to false, callbacks should not be called: |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, false); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if( 3!=f_EPTF_Var_getIntValue(vl_ctrVarIdx)) { |
| setverdict(fail,"Callbacks were called "&log2str(f_EPTF_Var_getIntValue(vl_ctrVarIdx))&" times instead of 3 after re-set"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| // CanAdjust: true |
| f_EPTF_Var_setSubsCanAdjust(vl_mainVarIdx, true); |
| |
| f_EPTF_Var_Test_subsCanAdjust_wait(0.1); |
| |
| if( 6!=f_EPTF_Var_getIntValue(vl_ctrVarIdx)) { |
| setverdict(fail,"Callbacks were called "&log2str(f_EPTF_Var_getIntValue(vl_ctrVarIdx))&" times instead of 6"); |
| f_EPTF_Base_stop(fail); |
| } |
| |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| } // group SubsCanAdjust |
| |
| group MaxWaitTimeForByeAck { |
| |
| |
| type component EPTF_Var_Test_MaxWaitTimeForByeAck_CT extends EPTF_Var_CT { |
| var float v_byeAckWaitTime := 20.0; |
| var float v_startTime := 0.0; |
| } |
| |
| function f_EPTF_Var_Test_logging_preamble(in charstring pl_message) runs on EPTF_Var_Test_MaxWaitTimeForByeAck_CT { |
| if (match(pl_message,pattern "*--VAR CLEANUP TIMEOUT-- Not all responses received for bye messages.")) { |
| var float vl_currentTime := f_EPTF_Base_getRelTimeInSecs(); |
| var float vl_warningTime := vl_currentTime-v_startTime; |
| var float vl_error := vl_warningTime-v_byeAckWaitTime; |
| if (vl_error*vl_error<0.01) { |
| setverdict(pass, "ByeAck received in correct time"); |
| } else { |
| setverdict(fail, "ByeAck received in incorrect time. The difference is: ", vl_error); |
| } |
| } |
| } |
| |
| function f_EPTF_Var_Test_maxWaitTimeForByeAck_behaviour(in float pl_waitTime) runs on EPTF_Var_Test_MaxWaitTimeForByeAck_CT { |
| f_EPTF_Var_init_CT("MTC"); |
| v_byeAckWaitTime := pl_waitTime; |
| f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_logging_preamble)); |
| var integer vl_idx; |
| f_EPTF_Var_subscribeRemote(mtc, "int", realtime, vl_idx); |
| f_EPTF_Var_setMaxWaitTimeForByeAck(pl_waitTime); |
| timer t_wait := 1.0; |
| t_wait.start; t_wait.timeout; |
| // it is not possible to check if the warning was received or not, because when the custom cleanup is executed, the var cleanup has not yet been started! => |
| // in this case the verdict of the testcase will be none |
| v_startTime := f_EPTF_Base_getRelTimeInSecs(); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // wait a given time without handling other events: |
| function f_EPTF_Var_Test_wait(in float pl_waitTime) runs on EPTF_Var_CT { |
| timer t_restart := 0.0; |
| t_restart.start; |
| var float vl_startTime := f_EPTF_Base_getRelTimeInSecs(); |
| alt { |
| [] t_restart.timeout { |
| for(var integer i:=0; i<10000000; i:=i+1) { |
| var float f:=1.234; |
| f:=f*f; |
| } |
| if (f_EPTF_Base_getRelTimeInSecs()-vl_startTime < pl_waitTime) { |
| t_restart.start; |
| repeat; |
| } |
| } |
| } |
| } |
| |
| testcase tc_EPTF_Var_Test_maxWaitTimeForByeAck() runs on EPTF_Var_CT{ |
| |
| const float c_waitTime := 2.0; |
| |
| f_EPTF_Var_init_CT("MTC"); |
| var integer vl_idx; |
| f_EPTF_Var_newInt("int", 1, vl_idx); |
| |
| var EPTF_Var_Test_MaxWaitTimeForByeAck_CT vl_comp := EPTF_Var_Test_MaxWaitTimeForByeAck_CT.create; |
| vl_comp.start(f_EPTF_Var_Test_maxWaitTimeForByeAck_behaviour(c_waitTime)); |
| |
| timer t_wait := 0.5; |
| t_wait.start; t_wait.timeout; |
| |
| f_EPTF_Var_Test_wait(c_waitTime + 2.0); |
| f_EPTF_Base_stop(none); |
| |
| } |
| |
| } // group MaxWaitTimeForByeAck |
| |
| |
| group StringConversion { |
| |
| // tests the f_EPTF_Var_str2directContent function for all types. |
| // converts a directContent to str and back, then checks if the two are the same |
| testcase tc_EPTF_Var_Test_toStringConversion() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("toStringConversion"); |
| |
| // check conversionFinctions: |
| var EPTF_Var_DirectContent vl_currentContent; |
| var charstring vl_strValue; |
| var EPTF_Var_DirectContent vl_newContent; |
| |
| //integer: |
| vl_currentContent := {intVal := 1}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {intVal := 0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //float: |
| vl_currentContent := {floatVal := 1.0}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatVal := 0.0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //bool: |
| vl_currentContent := {boolVal := true}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {boolVal := false}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //charstring: |
| vl_currentContent := {charstringVal := " 1.0 2.0 "}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringVal := ""}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| //charstring: |
| vl_currentContent := {charstringVal := ""}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringVal := " "}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //hexstring: |
| vl_currentContent := {hexstringVal := 'ABD'H}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {hexstringVal := ''H}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //octetstring: |
| vl_currentContent := {octetstringVal := 'ABCD'O}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {octetstringVal := ''O}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //bitstring: |
| vl_currentContent := {bitstringVal := '10101'B}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {bitstringVal := ''B}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //integerList: |
| vl_currentContent := {integerlistVal := {1,2}}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {integerlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //floatList: |
| vl_currentContent := {floatlistVal := {1.0,2.0}}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //charstringList: |
| vl_currentContent := {charstringlistVal := {"1.0","2.0"}}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_green, "green"}}; |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {statusLEDVal := {led_black, omit}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent) { |
| setverdict(fail, "Conversion failed for value "&log2str(vl_currentContent)&". Converted value: "&log2str(vl_newContent)); |
| f_EPTF_Base_stop(none); |
| } |
| //... |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| // tests the f_EPTF_Var_str2directContent function for all types. |
| // converts a string to directContent, then converts the resulting directContent to str and back, then checks if the two directContents are the same |
| testcase tc_EPTF_Var_Test_fromStringConversion() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("toStringConversion"); |
| |
| // check conversionFinctions: |
| var EPTF_Var_DirectContent vl_currentContent; |
| var charstring vl_currentStrValue; |
| var charstring vl_strValue; |
| var EPTF_Var_DirectContent vl_newContent; |
| |
| //integer: |
| vl_currentContent := {intVal := 0}; |
| vl_currentStrValue := " 1 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {intVal := 0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "1" or vl_newContent != {intVal := 1}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //float: |
| vl_currentContent := {floatVal := 0.0}; |
| vl_currentStrValue := " 1.0 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatVal := 0.0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "1.000000" or vl_newContent != {floatVal := 1.0}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //float: |
| vl_currentContent := {floatVal := 0.0}; |
| vl_currentStrValue := " 12 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatVal := 0.0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "12.000000" or vl_newContent != {floatVal := 12.0}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //float: |
| vl_currentContent := {floatVal := 0.0}; |
| vl_currentStrValue := " 1.0e+3 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatVal := 0.0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "1000.000000" or vl_newContent != {floatVal := 1000.0}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //float: |
| vl_currentContent := {floatVal := 0.0}; |
| vl_currentStrValue := " 1.0e-3 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatVal := 0.0}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "0.001000" or vl_newContent != {floatVal := 0.001}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //bool: |
| vl_currentContent := {boolVal := false}; |
| vl_currentStrValue := " true "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {boolVal := false}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "true" or vl_newContent != {boolVal := true}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //charstring: |
| vl_currentContent := {charstringVal := ""}; |
| vl_currentStrValue := " 1.0 2.0 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringVal := ""}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != " 1.0 2.0 " or vl_newContent != {charstringVal := " 1.0 2.0 "}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //charstring: |
| vl_currentContent := {charstringVal := ""}; |
| vl_currentStrValue := ""; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringVal := " AA "}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "" or vl_newContent != {charstringVal := ""}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //hexstring: |
| vl_currentContent := {hexstringVal := ''H}; |
| vl_currentStrValue := " ABD "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {hexstringVal := ''H}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "ABD" or vl_newContent != {hexstringVal := 'ABD'H}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //hexstring: |
| vl_currentContent := {hexstringVal := ''H}; |
| vl_currentStrValue := ""; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {hexstringVal := 'AA'H}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "" or vl_newContent != {hexstringVal := ''H}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //octetstring: |
| vl_currentContent := {octetstringVal := ''O}; |
| vl_currentStrValue := " ABCD "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {octetstringVal := ''O}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "ABCD" or vl_newContent != {octetstringVal := 'ABCD'O}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //octetstring: |
| vl_currentContent := {octetstringVal := ''O}; |
| vl_currentStrValue := ""; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {octetstringVal := 'AA'O}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "" or vl_newContent != {octetstringVal := ''O}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //bitstring: |
| vl_currentContent := {bitstringVal := ''B}; |
| vl_currentStrValue := " 010101 "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {bitstringVal := ''B}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "010101" or vl_newContent != {bitstringVal := '010101'B}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //bitstring: |
| vl_currentContent := {bitstringVal := ''B}; |
| vl_currentStrValue := ""; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {bitstringVal := '11'B}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "" or vl_newContent != {bitstringVal := ''B}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //integerList: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " {1,2} "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {integerlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ 1, 2 }" or vl_newContent != {integerlistVal := {1,2}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //integerList: |
| vl_currentContent := {integerlistVal := {1}}; |
| vl_currentStrValue := " { } "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {integerlistVal := {1}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ }" or vl_newContent != {integerlistVal := {}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //floatList: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {1.0,2.0} "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ 1.000000, 2.000000 }" or vl_newContent != {floatlistVal := {1.0,2.0}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //floatList: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {-1.0e-1,2.0E1} "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ -0.100000, 20.000000 }" or vl_newContent != {floatlistVal := {-0.1,20.0}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //floatList: |
| vl_currentContent := {floatlistVal := {1.0}}; |
| vl_currentStrValue := " { } "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {floatlistVal := {1.0}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ }" or vl_newContent != {floatlistVal := {}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //charstringList: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""1.0"", ""a"",""2.0""} "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ ""1.0"", ""a"", ""2.0"" }" or vl_newContent != {charstringlistVal := {"1.0","a","2.0"}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //charstringList: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {"""", """",""a""} "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringlistVal := {}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ """", """", ""a"" }" or vl_newContent != {charstringlistVal := {"","","a"}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //charstringList: |
| vl_currentContent := {charstringlistVal := {"A"}}; |
| vl_currentStrValue := " { } "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {charstringlistVal := {"A"}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "{ }" or vl_newContent != {charstringlistVal := {}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, omit}}; |
| vl_currentStrValue := " [led:green] green "; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {statusLEDVal := {led_black, omit}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "[led:green] green " or vl_newContent != {statusLEDVal := {led_green," green "}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, "AAA"}}; |
| vl_currentStrValue := " [led:red]"; |
| f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent); |
| vl_strValue := f_EPTF_Var_directContent2str(vl_currentContent); |
| vl_newContent := {statusLEDVal := {led_black, "AAA"}}; |
| f_EPTF_Var_str2directContent(vl_strValue, vl_newContent); |
| if (vl_newContent!=vl_currentContent or vl_strValue != "[led:red]" or vl_newContent != {statusLEDVal := {led_red,omit}}) { |
| setverdict(fail, "Conversion failed for value "&vl_currentStrValue&". Converted value: "&vl_strValue); |
| f_EPTF_Base_stop(none); |
| } |
| //... |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| // negativ test for the f_EPTF_Var_str2directContent function |
| // wrong string values are used as the parameter for all variable types |
| testcase tc_EPTF_Var_Test_fromStringConversion_neg() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("toStringConversion"); |
| |
| var EPTF_Var_DirectContent vl_currentContent; |
| var charstring vl_currentStrValue; |
| var charstring vl_strValue; |
| var EPTF_Var_DirectContent vl_newContent; |
| |
| //integer: |
| vl_currentContent := {intVal := 0}; |
| vl_currentStrValue := " A 1 "; |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //float: |
| vl_currentContent := {floatVal := 0.0}; |
| vl_currentStrValue := " 1..2 "; |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //bool: |
| vl_currentContent := {boolVal := false}; |
| vl_currentStrValue := " 124 "; |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //charstring: always successful |
| |
| //hexstring: |
| vl_currentContent := {hexstringVal := ''H}; |
| vl_currentStrValue := " 124X "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //octetstring: |
| vl_currentContent := {octetstringVal := ''O}; |
| vl_currentStrValue := " 124X "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //octetstring: |
| vl_currentContent := {octetstringVal := ''O}; |
| vl_currentStrValue := " 123 "; // odd number of chars |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //bitstring: |
| vl_currentContent := {bitstringVal := ''B}; |
| vl_currentStrValue := " 12 "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //integerlist: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " 1 2 "; // missing "," and "{}" |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //integerlist: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " { A1 } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //integerlist: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " {1A, 2 } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //integerlist: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " {1, A2 } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //integerlist: |
| vl_currentContent := {integerlistVal := {}}; |
| vl_currentStrValue := " {1, 2A , 3 } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {1.0, ""2"" } "; // wrong datatype |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " 1.0, 2.0 } "; // missing "{}" |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {A1.0, 2.0 } } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {1.0A, 2.0 } } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {1.0, A2.0 } } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //floatlist: |
| vl_currentContent := {floatlistVal := {}}; |
| vl_currentStrValue := " {1.0, 2.0A } } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " ""a"", ""bb"" "; // missing "{}" |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {a, bb } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a, bb } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a, bb } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a"", bb } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a"", ""bb } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a"", bb"" } "; // missing " |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a"",, ""b"" } "; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //charstringlist: |
| vl_currentContent := {charstringlistVal := {}}; |
| vl_currentStrValue := " {""a\\""A"", ""b"" } "; // invalid char: \" is not allowed in string |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, omit}}; |
| vl_currentStrValue := " [led:greeen] green"; // invalid color |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, omit}}; |
| vl_currentStrValue := " [ledAA:green] green"; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, omit}}; |
| vl_currentStrValue := " [[led:green] green"; // invalid char |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| //statusLED: |
| vl_currentContent := {statusLEDVal := {led_black, omit}}; |
| vl_currentStrValue := " led:red green"; // missing "[]" |
| if (0!=f_EPTF_Var_str2directContent(vl_currentStrValue,vl_currentContent)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail, "The value "&vl_currentStrValue&" is wrong, the conversion should be unsuccessful, but it succeeded"); |
| } |
| |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| // tests the f_EPTF_Var_content2str function for all types. |
| // converts the content of the variable to string, then checks the result |
| testcase tc_EPTF_Var_Test_content2StrConversion() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("toStringConversion"); |
| |
| f_initVariables(); |
| |
| var charstring vl_strValue; |
| |
| // integer |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("intVar")); |
| if (vl_strValue!="1") { |
| setverdict(fail,"Content conversion of var failed. Expected: 1, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // float |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("floatVar")); |
| if (vl_strValue!="1.000000") { |
| setverdict(fail,"Content conversion of var failed. Expected: 1.000000, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // bool |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("boolVar")); |
| if (vl_strValue!="true") { |
| setverdict(fail,"Content conversion of var failed. Expected: true, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // charstring |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("charstringVar")); |
| if (vl_strValue!="1.0") { |
| setverdict(fail,"Content conversion of var failed. Expected: ""1.0"", Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // octetstring |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("octetstringVar")); |
| if (vl_strValue!="01") { |
| setverdict(fail,"Content conversion of var failed. Expected: 01, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // hexstring |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("hexstringVar")); |
| if (vl_strValue!="01") { |
| setverdict(fail,"Content conversion of var failed. Expected: 01, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // bitstring |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("bitstringVar")); |
| if (vl_strValue!="01") { |
| setverdict(fail,"Content conversion of var failed. Expected: 01, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // integerlist |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("integerlistVar")); |
| if (vl_strValue!="{ 0, 1 }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { 0, 1 }, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // floatlistVar |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("floatlistVar")); |
| if (vl_strValue!="{ 0.000000, 1.000000 }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { 0.000000, 1.000000 }, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // charstringlistVar |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("charstringlistVar")); |
| if (vl_strValue!="{ ""0"", ""1"" }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { ""0"", ""1"" }, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| // statusLED |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("statusLEDVar")); |
| if (vl_strValue!="[led:blue]1") { |
| setverdict(fail,"Content conversion of var failed. Expected: [led:blue]1, Got: "&vl_strValue) |
| } else { |
| setverdict(pass); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| // tests the f_EPTF_Var_str2content function for all types. |
| // sets the value of the Variables from string, then converts the resulting varibale's content to str and checks if the two strings are the same |
| testcase tc_EPTF_Var_Test_str2contentConversion() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("toStringConversion"); |
| |
| f_initVariables(); |
| |
| var charstring vl_strValue; |
| var integer vl_errorCode; |
| |
| // integer |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("intVar"),"2"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("intVar")); |
| if (vl_errorCode != 0 or vl_strValue!="2") { |
| setverdict(fail,"Content conversion of var failed. Expected: 2, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // float |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("floatVar"),"2.0"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("floatVar")); |
| if (vl_errorCode != 0 or vl_strValue!="2.000000") { |
| setverdict(fail,"Content conversion of var failed. Expected: 2.000000, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // bool |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("boolVar"),"false"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("boolVar")); |
| if (vl_errorCode != 0 or vl_strValue!="false") { |
| setverdict(fail,"Content conversion of var failed. Expected: false, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // charstring |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("charstringVar"),"2.0"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("charstringVar")); |
| if (vl_errorCode != 0 or vl_strValue!="2.0") { |
| setverdict(fail,"Content conversion of var failed. Expected: ""2.0"", Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // octetstring |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("octetstringVar"),"0101"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("octetstringVar")); |
| if (vl_errorCode != 0 or vl_strValue!="0101") { |
| setverdict(fail,"Content conversion of var failed. Expected: 0101, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // hexstring |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("hexstringVar"),"010"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("hexstringVar")); |
| if (vl_errorCode != 0 or vl_strValue!="010") { |
| setverdict(fail,"Content conversion of var failed. Expected: 010, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // bitstring |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("bitstringVar"),"010"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("bitstringVar")); |
| if (vl_errorCode != 0 or vl_strValue!="010") { |
| setverdict(fail,"Content conversion of var failed. Expected: 010, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // integerlist |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("integerlistVar"),"{1,2,3}"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("integerlistVar")); |
| if (vl_errorCode != 0 or vl_strValue!="{ 1, 2, 3 }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { 1, 2, 3 }, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // floatlistVar |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("floatlistVar"),"{1.000000,2.000000,3.000000}"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("floatlistVar")); |
| if (vl_errorCode != 0 or vl_strValue!="{ 1.000000, 2.000000, 3.000000 }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { 1.000000, 2.000000, 3.000000 }, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // charstringlistVar |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("charstringlistVar"),"{""A"", ""B"" , ""C"" }"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("charstringlistVar")); |
| if (vl_errorCode != 0 or vl_strValue!="{ ""A"", ""B"", ""C"" }") { |
| setverdict(fail,"Content conversion of var failed. Expected: { ""A"", ""B"", ""C"" }, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| // statusLED |
| vl_errorCode := f_EPTF_Var_str2content(f_EPTF_Var_getId("statusLEDVar"),"[led:green]gr"); |
| vl_strValue := f_EPTF_Var_content2str(f_EPTF_Var_getId("statusLEDVar")); |
| if (vl_errorCode != 0 or vl_strValue!="[led:green]gr") { |
| setverdict(fail,"Content conversion of var failed. Expected: [led:green]gr, Got: "&vl_strValue&" Error code: "&int2str(vl_errorCode)); |
| } else { |
| setverdict(pass); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| }// group StringConversion |
| |
| |
| group CleanupDuringSubscribe { |
| |
| |
| function f_EPTF_Var_Test_cleanupDuringSubscribe_checkExpectedWarning_preamble_FT(in charstring pl_message) runs on EPTF_Var_CT { |
| if (not match(pl_message,pattern "*Warning*")) { |
| return; |
| } |
| if (match(pl_message,pattern "*EPTF_Var*No response received for hello*")) { |
| setverdict(pass); // verdict is only pass, if the hello was not answered at least once |
| } |
| } |
| |
| function f_EPTF_Var_Test_cleanupDuringSubscribe_subscriberCTBehaviour(in integer pl_id, in EPTF_Var_CT pl_exitCT) runs on EPTF_Var_CT { |
| timer t_start := 2.0; |
| t_start.start; |
| var integer vl_idx; |
| |
| f_EPTF_Var_init_CT("cleanupDuringSubscribe_subscriberCTBehaviour_"&int2str(pl_id)); |
| f_EPTF_Var_setMaxWaitTime(10.0); |
| f_EPTF_Base_setNegativeTestMode(); // if there is no response to the subscribe, variable would set the verdict to fail. The negative test mode prevents it |
| f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_cleanupDuringSubscribe_checkExpectedWarning_preamble_FT)); |
| |
| alt { |
| [] t_start.timeout { |
| f_EPTF_Var_subscribeRemote(pl_exitCT,"intVar", realtime,vl_idx); // the connection should be closed during this function call |
| } |
| } |
| t_start.start; |
| t_start.timeout; |
| f_EPTF_Base_stop(none); // this should generate a DTE when sending bye to pl_exitCT |
| } |
| |
| function f_EPTF_Var_Test_cleanupDuringSubscribe_exitCTBehaviour() runs on EPTF_Var_CT { |
| timer t_start := 2.0; |
| t_start.start; |
| var integer vl_idx; |
| |
| f_EPTF_Var_init_CT("cleanupDuringSubscribe_subscriberCTBehaviour"); |
| f_EPTF_Var_newInt("intVar", 1, vl_idx); |
| |
| alt { |
| [] t_start.timeout { |
| f_EPTF_Base_stop(none); |
| } |
| } |
| } |
| |
| // Tests the following erroneous behaviour: |
| // A DTE happens when the other component does not reply to the subscribe message |
| // but it exits before handling it. It does not send the bye message to the original component, because the incoming subscribe was not handled. |
| // It is still in the queue when the cleanup starts. |
| // Later, when the subscriber component exits it sends a bye message to the |
| // exited component, because it does not know that the other component exited, which results in the following DTE: |
| // Dynamic test case error: Data cannot be sent on port EPTF_Var_MgmtIf to component 3 because there is no connection towards component 3 |
| // |
| // The testcase sets up a component which holds a variable, and starts c_subsCTNum other components |
| // which subscribe to the variable. At the time of the subscription the original component |
| // exits. One or more of the c_subsCTNum components should subscribe in a way that there will be no |
| // response from the original component. If that happens, they will run into DTE during the Variable cleanup. |
| // The test should pass, even if there were unanswered subscriptions if this problem is corrected. |
| // Without the fix, the test exits with the DTE above. |
| testcase tc_EPTF_Var_Test_cleanupDuringSubscribe() runs on VariableTest_CT { |
| const integer c_subsCTNum := 10; |
| f_EPTF_Base_init_CT("cleanupDuringSubscribe"); |
| |
| var EPTF_Var_CT vl_subscriberCT[c_subsCTNum] |
| |
| var EPTF_Var_CT vl_exitCT := EPTF_Var_CT.create; |
| for (var integer i:=0; i<c_subsCTNum; i:=i+1) { |
| vl_subscriberCT[i]:= EPTF_Var_CT.create; |
| } |
| |
| for (var integer i:=0; i<c_subsCTNum; i:=i+1) { |
| vl_subscriberCT[i].start(f_EPTF_Var_Test_cleanupDuringSubscribe_subscriberCTBehaviour(i,vl_exitCT)); |
| } |
| vl_exitCT.start(f_EPTF_Var_Test_cleanupDuringSubscribe_exitCTBehaviour()); |
| |
| all component.done |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| function f_EPTF_Var_Test_cleanupDuringConnectionSetup_checkExpectedDebug_preamble_FT(in charstring pl_message) runs on EPTF_Var_CT { |
| if (not match(pl_message,pattern "*Debug*")) { |
| return; |
| } |
| if (match(pl_message,pattern "*EPTF_Var*Waiting for*number of pending hello messages...*")) { |
| setverdict(pass); // verdict is only pass, if the hello was not answered at least once in the cleanup |
| } |
| } |
| |
| function f_EPTF_Var_Test_cleanupDuringConnectionSetup_subscriberCTBehaviour(in integer pl_id, in EPTF_Var_CT pl_exitCT) runs on EPTF_Var_CT { |
| timer t_start := 2.0; |
| t_start.start; |
| var integer vl_idx; |
| |
| f_EPTF_Var_init_CT("cleanupDuringSubscribe_subscriberCTBehaviour_"&int2str(pl_id)); |
| f_EPTF_Var_enableDebug(); |
| f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_cleanupDuringConnectionSetup_checkExpectedDebug_preamble_FT)); |
| |
| alt { |
| [] t_start.timeout { |
| f_EPTF_Var_subscribeRemote(pl_exitCT,"intVar", realtime,vl_idx); // the connection should be closed during this function call |
| } |
| } |
| t_start.start; |
| t_start.timeout; |
| f_EPTF_Base_stop(none); // this should generate a DTE when sending bye to pl_exitCT |
| } |
| |
| // Tests if no DTE happens when the MTC component does reply to the hello message |
| // but the other component receives a stopRemote during connection setup. |
| // |
| // The testcase sets up a component subscribe to the variable on the MTC. At the time of the connection setup the MTC component |
| // exits. One or more of the c_subsCTNum components should subscribe in a way that there will be no |
| // stops the system. The subscriber and the MTC component should exit without DTE. |
| // The test should pass, when there are interrupted connection establishments. |
| // Without the fix, the test exits with the DTE on MTC. |
| // THE TEST SHOULD BE COMPILED with EPTF_DEBUG !! |
| testcase tc_EPTF_Var_Test_cleanupDuringConnectionSetup() runs on VariableTest_CT { |
| const integer c_subsCTNum := 1; |
| f_EPTF_Base_init_CT("cleanupDuringConnectionSetup"); |
| |
| if (c_EPTF_Common_debugSwitch==false) { |
| setverdict(inconc,"The test is not compiled in debug mode") |
| } |
| |
| f_EPTF_Logging_registerPreambleFn(refers(f_EPTF_Var_Test_cleanupDuringConnectionSetup_checkExpectedDebug_preamble_FT)); |
| |
| var EPTF_Var_CT vl_subscriberCT[c_subsCTNum] |
| |
| for (var integer i:=0; i<c_subsCTNum; i:=i+1) { |
| vl_subscriberCT[i]:= EPTF_Var_CT.create; |
| } |
| |
| for (var integer i:=0; i<c_subsCTNum; i:=i+1) { |
| vl_subscriberCT[i].start(f_EPTF_Var_Test_cleanupDuringConnectionSetup_subscriberCTBehaviour(i,mtc)); |
| } |
| |
| f_EPTF_Var_Test_cleanupDuringSubscribe_exitCTBehaviour(); |
| all component.done |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| } //group CleanupDuringSubscribe |
| |
| |
| group SubscribeAfterBye { |
| |
| function f_EPTF_Var_Test_subscribeAfterByeBehavior(in float pl_executionTime) runs on EPTF_Var_CT{ |
| f_EPTF_Var_init_CT("subscribeAfterByeBehavior"); |
| var integer vl_varId; |
| f_EPTF_Var_newInt(c_varname, 1, vl_varId) |
| timer t1 |
| t1.start( pl_executionTime ); |
| |
| t1.timeout; |
| f_EPTF_Base_stop(none); |
| } |
| |
| testcase tc_EPTF_Var_Test_subscribeAfterBye() runs on VariableTest_CT { |
| f_EPTF_Var_init_CT("subscribeAfterBye"); |
| |
| var float vl_executionTime := 1.0; |
| |
| var EPTF_Var_CT vl_server := EPTF_Var_CT.create; |
| vl_server.start( f_EPTF_Var_Test_subscribeAfterByeBehavior(vl_executionTime) ); |
| var integer vl_varId; |
| |
| timer t_wait; |
| t_wait.start(vl_executionTime*0.2); |
| t_wait.timeout; |
| t_wait.start(vl_executionTime*1.2); |
| f_EPTF_Var_subscribeRemote(vl_server, c_varname, realtime, vl_varId); |
| f_EPTF_Var_unsubscribe(vl_varId); |
| t_wait.timeout; // now the server comp terminated |
| t_wait.start(vl_executionTime*0.2); |
| |
| //try to resubscribe, no DTE should happen here: |
| f_EPTF_Var_resubscribeRemote(vl_server, c_varname, realtime, vl_varId); |
| t_wait.timeout; |
| |
| f_EPTF_Base_stop(pass); |
| |
| |
| |
| } |
| |
| } // group SubscribeAfterBye |
| |
| |
| // If a local provider added later by f_EPTF_Var_addLocalProviders with index larger than the index of the variable, then |
| // the f_EPTF_Var_addVarToUpdate function will add it before the current position |
| // and the update of this variable will be omitted |
| // This is to test the artf282815 (Total Counters not working) problem |
| group AddLocalProvidersWithLargerID { |
| |
| testcase tc_EPTF_Var_Test_addLocalProvidersWithLargerID() runs on VariableTest_CT { |
| |
| // var0, var1 |
| // var2: localSubsr(sum of var3) |
| // var3: localSubsr(sum of var0 and var1) |
| // var4 var5 |
| // var6: localSubsr(sum of var4 and var5) |
| |
| // var0,var1,var4,var5 updated, var2, var3 and var6 should show the correct values |
| |
| f_EPTF_Var_init_CT("addLocalProvidersWithLargerID"); |
| |
| timer t_wait := 3.0; |
| var integer vl_var0Idx,vl_var1Idx,vl_var2Idx,vl_var3Idx,vl_var4Idx,vl_var5Idx,vl_var6Idx; |
| f_EPTF_Var_newInt("var0",0,vl_var0Idx); |
| f_EPTF_Var_newInt("var1",0,vl_var1Idx); |
| f_EPTF_Var_newInt("var2",0,vl_var2Idx); |
| f_EPTF_Var_newInt("var3",0,vl_var3Idx); |
| f_EPTF_Var_newInt("var4",0,vl_var4Idx); |
| f_EPTF_Var_newInt("var5",0,vl_var5Idx); |
| f_EPTF_Var_newInt("var6",0,vl_var6Idx); |
| |
| f_EPTF_Var_subscribeLocal(vl_var2Idx,{{refers(f_calculationSum),{vl_var3Idx},{}}}); |
| f_EPTF_Var_subscribeLocal(vl_var3Idx,{{refers(f_calculationSum),{vl_var0Idx,vl_var1Idx},{}}}); |
| f_EPTF_Var_subscribeLocal(vl_var6Idx,{{refers(f_calculationSum),{vl_var4Idx,vl_var5Idx},{}}}); |
| |
| f_EPTF_Var_adjustContent(vl_var0Idx,{intVal:=1}); |
| f_EPTF_Var_adjustContent(vl_var5Idx,{intVal:=6}); |
| t_wait.start; t_wait.timeout; |
| |
| // now the values should be like this: |
| // var2: 1 |
| // var3: 1 |
| // var6: 6 |
| |
| if(f_EPTF_Var_getIntValue(vl_var2Idx)!=1) { |
| setverdict(fail,"Incorrect value of var2: ", f_EPTF_Var_getIntValue(vl_var2Idx), ". Should be: 1"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var3Idx)!=1) { |
| setverdict(fail,"Incorrect value of var3: ", f_EPTF_Var_getIntValue(vl_var3Idx), ". Should be: 1"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var6Idx)!=6) { |
| setverdict(fail,"Incorrect value of var6: ", f_EPTF_Var_getIntValue(vl_var6Idx), ". Should be: 6"); |
| //f_EPTF_Base_stop(none); |
| } |
| |
| f_EPTF_Var_adjustContent(vl_var1Idx,{intVal:=2}); |
| f_EPTF_Var_adjustContent(vl_var4Idx,{intVal:=5}); |
| |
| // wait to update the values |
| t_wait.start; t_wait.timeout; |
| |
| // now the values should be like this: |
| // var2: 3 |
| // var3: 3 |
| // var6: 11 |
| |
| if(f_EPTF_Var_getIntValue(vl_var2Idx)!=3) { |
| setverdict(fail,"Incorrect value of var2: ", f_EPTF_Var_getIntValue(vl_var2Idx), ". Should be: 3"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var3Idx)!=3) { |
| setverdict(fail,"Incorrect value of var3: ", f_EPTF_Var_getIntValue(vl_var3Idx), ". Should be: 3"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var6Idx)!=11) { |
| setverdict(fail,"Incorrect value of var6: ", f_EPTF_Var_getIntValue(vl_var6Idx), ". Should be: 11"); |
| //f_EPTF_Base_stop(none); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_Test_addLocalProvidersWithLargerID2() runs on VariableTest_CT { |
| |
| // var0, var1 |
| // var2: localSubsr(sum of var3) |
| // var3: localSubsr(sum of var0 and var1) |
| // var4 var5 |
| // var6: localSubsr(sum of var4 and var5) |
| |
| // var0,var1,var4,var5 updated, var2, var3 and var6 should show the correct values |
| |
| f_EPTF_Var_init_CT("addLocalProvidersWithLargerID2"); |
| |
| timer t_wait := 3.0; |
| var integer vl_var0Idx,vl_var1Idx,vl_var2Idx,vl_var3Idx,vl_var4Idx,vl_var5Idx,vl_var6Idx; |
| f_EPTF_Var_newInt("var0",0,vl_var0Idx); |
| f_EPTF_Var_newInt("var1",0,vl_var1Idx); |
| f_EPTF_Var_newInt("var2",0,vl_var2Idx); |
| f_EPTF_Var_newInt("var3",0,vl_var3Idx); |
| f_EPTF_Var_newInt("var4",0,vl_var4Idx); |
| f_EPTF_Var_newInt("var5",0,vl_var5Idx); |
| f_EPTF_Var_newInt("var6",0,vl_var6Idx); |
| |
| f_EPTF_Var_subscribeLocal(vl_var2Idx,{{refers(f_calculationSum),{vl_var3Idx},{}}}); |
| f_EPTF_Var_subscribeLocal(vl_var3Idx,{{refers(f_calculationSum),{vl_var0Idx,vl_var1Idx},{}}}); |
| f_EPTF_Var_subscribeLocal(vl_var6Idx,{{refers(f_calculationSum),{},{}}}); |
| f_EPTF_Var_addLocalProviders(vl_var6Idx,{vl_var4Idx,vl_var5Idx}); |
| |
| f_EPTF_Var_adjustContent(vl_var0Idx,{intVal:=1}); |
| f_EPTF_Var_adjustContent(vl_var1Idx,{intVal:=2}); |
| f_EPTF_Var_adjustContent(vl_var4Idx,{intVal:=5}); |
| f_EPTF_Var_adjustContent(vl_var5Idx,{intVal:=6}); |
| |
| // wait to update the values |
| t_wait.start; t_wait.timeout; |
| |
| // now the values should be like this: |
| // var2: 3 |
| // var3: 3 |
| // var6: 11 |
| |
| if(f_EPTF_Var_getIntValue(vl_var2Idx)!=3) { |
| setverdict(fail,"Incorrect value of var2: ", f_EPTF_Var_getIntValue(vl_var2Idx), ". Should be: 3"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var3Idx)!=3) { |
| setverdict(fail,"Incorrect value of var3: ", f_EPTF_Var_getIntValue(vl_var3Idx), ". Should be: 3"); |
| //f_EPTF_Base_stop(none); |
| } |
| if(f_EPTF_Var_getIntValue(vl_var6Idx)!=11) { |
| setverdict(fail,"Incorrect value of var6: ", f_EPTF_Var_getIntValue(vl_var6Idx), ". Should be: 11"); |
| //f_EPTF_Base_stop(none); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| } // group AddLocalProviders_withLargerID |
| |
| |
| group SubscribeToSameLocalVar { |
| |
| altstep as_EPTF_Var_Test_subscribeToSameLocalVar_checkLoop() runs on VariableTest_CT { |
| [] T_WAIT.timeout { |
| //no loop, exit the alt |
| } |
| } |
| |
| |
| // test subscribeRemote if subscribing realtime to a local variable, no infinite loops should occur |
| testcase tc_EPTF_Var_Test_subscribeRealtimeToSameLocalVar() runs on VariableTest_CT { |
| //T_WAIT: if this timeout can be handled: no infinite loop |
| timer t_maxWait := 1.0; // checking interval |
| |
| activate(as_EPTF_Var_Test_subscribeToSameLocalVar_checkLoop()); |
| f_EPTF_Var_init_CT("subscribeToSameLocalVar"); |
| |
| |
| var integer vl_var1Idx, vl_var2Idx, vl_var3Idx, vl_var4Idx; |
| f_EPTF_Var_newInt("var1",1,vl_var1Idx); |
| f_EPTF_Var_newInt("var2",2,vl_var2Idx); |
| f_EPTF_Var_newInt("var3",3,vl_var3Idx); |
| f_EPTF_Var_newInt("var4",4,vl_var4Idx); |
| |
| var integer vl_subscribedVarIdx; |
| |
| |
| // subscribing realtime to a local var if pl_localName is not given |
| // this should return the same var: |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var1", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subscribedVarIdx, |
| pl_localName := "" |
| ); |
| if (vl_subscribedVarIdx != vl_var1Idx) { |
| setverdict(fail,"SubscribeRemote returns a different var for subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var1Idx,{intVal := 11}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| t_maxWait.start(11.0);t_maxWait.timeout; |
| //check the value of the subscribed variable: |
| if (f_EPTF_Var_getIntValue(vl_var1Idx) != f_EPTF_Var_getIntValue(vl_subscribedVarIdx)) { |
| setverdict(fail,"The value of the subscribed var differs from the original."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| // subscribing realtime to a local var if pl_localName is given and it is the same |
| // this should return the same var: |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var2", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subscribedVarIdx, |
| pl_localName := "var2" |
| ); |
| if (vl_subscribedVarIdx != vl_var2Idx) { |
| setverdict(fail,"SubscribeRemote returns a different var for subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var2Idx,{intVal := 11}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| t_maxWait.start(11.0);t_maxWait.timeout; |
| //check the value of the subscribed variable: |
| if (f_EPTF_Var_getIntValue(vl_var2Idx) != f_EPTF_Var_getIntValue(vl_subscribedVarIdx)) { |
| setverdict(fail,"The value of the subscribed var differs from the original."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| // subscribing realtime to a local var if pl_localName is given and it is different |
| // this should return a different var, and also a debug about performance degradation: |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var3", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subscribedVarIdx, |
| pl_localName := "var3b" |
| ); |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var3Idx,{intVal := 33}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| t_maxWait.start(11.0);t_maxWait.timeout; |
| //check the value of the subscribed variable: |
| if (f_EPTF_Var_getIntValue(vl_var3Idx) != f_EPTF_Var_getIntValue(vl_subscribedVarIdx)) { |
| setverdict(fail,"The value of the subscribed var differs from the original."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| setverdict(pass); |
| |
| } |
| |
| // test subscribeRemote if subscribing non-realtime to a local variable, no infinite loops should occur |
| testcase tc_EPTF_Var_Test_subscribeNonRealtimeToSameLocalVar() runs on VariableTest_CT { |
| //T_WAIT: if this timeout can be handled: no infinite loop |
| timer t_maxWait := 1.0; // checking interval |
| |
| activate(as_EPTF_Var_Test_subscribeToSameLocalVar_checkLoop()); |
| f_EPTF_Var_init_CT("subscribeToSameLocalVar"); |
| |
| |
| var integer vl_var1Idx, vl_var2Idx, vl_var3Idx, vl_var4Idx; |
| f_EPTF_Var_newInt("var1",1,vl_var1Idx); |
| f_EPTF_Var_newInt("var2",2,vl_var2Idx); |
| f_EPTF_Var_newInt("var3",3,vl_var3Idx); |
| f_EPTF_Var_newInt("var4",4,vl_var4Idx); |
| |
| var integer vl_subscribedVarIdx; |
| |
| |
| // subscribing realtime to a local var if pl_localName is not given |
| // this should return a different var: |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var1", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_subscribedVarIdx, |
| pl_localName := "" |
| ); |
| if (vl_subscribedVarIdx == vl_var1Idx) { |
| setverdict(fail,"SubscribeRemote returns the same var when subscribing non-realtime to a local var if pl_localName is not given. They sould be different."); |
| f_EPTF_Base_stop(none); |
| } |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var1Idx,{intVal := 11}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| t_maxWait.start(11.0);t_maxWait.timeout; |
| //check the value of the subscribed variable: |
| if (f_EPTF_Var_getIntValue(vl_var1Idx) != f_EPTF_Var_getIntValue(vl_subscribedVarIdx)) { |
| setverdict(fail,"The value of the subscribed var differs from the original."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // subscribing realtime to a local var if pl_localName is given and it is different |
| // this should return a different var: |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var3", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_subscribedVarIdx, |
| pl_localName := "var3b" |
| ); |
| if (vl_subscribedVarIdx == vl_var1Idx) { |
| setverdict(fail,"SubscribeRemote returns the same var when subscribing non-realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var3Idx,{intVal := 11}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when subscribing realtime to a local var if pl_localName is not given"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| t_maxWait.start(11.0);t_maxWait.timeout; |
| //check the value of the subscribed variable: |
| if (f_EPTF_Var_getIntValue(vl_var3Idx) != f_EPTF_Var_getIntValue(vl_subscribedVarIdx)) { |
| setverdict(fail,"The value of the subscribed var differs from the original."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| setverdict(pass); |
| |
| } |
| |
| // test resubscribeRemote if resubscribing to the same local variable causes infinite loop, no infinite loops should occur |
| testcase tc_EPTF_Var_Test_resubscribeToSameLocalVar() runs on VariableTest_CT { |
| //T_WAIT: if this timeout can be handled: no infinite loop |
| timer t_maxWait := 1.0; // checking interval |
| |
| activate(as_EPTF_Var_Test_subscribeToSameLocalVar_checkLoop()); |
| f_EPTF_Var_init_CT("subscribeToSameLocalVar"); |
| |
| |
| var integer vl_var1Idx, vl_var2Idx, vl_var3Idx, vl_var4Idx; |
| f_EPTF_Var_newInt("var1",1,vl_var1Idx); |
| f_EPTF_Var_newInt("var2",2,vl_var2Idx); |
| f_EPTF_Var_newInt("var3",3,vl_var3Idx); |
| f_EPTF_Var_newInt("var4",4,vl_var4Idx); |
| |
| var integer vl_subscribedVarIdx; |
| |
| |
| // resubscribing realtime to the same local var (pl_localName is not given) |
| // this should return the same var: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var3", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_var3Idx, |
| pl_localName := "" |
| ); |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var3Idx,{intVal := 33}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when resubscribing realtime to the same local var"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| //check the value of the local variable: |
| if (f_EPTF_Var_getIntValue(vl_var3Idx) != 33) { |
| setverdict(fail,"The value of the resubscribed var differs from the expected."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // resubscribing non-realtime to the same local var (pl_localName is not given) |
| // this should return the same var: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "var4", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_var4Idx, |
| pl_localName := "" |
| ); |
| //try to adjust original and check if there is no infinite loop: |
| T_WAIT.start(0.1); |
| t_maxWait.start; |
| f_EPTF_Var_adjustContent(vl_var4Idx,{intVal := 44}); |
| alt { |
| [] t_maxWait.timeout { |
| setverdict(fail,"Infinite loop detected when resubscribing non-realtime to the same local var"); |
| f_EPTF_Base_stop(none); |
| } |
| } |
| //check the value of the local variable: |
| if (f_EPTF_Var_getIntValue(vl_var4Idx) != 44) { |
| setverdict(fail,"The value of the resubscribed var differs from the expected."); |
| f_EPTF_Base_stop(none); |
| } |
| |
| setverdict(pass); |
| |
| } |
| |
| } // |
| |
| |
| group ReSubscribeLocalRealtime { |
| |
| |
| // resubscribes a variable to local varibale realtime and checks if it is updated correctly |
| // when the original/subscriber var is adjusted. |
| // Same test is done for sampled subscription as well. |
| testcase tc_EPTF_Var_Test_reSubscribeLocal() runs on VariableTest_CT { |
| |
| f_EPTF_Var_init_CT("reSubscribeLocal"); |
| |
| var float vl_syncInterval := 0.1; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| timer t_wait := vl_syncInterval*2.0; |
| |
| var integer vl_providerVarIdx, vl_subscriberVarIdx; |
| |
| f_EPTF_Var_newInt("provider",0,vl_providerVarIdx); |
| f_EPTF_Var_newInt("subscriber",0,vl_subscriberVarIdx); |
| |
| // resubscribe the local subscriber to the local provider in realtime: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := realtime, |
| pl_idx := vl_subscriberVarIdx |
| ) |
| |
| t_wait.start; |
| t_wait.timeout; |
| |
| // update provider: |
| f_EPTF_Var_adjustContent(vl_providerVarIdx,{intVal := 1}); |
| t_wait.start; |
| t_wait.timeout; |
| // check subscriber: |
| if(f_EPTF_Var_getIntValue(vl_subscriberVarIdx)!=1) { |
| setverdict(fail,"The value of the subscribed variable not updated for realtime resubscription. Current value: ", |
| f_EPTF_Var_getIntValue(vl_subscriberVarIdx), " should be: 1"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // update subscriber: |
| f_EPTF_Var_adjustContent(vl_subscriberVarIdx,{intVal := 2}); |
| t_wait.start; |
| t_wait.timeout; |
| // check provider: |
| if(f_EPTF_Var_getIntValue(vl_providerVarIdx)!=2) { |
| setverdict(fail,"The value of the provider variable not updated for realtime resubscription. Current value: ", |
| f_EPTF_Var_getIntValue(vl_providerVarIdx), " should be: 2"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| |
| // repeat the test for sampled subscription: |
| |
| // unsubscribe: |
| f_EPTF_Var_unsubscribe(vl_subscriberVarIdx); |
| // check if really unsubscribed: |
| // update subscriber: |
| f_EPTF_Var_adjustContent(vl_subscriberVarIdx,{intVal := 3}); |
| t_wait.start; |
| t_wait.timeout; |
| // check provider: |
| if(f_EPTF_Var_getIntValue(vl_providerVarIdx)!=2) { |
| setverdict(fail,"The value of the provider variable was updated after insubscribe. Current value: ", |
| f_EPTF_Var_getIntValue(vl_providerVarIdx), " should be: 2"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // now resubscribe in sampled mode and do the checks: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_subscriberVarIdx |
| ) |
| t_wait.start; |
| t_wait.timeout; |
| // update provider: |
| f_EPTF_Var_adjustContent(vl_providerVarIdx,{intVal := 4}); |
| t_wait.start; |
| t_wait.timeout; |
| // check subscriber: |
| if(f_EPTF_Var_getIntValue(vl_subscriberVarIdx)!=4) { |
| setverdict(fail,"The value of the subscribed variable not updated for sampled resubscription. Current value: ", |
| f_EPTF_Var_getIntValue(vl_subscriberVarIdx), " should be: 4"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| // update subscriber: |
| f_EPTF_Var_adjustContent(vl_subscriberVarIdx,{intVal := 5}); |
| t_wait.start; |
| t_wait.timeout; |
| // check provider: |
| if(f_EPTF_Var_getIntValue(vl_providerVarIdx)!=5) { |
| setverdict(fail,"The value of the provider variable not updated for sampled resubscription. Current value: ", |
| f_EPTF_Var_getIntValue(vl_providerVarIdx), " should be: 5"); |
| f_EPTF_Base_stop(none); |
| } |
| |
| setverdict(pass); |
| f_EPTF_Base_stop(none); |
| |
| } |
| |
| } // group ReSubscribeLocalRealtime |
| |
| group PullModeSubscription { |
| |
| function f_EPTF_Var_SubscribeTest_pull_adjustContent_handler( |
| in integer pl_idx, |
| in EPTF_Var_DirectContent pl_content, |
| in boolean pl_result, |
| in EPTF_IntegerList pl_argList |
| ) runs on VariableTest_CT { |
| v_inc := pl_content.intVal; |
| if (sizeof(pl_argList) != 1 or pl_argList[0] != 1 or f_EPTF_Var_getName(pl_idx) != "subscriber3" or pl_content != {intVal := 10} or pl_result != true) { |
| setverdict(fail," my handler called with incorrect parameters") |
| } |
| action("my adjust handler is called with idx: ",pl_idx," content: ",pl_content, " result: ",pl_result," args: ", pl_argList); |
| } |
| |
| function f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative(in integer pl_idx, in EPTF_Var_DirectContent pl_content,in boolean pl_result, in EPTF_IntegerList pl_argList) runs on VariableTest_CT { |
| v_inc := 1; |
| if (pl_result) { |
| setverdict(fail, "Adjust-handler called valid response for invalid adjust call"); |
| } |
| action("my adjust handler_negative is called with idx: ",pl_idx," content: ",pl_content, " result: ",pl_result," args: ", pl_argList); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // test value change after owner value is adjusted |
| // adjust the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 1}); |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content after adjust 1: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 1}) { |
| setverdict(fail, "Invalid adjusted value received for the pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_CT_LogAll("Var dump: "); |
| |
| // test chained subscription of pull |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 1}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // check if sync time does not have any effect |
| timer t_waitForSync := vl_syncInterval*2.0; |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 2}); |
| action("No refresh should arrive during this period"); |
| t_waitForSync.start; |
| t_waitForSync.timeout; |
| action("End of period"); |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content of pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // check unsubscribe: |
| f_EPTF_Var_unsubscribe(vl_subscriber2_idx); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 3}); |
| |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after unsubscribe: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // resubscribe normally: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_subscriber2_idx |
| ); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after sampled resubscribe: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 3}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 3}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| |
| // resubscribe in pull mode: |
| f_EPTF_Var_unsubscribe(vl_subscriber2_idx); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 4}); |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx |
| ); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 4}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode resubscriber: ", vl_currentContent, ". Should be: {intVal := 4}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust pull mode subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx,{intVal := 5}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 2nd adjust pull mode subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx,{intVal := 6}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust pull mode chained subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber2_idx,{intVal := 7}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 7}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 7}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 2nd adjust pull mode chained subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber2_idx,{intVal := 8}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 8}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 8}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // test 3 chained subscription of pull |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_adjustContent(vl_subscriber3_idx,{intVal := 9}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 9}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode 3 chained subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 9}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content of subscriber3 after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 9}) { |
| setverdict(fail, "Invalid adjusted value for subscriber3 after pull mode 3 chained subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 9}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // handler test 3 chained subscription: |
| v_inc := 0; |
| f_EPTF_Var_adjustContent(vl_subscriber3_idx,{intVal := 10}, {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler), {1}}); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 10) { |
| setverdict(fail,"adjust handler was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| |
| // ------------- negative tests: ------------------- |
| |
| // request non-existent content: |
| if(f_EPTF_Var_getRemoteContent(self,"non-existent var", vl_currentContent)) { |
| setverdict(fail,"Successful getRemoteContent for non-existent variable"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust non-existent var: |
| v_inc:= 0; |
| f_EPTF_Var_adjustRemoteContent(self,"non-existent var", {intVal := 1}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_CT_LogAll("Var dump: "); |
| |
| f_EPTF_Base_stop(pass); |
| |
| } |
| |
| // same as tc_EPTF_Var_SubscribeTest_pull but no altstep is called after subscribe => get/adjustRemoteContent uses variable name |
| testcase tc_EPTF_Var_SubscribeTest_noAlt_pull() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_noAlt_pull"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // test value change after owner value is adjusted |
| // adjust the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 1}); |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content after adjust 1: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 1}) { |
| setverdict(fail, "Invalid adjusted value received for the pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_CT_LogAll("Var dump: "); |
| |
| // test chained subscription of pull |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 1}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 2}); |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content of pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // check unsubscribe: |
| f_EPTF_Var_unsubscribe(vl_subscriber2_idx); |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 3}); |
| |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after unsubscribe: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // resubscribe in pull mode: |
| f_EPTF_Var_unsubscribe(vl_subscriber2_idx); |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 4}); |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx |
| ); |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of chained pull after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 4}) { |
| setverdict(fail, "Invalid adjusted value received for the 2nd chained pull mode resubscriber: ", vl_currentContent, ". Should be: {intVal := 4}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust pull mode subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx,{intVal := 5}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 2nd adjust pull mode subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx,{intVal := 6}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust pull mode chained subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber2_idx,{intVal := 7}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 7}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 7}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // 2nd adjust pull mode chained subscriber, check provider: |
| f_EPTF_Var_adjustContent(vl_subscriber2_idx,{intVal := 8}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 8}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 8}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // test 3 chained subscription of pull |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| f_EPTF_Var_adjustContent(vl_subscriber3_idx,{intVal := 9}); |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_getContent(vl_provider_idx,vl_currentContent); |
| action("Current content of provider after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 9}) { |
| setverdict(fail, "Invalid adjusted value for provider after pull mode 3 chained subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 9}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content of subscriber3 after adjust: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 9}) { |
| setverdict(fail, "Invalid adjusted value for subscriber3 after pull mode 3 chained subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 9}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // handler test 3 chained subscription: |
| v_inc := 0; |
| f_EPTF_Var_adjustContent(vl_subscriber3_idx,{intVal := 10}, {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler), {1}}); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 10) { |
| setverdict(fail,"adjust handler was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| |
| // ------------- negative tests: ------------------- |
| |
| // request non-existent content: |
| if(f_EPTF_Var_getRemoteContent(self,"non-existent var", vl_currentContent)) { |
| setverdict(fail,"Successful getRemoteContent for non-existent variable"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust non-existent var: |
| v_inc:= 0; |
| f_EPTF_Var_adjustRemoteContent(self,"non-existent var", {intVal := 1}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_CT_LogAll("Var dump: "); |
| |
| f_EPTF_Base_stop(pass); |
| |
| } |
| |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_automaticRerouting() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_automaticRerouting"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_newInt("subscriber1",-1,vl_subscriber1_idx); |
| |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_newInt("subscriber2",-1,vl_subscriber2_idx); |
| |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_newInt("subscriber3",-1,vl_subscriber3_idx); |
| |
| var integer vl_subscriber4_idx; |
| f_EPTF_Var_newInt("subscriber4",-1,vl_subscriber4_idx); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber3", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber4_idx, |
| pl_localName := "subscriber4" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| // here the subscribed variables will have names in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with name refs: "); |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 1st subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 2nd subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 3rd subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have rerouted idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with refs after getContent: "); |
| |
| // wait to handle the subscribe msgs: |
| t_wait.start; t_wait.timeout; |
| |
| f_EPTF_Var_CT_LogAll("Var dump with refs after subscribe: "); |
| |
| // this should be done in one hop: |
| action("Next getContent should take one hop"); |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with id refs: "); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_automaticReroutingViaGetContent() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_automaticReroutingViaGetContent"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_newInt("subscriber1",-1,vl_subscriber1_idx); |
| |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_newInt("subscriber2",-1,vl_subscriber2_idx); |
| |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_newInt("subscriber3",-1,vl_subscriber3_idx); |
| |
| var integer vl_subscriber4_idx; |
| f_EPTF_Var_newInt("subscriber4",-1,vl_subscriber4_idx); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber3", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber4_idx, |
| pl_localName := "subscriber4" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| // here the subscribed variables will have names in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with name refs: "); |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have rerouted idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with id refs: "); |
| |
| // test rerouting (the getcontent should be done in one hop to provider): |
| // change the provider and subscriber3 vars (without updating their providers: i.e. use setContent instead of Adjust): |
| f_EPTF_Var_setContent(vl_provider_idx,{intVal := 3}); |
| f_EPTF_Var_setContent(vl_subscriber3_idx,{intVal := 2}); |
| // get the value of subscriber4 (subscriber of subscriber3, but now rerouted to provider): |
| action("Next getContent should take one hop"); |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 3}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 3}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_automaticReroutingAfterSubscribe() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_automaticReroutingAfterSubscribe"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| t_wait.start; t_wait.timeout; |
| f_EPTF_Var_CT_LogAll("Var dump after subscribe 1: "); |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| |
| t_wait.start; t_wait.timeout; |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| |
| t_wait.start; t_wait.timeout; |
| var integer vl_subscriber4_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber3", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber4_idx, |
| pl_localName := "subscriber4" |
| ); |
| |
| // wait to handle the subscribe msgs: |
| t_wait.start; t_wait.timeout; |
| |
| // here the subscribed variables will have rerouted idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with refs after subscribe: "); |
| |
| action("Next getContents should take one hop"); |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 3rd subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 2nd subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 1st subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have rerouted idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with id refs: "); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_automaticRerouting_RouteUpdate() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_automaticRerouting"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_newInt("subscriber1",-1,vl_subscriber1_idx); |
| |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_newInt("subscriber2",-1,vl_subscriber2_idx); |
| |
| var integer vl_subscriber3_idx; |
| f_EPTF_Var_newInt("subscriber3",-1,vl_subscriber3_idx); |
| |
| var integer vl_subscriber4_idx; |
| f_EPTF_Var_newInt("subscriber4",-1,vl_subscriber4_idx); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber3", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber4_idx, |
| pl_localName := "subscriber4" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber3_idx, |
| pl_localName := "subscriber3" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| // here the subscribed variables will have names in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with name refs: "); |
| |
| // test initial value |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content initial: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid initial value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 0}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have rerouted idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump with refs after getContent: "); |
| |
| // wait to handle the subscribe msgs: |
| t_wait.start; t_wait.timeout; |
| |
| f_EPTF_Var_CT_LogAll("Var dump with refs after subscribe: "); |
| |
| /////////////////////////////////////// |
| // CHANGE ROUTE TO DIFFERTENT PROVIDER: |
| /////////////////////////////////////// |
| |
| // update subscriptions, unsubscribe subscriber1 from the provider: |
| f_EPTF_Var_unsubscribe(vl_subscriber1_idx); |
| //create new provider var with new value: |
| var integer vl_provider2_idx; |
| f_EPTF_Var_newInt("provider2",2,vl_provider2_idx); |
| // subscribe subscriber1 to this: |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| |
| // change the value of the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx,{intVal := 1}); |
| |
| // wait to handle the subscribe msgs: |
| t_wait.start; t_wait.timeout; |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after resubscribe to new provider: "); |
| |
| // the cg_EPTF_Var_routeUpdatePeriod-1 getContent should show the provider2 value: |
| // start from 2: getContent was requested already before 1 times |
| for (var integer i:=2; i<cg_EPTF_Var_routeUpdatePeriod; i:=i+1) { |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content ",i,"th cycle: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 1}) { |
| setverdict(fail, "Invalid ",i,"th value received for the pull mode 4th subscriber before: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after 9 getContent: "); |
| |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content 10th cycle: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Route is not updated after 10 getContent cycle: Invalid 10th value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after 10th getContent: "); |
| |
| f_EPTF_Var_setContent(vl_provider2_idx, {intVal:=3}); |
| action("Next getContent should take one hop to provider2"); |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 3}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 3}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| //////////////// |
| // APPEND ROUTE: |
| //////////////// |
| var integer vl_provider2_parent_idx; |
| f_EPTF_Var_newInt("provider2_parent",5,vl_provider2_parent_idx); |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider2_parent", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_provider2_idx, |
| pl_localName := "provider2" |
| ); |
| |
| // wait to handle the subscribe msgs: |
| t_wait.start; t_wait.timeout; |
| |
| // here the subscribed variables will have idx to their previous providers (provider2: mtc,5), provider2 will have a provider as well: provider2_parent |
| f_EPTF_Var_CT_LogAll("Var dump after route append: "); |
| |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after route append: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Route is not updated after route append: Invalid value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after route append + get subscriber 4: "); |
| |
| f_EPTF_Var_setContent(vl_provider2_idx, {intVal:=4}); |
| action("Next getContent should take one hop to provider2_parent"); |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 4th subscriber after route append: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // request subscriber3 also: |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content after route append: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Route is not updated after route append: Invalid value received for the pull mode 3rd subscriber: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after route append + get subscriber 3: "); |
| |
| f_EPTF_Var_setContent(vl_provider2_idx, {intVal:=4}); |
| action("Next getContent should take one hop to provider2_parent"); |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 5}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 3rd subscriber after route append: ", vl_currentContent, ". Should be: {intVal := 5}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| //////////////// |
| // APPEND ROUTE - no subscribe: |
| //////////////// |
| var integer vl_provider2_parent2_idx; |
| f_EPTF_Var_newInt("provider2_parent2",6,vl_provider2_parent2_idx); |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider2_parent2", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_provider2_parent_idx, |
| pl_localName := "provider2_parent" |
| ); |
| |
| // do not wait to handle the subscribe msgs |
| |
| // here the subscribed variables will have idx to their previous providers (provider2: mtc,5), provider2 will have a provider as well: provider2_parent |
| f_EPTF_Var_CT_LogAll("Var dump after route append: "); |
| |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after route append: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Route is not updated after route append: Invalid value received for the pull mode 4th subscriber: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after route append + get subscriber 4: "); |
| |
| f_EPTF_Var_setContent(vl_provider2_parent_idx, {intVal:=4}); |
| action("Next getContent should take one hop to provider2_parent2"); |
| f_EPTF_Var_getContent(vl_subscriber4_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 4th subscriber after route append: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // request subscriber3 also: |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content after route append: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Route is not updated after route append: Invalid value received for the pull mode 3rd subscriber: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // here the subscribed variables will have idx in their providers |
| f_EPTF_Var_CT_LogAll("Var dump after route append + get subscriber 3: "); |
| |
| f_EPTF_Var_setContent(vl_provider2_parent_idx, {intVal:=4}); |
| action("Next getContent should take one hop to provider2_parent2"); |
| f_EPTF_Var_getContent(vl_subscriber3_idx,vl_currentContent); |
| action("Current content after reroute: ", vl_currentContent); |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Invalid rerouted value received for the pull mode 3rd subscriber after route append: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Base_stop(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) |
| 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; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| // adjust existent var with incompatibe content: |
| v_inc:= 0; |
| f_EPTF_Var_adjustRemoteContent(self,"subscriber1", {floatVal := 1.0}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| 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) |
| 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; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| // no alt is called here! |
| |
| // adjust existent var with incompatibe content: |
| v_inc:= 0; |
| f_EPTF_Var_adjustRemoteContent(self,"subscriber1", {floatVal := 1.0}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| 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) |
| 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; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| // adjust existent var with incompatibe content: |
| v_inc:= 0; |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx, {floatVal := 1.0}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| 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) |
| 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; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| // no alt is called here! |
| |
| // adjust existent var with incompatibe content: |
| v_inc:= 0; |
| f_EPTF_Var_adjustContent(vl_subscriber1_idx, {floatVal := 1.0}, |
| {refers(f_EPTF_Var_SubscribeTest_pull_adjustContent_handler_negative), {}} |
| ); |
| t_wait.start; t_wait.timeout; |
| if (v_inc != 1) { |
| setverdict(fail,"adjust handler_negative was not called, or was called with invalid args") |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Base_cleanup_CT() |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_chainedPullAndNonPull() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_chainedPullAndNonPull"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| var EPTF_Var_DirectContent vl_currentContent; |
| // f_EPTF_Var_getContent(vl_subscriber1_idx,vl_currentContent); |
| // timer t_waitForSync := vl_syncInterval*2.0; |
| // t_waitForSync.start; t_waitForSync.timeout; |
| |
| // subscribe in sampled mode to pull mode subscriber: |
| var integer vl_subscriber2_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "subscriber1", |
| pl_subscriptionMode := sampled, |
| pl_idx := vl_subscriber2_idx, |
| pl_localName := "subscriber2" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| // adjust the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx, {intVal := 2}); |
| t_wait.start; t_wait.timeout; |
| // request the sampled subscriber: |
| f_EPTF_Var_getContent(vl_subscriber2_idx,vl_currentContent); |
| action("Current content of subscriber2 after adjust: ", vl_currentContent); |
| // value should be the same |
| if (vl_currentContent != {intVal := 2}) { |
| setverdict(fail, "Invalid value for subscriber2 after pull mode and sampled mode chained subscriber adjust: ", vl_currentContent, ". Should be: {intVal := 2}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| testcase tc_EPTF_Var_SubscribeTest_pull_chainedLocal() runs on VariableTest_CT{ |
| f_EPTF_Var_init_CT("SubscribeTest_pull_chainedLocal"); |
| timer t_wait := 0.2; |
| |
| var integer vl_provider_idx; |
| f_EPTF_Var_newInt("provider",0,vl_provider_idx); |
| var float vl_syncInterval := 1.0; |
| f_EPTF_Var_setSyncInterval(vl_syncInterval); |
| |
| var integer vl_subscriber1_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := self, |
| pl_remoteProviderVarName := "provider", |
| pl_subscriptionMode := pull, |
| pl_idx := vl_subscriber1_idx, |
| pl_localName := "subscriber1" |
| ); |
| t_wait.start; t_wait.timeout; |
| |
| // local subscriber 1 with pull mode provider: |
| var integer vl_subscriberLocal1_idx; |
| f_EPTF_Var_newInt("localSubscriber1",0,vl_subscriberLocal1_idx); |
| f_EPTF_Var_subscribeLocal(vl_subscriberLocal1_idx,{{refers(f_calculationSum),{vl_provider_idx,vl_subscriber1_idx},{}}}); |
| |
| // ,ocal subscriber2 with local subsciber that has pull mode provider: |
| var integer vl_subscriberLocal2_idx; |
| f_EPTF_Var_newInt("localSubscriber2",0,vl_subscriberLocal2_idx); |
| f_EPTF_Var_subscribeLocal(vl_subscriberLocal2_idx,{{refers(f_calculationSum),{vl_subscriberLocal1_idx},{}}}); |
| |
| var EPTF_Var_DirectContent vl_currentContent; |
| |
| f_EPTF_Var_getContent(vl_subscriberLocal1_idx,vl_currentContent); |
| action("Current content of subscriberLocal1: ", vl_currentContent); |
| // value should be the same |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid value for subscriber1: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Var_getContent(vl_subscriberLocal2_idx,vl_currentContent); |
| action("Current content of subscriberLocal2: ", vl_currentContent); |
| // value should be the same |
| if (vl_currentContent != {intVal := 0}) { |
| setverdict(fail, "Invalid value for subscriber2: ", vl_currentContent, ". Should be: {intVal := 1}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| // adjust the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx, {intVal := 2}); |
| t_wait.start; t_wait.timeout; |
| // request the subscriberLocal1: |
| f_EPTF_Var_getContent(vl_subscriberLocal1_idx,vl_currentContent); |
| action("Current content of subscriberLocal1 after adjust: ", vl_currentContent); |
| // value should be the same |
| if (vl_currentContent != {intVal := 4}) { |
| setverdict(fail, "Invalid value for subscriberLocal1 after adjust: ", vl_currentContent, ". Should be: {intVal := 4}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| |
| // adjust the provider: |
| f_EPTF_Var_adjustContent(vl_provider_idx, {intVal := 3}); |
| t_wait.start; t_wait.timeout; |
| // request the subscriberLocal2: |
| f_EPTF_Var_getContent(vl_subscriberLocal2_idx,vl_currentContent); |
| action("Current content of subscriberLocal2 after adjust: ", vl_currentContent); |
| // value should be the same |
| if (vl_currentContent != {intVal := 6}) { |
| setverdict(fail, "Invalid value for subscriberLocal2 after adjust: ", vl_currentContent, ". Should be: {intVal := 6}"); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| } //group PullModeSubscription |
| |
| //========================================================================= |
| // Control Part |
| //========================================================================= |
| control { |
| |
| execute(tc_EPTF_Var_CreateAndModifyTest()); |
| execute(tc_EPTF_Var_SubscribeTest()); |
| execute(tc_EPTF_Var_SubscribeTestPull()); |
| execute(tc_EPTF_Var_AdjustTest()); |
| execute(tc_EPTF_Var_AdjustTestPull()); |
| execute(tc_EPTF_Var_UnsubscribeTest()); |
| execute(tc_EPTF_Var_GuardfunctionTest()); |
| execute(tc_EPTF_Var_CalculationfunctionTest()); |
| execute(tc_EPTF_Var_PostprocfunctionTest()); |
| execute(tc_EPTF_Var_BufferedTest()); |
| execute(tc_EPTF_Var_LongBufferedTest()); |
| execute(tc_EPTF_Var_ComplexSubscribeTest()); |
| execute(tc_EPTF_Var_ComplexAdjustTest()); |
| execute(tc_EPTF_Var_ComplexBufferedTest()); |
| execute(tc_EPTF_Var_ComplexDoubleBufferedTest()); |
| execute(tc_EPTF_Var_ComplexParalelSubscribeTest()); |
| execute(tc_EPTF_Var_ComplexParalelUnsubscribeTest()); |
| execute(tc_EPTF_Var_ComplexParalelAdjustTest()); |
| execute(tc_EPTF_Var_ComplexParalelBufferedTest()); |
| execute(tc_EPTF_Var_SimpleHashMapTest()); |
| execute(tc_EPTF_Var_getRemote()); |
| execute(tc_EPTF_Var_getRemote_local()); |
| { |
| execute(tc_EPTF_Var_adjustRemote_blocking()); |
| execute(tc_EPTF_Var_Test_directContent_EmptyOctetString()); |
| execute(tc_EPTF_Var_Test_directContent_unknownVal()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkPeriodLength()); |
| } |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_timelined()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_sampledAtSync()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_realtime()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_chained()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_sampledAtSync_chained()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_realtime_chained()); |
| execute(tc_EPTF_Var_Test_subscribeWithCustomPeriod_checkContentChange_timelined_chained()); |
| {//subscribeTimeouts |
| execute(tc_EPTF_Var_Test_subscribeTimeout()); |
| execute(tc_EPTF_Var_Test_resubscribeTimeout()); |
| execute(tc_EPTF_Var_Test_subscribeRefTimeout()); |
| } |
| execute(tc_EPTF_Var_Test_subscribeRemote_negative()); |
| execute(tc_EPTF_Var_Test_subscribeRemote_nonBlocking()); |
| execute(tc_EPTF_Var_Test_subscribeRemote_nonBlocking_parallel()); |
| |
| execute(tc_EPTF_Var_Test_subsCanAdjust_flagTest()); |
| execute(tc_EPTF_Var_Test_subsCanAdjust_adjustMainTest()); |
| execute(tc_EPTF_Var_Test_subsCanAdjust_adjustSubsTest()); |
| execute(tc_EPTF_Var_Test_subsCanAdjust_callBack()); |
| execute(tc_EPTF_Var_Test_maxWaitTimeForByeAck()); |
| |
| execute(tc_EPTF_Var_Test_toStringConversion()); |
| execute(tc_EPTF_Var_Test_fromStringConversion()); |
| execute(tc_EPTF_Var_Test_fromStringConversion_neg()); |
| execute(tc_EPTF_Var_Test_content2StrConversion()); |
| execute(tc_EPTF_Var_Test_str2contentConversion()); |
| execute(tc_EPTF_Var_Test_cleanupDuringSubscribe()); |
| execute(tc_EPTF_Var_Test_cleanupDuringConnectionSetup()); |
| |
| execute(tc_EPTF_Var_Test_adjustSubscribedVarsInPostproc()); |
| |
| execute(tc_EPTF_Var_Test_subscribeAfterBye()); |
| |
| execute(tc_EPTF_Var_Test_subscribeRealtimeToSameLocalVar()); |
| execute(tc_EPTF_Var_Test_subscribeNonRealtimeToSameLocalVar()); |
| execute(tc_EPTF_Var_Test_resubscribeToSameLocalVar()); |
| execute(tc_EPTF_Var_Test_reSubscribeLocal()); |
| |
| execute(tc_EPTF_Var_SubscribeTest_pull()); |
| execute(tc_EPTF_Var_SubscribeTest_noAlt_pull()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_automaticRerouting()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_automaticReroutingViaGetContent()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_automaticReroutingAfterSubscribe()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_automaticRerouting_RouteUpdate()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_with_adjustRemoteContent_negative()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_noAlt_with_adjustRemoteContent_negative()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_with_adjustContent_negative()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_noAlt_with_adjustContent_negative()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_chainedPullAndNonPull()); |
| execute(tc_EPTF_Var_SubscribeTest_pull_chainedLocal()); |
| } |
| |
| |
| } |