| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2017 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 Transport_Demo |
| { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_CLL_TransportCommPortIPL4_Definitions all; |
| //import from EPTF_CLL_TransportCommPortUDP_Definitions all; |
| import from EPTF_CLL_TransportMessageBufferManager_Definitions all; |
| import from EPTF_CLL_TransportMessageBufferManager_Functions all; |
| //import from EPTF_CLL_FBQ_Functions all; |
| import from EPTF_CLL_TransportRouting_Definitions all; |
| import from EPTF_CLL_TransportRouting_Functions all; |
| import from EPTF_CLL_TransportCommPortIPL4_Functions all; |
| //import from EPTF_CLL_TransportCommPortUDP_Functions all; |
| import from IPL4asp_Types all; |
| //import from UDPasp_Types all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_TransportIPL2_Definitions all; |
| import from EPTF_CLL_TransportIPL2_Functions all; |
| import from EPTF_CLL_Transport_CommonDefinitions all; |
| |
| modulepar { |
| charstring tsp_LocalHostIP := "localhost" |
| charstring tsp_RemoteHostIP := "localhost" |
| integer tsp_LocalHostPort := 10005 |
| integer tsp_RemoteHostPort := 10006 |
| } |
| |
| type component IPL4Demo_CT extends EPTF_CommPort_IPL4_CT { |
| |
| } |
| |
| type component IPL2Demo_CT extends EPTF_TransportIPL2_CT { |
| |
| } |
| |
| // type component UDPDemo_CT extends EPTF_CommPort_UDP_CT { |
| // |
| // } |
| |
| type component MessageBufferDemo_CT extends EPTF_MessageBufferManager_CT { |
| |
| } |
| type component RoutingDemo_CT extends EPTF_Routing_CT { |
| |
| } |
| |
| function f_DemoOutgoingMessageProcess() runs on RoutingDemo_CT |
| { |
| log("Outgoing Message Process function called!"); |
| } |
| |
| function f_DemoIncomingMessageProcess() runs on RoutingDemo_CT |
| { |
| log("Incoming Message Process function called!"); |
| } |
| |
| // function f_DemoUDPReceive(in octetstring pl_message) runs on UDPDemo_CT |
| // { |
| // log("UDP Message received!: ",pl_message); |
| // } |
| |
| function f_DemoIPL4Receive() runs on IPL4Demo_CT |
| { |
| log("IPL4 Message received!"); |
| log("The received message is: ", v_EPTF_CommPort_IPL4_incomingMessage); |
| log("The connid is: ",v_EPTF_CommPort_IPL4_incomingMessage.asp_RecvFrom.connId); |
| } |
| |
| function f_DemoIPL4ReceiveEvent() runs on IPL4Demo_CT |
| { |
| log("IPL4 Event Message received!"); |
| } |
| |
| testcase tc_IPL4Component() runs on IPL4Demo_CT { |
| timer t_wait := 2.0; |
| |
| f_EPTF_CommPort_IPL4_init({}); |
| |
| var template EPTF_CommPort_IPL4_IncomingMessage vl_template:= { |
| asp_RecvFrom := ? |
| }; |
| |
| f_EPTF_CommPort_IPL4_setReceive(vl_template,refers(f_DemoIPL4Receive)); |
| |
| vl_template:= { |
| asp_Event := ? |
| }; |
| |
| f_EPTF_CommPort_IPL4_setReceive(vl_template,refers(f_DemoIPL4ReceiveEvent)); |
| |
| |
| var EPTF_CommPort_IPL4_ASP_OutgoingMessage vl_connectMessage; |
| var Result vl_result; |
| |
| vl_connectMessage := { |
| asp_Connect := { |
| remName := tsp_RemoteHostIP, |
| remPort := tsp_RemoteHostPort, |
| locName := tsp_LocalHostIP, |
| locPort := tsp_LocalHostPort, |
| proto := {tcp := {}} |
| } |
| } |
| |
| vl_result := f_EPTF_CommPort_IPL4_send(vl_connectMessage); |
| if (not ispresent(vl_result.os_error_text)) { |
| if (vl_result.connId > 0){ |
| var EPTF_CommPort_IPL4_ASP_OutgoingMessage vl_sendMessage := { |
| asp_Send := |
| { connId := vl_result.connId, |
| proto := {tcp := {}}, |
| msg := char2oct("Hello") |
| } |
| } |
| |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| |
| f_EPTF_CommPort_IPL4_send(vl_sendMessage); |
| } |
| |
| |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| |
| var EPTF_CommPort_IPL4_ASP_OutgoingMessage vl_closeMessage := { |
| asp_Close := { |
| id := v_EPTF_CommPort_IPL4_incomingMessage.asp_RecvFrom.connId, |
| proto := {tcp := {}} |
| } |
| } |
| |
| f_EPTF_CommPort_IPL4_send(vl_closeMessage); |
| } |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| |
| |
| } |
| |
| // testcase tc_UDPComponent() runs on UDPDemo_CT { |
| // timer t_wait := 2.0; |
| // |
| // f_EPTF_CommPort_UDP_init_CT("test") |
| // |
| // f_EPTF_CommPort_UDP_setReceive(ASP_UDP:?,refers(f_DemoUDPReceive)); |
| // |
| // var PDU_UDP pl_data; |
| // pl_data := char2oct("Hello"); |
| // |
| // |
| // f_EPTF_CommPort_UDP_send(pl_data); |
| // |
| // t_wait.start; |
| // t_wait.timeout; |
| // t_wait.stop; |
| // |
| // f_EPTF_Base_cleanup_CT(); |
| // |
| // setverdict(pass); |
| // } |
| |
| function f_DemoIPL2Receive( |
| in EPTF_Transport_TransportType pl_transportType, |
| in integer pl_connId, |
| in charstring pl_remHost, |
| in integer pl_remPort, |
| in charstring pl_locHost, |
| in integer pl_locPort, |
| in ProtoTuple pl_proto, |
| in integer pl_userData, |
| in octetstring pl_msg |
| ) runs on IPL2Demo_CT |
| { |
| log("IPL2 Message received!"); |
| // log("The received message is: ", v_EPTF_CommPort_IPL4_incomingMessage); |
| // log("The connid is: ",v_EPTF_CommPort_IPL4_incomingMessage.asp_RecvFrom.connId); |
| } |
| |
| function f_DemoIPL2ReceiveEvent( |
| in EPTF_Transport_TransportType pl_transportType, |
| in ConnectionId pl_connId, |
| in ASP_Event pl_event) runs on IPL2Demo_CT |
| { |
| log("IPL2 Event Message received!"); |
| } |
| |
| testcase tc_IPL2Component() runs on IPL2Demo_CT { |
| timer t_wait := 2.0; |
| var integer vl_connId; |
| var integer vl_listenId, vl_osError; |
| var boolean vl_res; |
| var Result vl_result; |
| var octetstring vl_Msg; |
| |
| EPTF_CLL_TransportIPL2_Functions.f_EPTF_Transport_init(IPL2,"EPTF_Transport_Test"); |
| EPTF_CLL_TransportIPL2_Functions.f_EPTF_Transport_registerMsgCallback( |
| IPL2, |
| "type0", |
| refers(f_DemoIPL2Receive), |
| refers(f_DemoIPL2ReceiveEvent) ); |
| |
| vl_connId := EPTF_CLL_TransportIPL2_Functions.f_EPTF_Transport_connect ( |
| IPL2, |
| {udp := {}}, |
| tsp_LocalHostIP, |
| tsp_LocalHostPort, |
| tsp_RemoteHostIP, |
| tsp_RemoteHostPort, |
| "type0", |
| vl_result, |
| true |
| ); |
| |
| if (not ispresent(vl_result.os_error_text)) { |
| if (vl_connId >= 0){ |
| |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| |
| EPTF_CLL_TransportIPL2_Functions.f_EPTF_Transport_send( IPL2, vl_connId, '1122'O, vl_result); |
| |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| |
| EPTF_CLL_TransportIPL2_Functions.f_EPTF_Transport_close ( IPL2, vl_connId, vl_result); |
| |
| t_wait.start(2.0); |
| t_wait.timeout; |
| t_wait.stop; |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| |
| } |
| |
| |
| |
| |
| testcase tc_MessageBuffer() runs on MessageBufferDemo_CT { |
| var octetstring vl_message; |
| var charstring vl_information; |
| |
| f_EPTF_MessageBufferManager_init_CT(); |
| |
| f_EPTF_MessageBufferManager_setMessageToBuffer(char2oct("Demo1"),"DemoTestcase1",1); |
| f_EPTF_MessageBufferManager_setMessageToBuffer(char2oct("Demo2"),"DemoTestcase2",2); |
| f_EPTF_MessageBufferManager_setMessageToBuffer(char2oct("Demo3"),"DemoTestcase3",3); |
| |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| |
| f_EPTF_MessageBufferManager_getMessageFromBuffer(2,vl_message,vl_information); |
| log("The message and the information are: ",vl_message," ",vl_information); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| f_EPTF_MessageBufferManager_getMessageFromBuffer(1,vl_message,vl_information); |
| log("The message and the information are: ",vl_message," ",vl_information); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| f_EPTF_MessageBufferManager_setMessageToBuffer(char2oct("Demo1"),"DemoTestcase1",1); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| f_EPTF_MessageBufferManager_setMessageToBuffer(char2oct("Demo2"),"DemoTestcase2",2); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| f_EPTF_MessageBufferManager_getMessageFromBuffer(3,vl_message,vl_information); |
| |
| log("The message and the information are: ",vl_message," ",vl_information); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| |
| f_EPTF_MessageBufferManager_getMessageFromBuffer(2,vl_message,vl_information); |
| log("The message and the information are: ",vl_message," ",vl_information); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| f_EPTF_MessageBufferManager_getMessageFromBuffer(1,vl_message,vl_information); |
| log("The message and the information are: ",vl_message," ",vl_information); |
| // log("The messages are:", v_EPTF_MessageBufferManager_messages); |
| |
| |
| // log("The length of the free chain is: ",f_EPTF_FBQ_getLengthOfFreeChain(v_EPTF_MessageBufferManager_messageFreeBusyQueue)); |
| // log("The length of the busy chain is: ",f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_MessageBufferManager_messageFreeBusyQueue)); |
| |
| |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| testcase tc_Routing() runs on RoutingDemo_CT { |
| f_EPTF_Routing_init_CT(refers(f_DemoOutgoingMessageProcess),refers(f_DemoIncomingMessageProcess)); |
| |
| f_EPTF_Routing_processIncomingMessage(); |
| |
| f_EPTF_Routing_processOutgoingMessage(); |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| } |
| |
| control { |
| execute(tc_IPL4Component()); |
| execute(tc_IPL2Component()); |
| execute(tc_MessageBuffer()); |
| execute(tc_Routing()); |
| |
| } |
| |
| } // end of module |