Commit 062a346e authored by ringst's avatar ringst
Browse files

group general_td_functions moved from Behavior module to Functions module

parent e094e3d9
Loading
Loading
Loading
Loading
+1 −143
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ module AtsImsIot_Behavior {
	
	import from LibIms_UpperTester {type ImsUserInfo;}

	import from LibIot_TypesAndValues {type DefaultList, SetFilterReq, SetFilterRsp;}
	import from LibIot_TypesAndValues {type SetFilterReq, SetFilterRsp;}
	import from LibIot_Functions {
		function f_setConformanceVerdict, f_setIotVerdictFAIL;
	}
@@ -32,148 +32,6 @@ module AtsImsIot_Behavior {
	import from AtsImsIot_Functions all;
	import from LibIot_PIXITS {modulepar PX_EUT_A, PX_EUT_B;}
		
	//TODO move group to Function module
	group general_td_functions {
	 	

		/**
         * @desc
         *     Generic function for reading and verifying messages on the
         *     interface associated to the ImsInterfaceMonitor instance. This
         *     functions works as follows: First, messages are skipped according
         *     to the p_skip template. The p_skip template contains a message
         *     template and a counter indicating the number of received messages
         *     matching the message template to be skipped. If not enough
         *     messages matching the message template arrive at the interface,
         *     the function fails after timout. Next, messages are consumed from
         *     the interface and matched against the p_passCriteria template
         *     list and the p_failCriteria template list. The function
         *     terminates with pass if a message is received matching a
         *     pass-template and terminates with fail if a fail-template
         *     matches. Matching against pass-templates occurs bevor matching
         *     agains fail-templates. If neither pass-templates nor
         *     fail-templates match, then the functions continues reading from
         *     the interface until a match arises, or timeout. The timeout value
         *     is given by PX_MAX_MSG_WAIT [5.0 seconds, FFS]. Finally, if
         *     p_forwardMtc is set to true, the last received message is stored
         *     to be fetched and used later by the main test component. Some
         *     special use cases: - Set p_skip.skipCounter to 0 to avoid
         *     skipping, i.e. no skippin - Set p_skip.skipCounter to 0 and
         *     p_skip.skipMessage to ? to skip exactly one message of any type
         *     will be skipped. - If the list of fail-templates is empty, then
         *     the function will wait for the first message maching a
         *     pass-message, or fail after timeout.
         * @param p_passCriteria list of message templates which lead to pass
         * @param p_failCriteria list of message templates which lead to fail
         * @param p_skip
         *     Indicate how many messages from a specific sip template should be
         *     skipped prior to checking
         * @param p_tpId The Test Purpose identifier
         * @param p_forwardMtc
         *     indicate if the received Sip message should be forwarded to the
         *     mtc
         * @param p_checkMessage
         *     indicate if the incomming message should only be checked
         *     (port.check) or consumed (port.receive). The check operation
         *     allows read access to the top element of incoming port queues
         *     without removing the top element from the queue.
         */     
        function f_imsIot_receive( 
          in template SipMessageList p_passCriteria,
          in template SipMessageList p_failCriteria,
          in template SkipType p_skip,
          in charstring p_tpId,
          in boolean p_forwardMtc,
          in boolean p_checkMessage
        ) runs on ImsInterfaceMonitor { 

            var integer v_size := lengthof(p_failCriteria); 
            var DefaultList v_defaultArray;

            v_defaultArray[0] := activate(a_default(p_tpId));
            f_activateImsSipDefaults(v_defaultArray, 1, p_failCriteria, fail, p_tpId, p_forwardMtc, p_checkMessage);
            f_activateImsSipDefaults(v_defaultArray, v_size + 1, p_passCriteria, pass, p_tpId, p_forwardMtc, p_checkMessage);

			f_gen_receive(p_tpId, p_skip);

			for (var integer i := 0; i < sizeof(v_defaultArray); i := i + 1) {
                deactivate(v_defaultArray[i]);
            }
		}
		
		/**
         * @desc This function implements skipping of messages as well as timeout handling.
		 *       Prior to calling this function the message to be cheked for should be added
		 *       as defaults.
		 *       This function is independent of a specific interface component.
         * @param p_tpId The Test Purpose identifier
         * @param p_skipCount Indicate how many messages should be skipped prior to checking
         */     
        function f_gen_receive( 
          in charstring p_tpId,
          in template SkipType p_skip
        ) runs on ImsInterfaceMonitor {
            var integer skipCount := valueof(p_skip.skipCount);
			tc_wait.start;
            
            alt {
            	// preamble (consume prior messages)
            	[skipCount > 0 and ischosen(p_skip.skipMessage.request)] dPort.receive (p_skip.skipMessage.request) {
            		skipCount := skipCount - 1;
            		log("***f_gen_receive: Message skipped (intentionally) when checking for " & p_tpId & " at interface " & vc_interfaceName & " ****");
            		repeat;
            	}
            	[skipCount > 0 and ischosen(p_skip.skipMessage.response)] dPort.receive (p_skip.skipMessage.response) {
            		skipCount := skipCount - 1;
            		log("***f_gen_receive: Message skipped (intentionally) when checking for " & p_tpId & " at interface " & vc_interfaceName & " ****");
            		repeat;
            	}
	            [] tc_wait.timeout {
	            	f_setConformanceVerdict(inconc, "***f_gen_receive: Timer tc_wait expired when waiting for incoming message in " & p_tpId & " at interface " & vc_interfaceName & " ****");
	            }
            }
            
        }
        
		/**
		* @desc Activates for each entry in a expected IMS SIP message list a default 
		*       for receiving that message and setting the verdict as desired
		* @param p_default Reference to default array where deaults are to be added
		* @param p_startIdx Index into default array after which references for 
		*                   defaults created in this function should be added
		* @param p_list List of expected messages to be checked in default
		* @param p_verdict Verdict to be set in case the incoming message matches 
		                   any of the expcted messages 
		* @param p_tpId Test Purpose identifir
		*/
		function f_activateImsSipDefaults(
			inout DefaultList p_default,
			in integer p_startIdx,
			in template SipMessageList p_list,
			in verdicttype p_verdict,
			in charstring p_tpId,
			in boolean p_forwardMtc,
			in boolean p_checkMessage
		) runs on ImsInterfaceMonitor {
			var integer v_size := lengthof(p_list); 
			var integer v_idx := p_startIdx;

			for (var integer i := 0; i < v_size; i := i + 1) {
				if (ischosen(p_list[i].request)) {
					p_default[v_idx] := activate(
						a_receive_sipRequest(p_list[i].request,p_verdict, p_tpId, p_forwardMtc, p_checkMessage)
					);
				} else {
					p_default[v_idx] := activate(
						a_receive_sipResponse(p_list[i].response,p_verdict, p_tpId, p_forwardMtc, p_checkMessage)
					);
				}
				v_idx := v_idx + 1;
			}
		}
        
	}//end group
		
	group altsteps {
		
		altstep a_default(in charstring p_TP) runs on ImsInterfaceMonitor {
+158 −5
Original line number Diff line number Diff line
@@ -7,14 +7,24 @@ module AtsImsIot_Functions {
 
 	import from AtsImsIot_Templates {template mw_SIP_URI_Base;}

 	import from LibSip_SIPTypesAndValues {type SipUrl;}
 	import from LibSip_SIPTypesAndValues all;

 	import from AtsImsIot_TestSystem {type ImsTestCoordinator;}
 	import from AtsImsIot_TestSystem {
 		type ImsTestCoordinator, ImsInterfaceMonitor;
 	}
 	
 	import from LibIot_PIXITS {modulepar PX_MAX_MSG_WAIT, PX_PRODUCTS;}
 	import from AtsImsIot_Behavior {
 		altstep a_default, a_receive_sipRequest, a_receive_sipResponse;
 	}

 	import from AtsImsIot_TypesAndValues {type SipMessage;}
 	import from LibIot_PIXITS {modulepar PX_MAX_MSG_WAIT, PX_PRODUCTS;}
	import from LibIot_Functions {
		function f_setConformanceVerdict;
	}
	
 	import from AtsImsIot_TypesAndValues {
 		type SipMessage, SipMessageList, SkipType;
 	}

 	import from LibIms_UpperTester all;

@@ -24,6 +34,8 @@ module AtsImsIot_Functions {
 	
 	import from LibIot_Functions {function f_getE2EVerdict;}

	import from LibIot_TypesAndValues {type DefaultList;}
 	
 	group ue {
 		
 		/**
@@ -900,6 +912,147 @@ module AtsImsIot_Functions {
        }	
 	}
 	
	group general_td_functions {

		/**
         * @desc
         *     Generic function for reading and verifying messages on the
         *     interface associated to the ImsInterfaceMonitor instance. This
         *     functions works as follows: First, messages are skipped according
         *     to the p_skip template. The p_skip template contains a message
         *     template and a counter indicating the number of received messages
         *     matching the message template to be skipped. If not enough
         *     messages matching the message template arrive at the interface,
         *     the function fails after timout. Next, messages are consumed from
         *     the interface and matched against the p_passCriteria template
         *     list and the p_failCriteria template list. The function
         *     terminates with pass if a message is received matching a
         *     pass-template and terminates with fail if a fail-template
         *     matches. Matching against pass-templates occurs bevor matching
         *     agains fail-templates. If neither pass-templates nor
         *     fail-templates match, then the functions continues reading from
         *     the interface until a match arises, or timeout. The timeout value
         *     is given by PX_MAX_MSG_WAIT [5.0 seconds, FFS]. Finally, if
         *     p_forwardMtc is set to true, the last received message is stored
         *     to be fetched and used later by the main test component. Some
         *     special use cases: - Set p_skip.skipCounter to 0 to avoid
         *     skipping, i.e. no skippin - Set p_skip.skipCounter to 0 and
         *     p_skip.skipMessage to ? to skip exactly one message of any type
         *     will be skipped. - If the list of fail-templates is empty, then
         *     the function will wait for the first message maching a
         *     pass-message, or fail after timeout.
         * @param p_passCriteria list of message templates which lead to pass
         * @param p_failCriteria list of message templates which lead to fail
         * @param p_skip
         *     Indicate how many messages from a specific sip template should be
         *     skipped prior to checking
         * @param p_tpId The Test Purpose identifier
         * @param p_forwardMtc
         *     indicate if the received Sip message should be forwarded to the
         *     mtc
         * @param p_checkMessage
         *     indicate if the incomming message should only be checked
         *     (port.check) or consumed (port.receive). The check operation
         *     allows read access to the top element of incoming port queues
         *     without removing the top element from the queue.
         */     
        function f_imsIot_receive( 
          in template SipMessageList p_passCriteria,
          in template SipMessageList p_failCriteria,
          in template SkipType p_skip,
          in charstring p_tpId,
          in boolean p_forwardMtc,
          in boolean p_checkMessage
        ) runs on ImsInterfaceMonitor { 

            var integer v_size := lengthof(p_failCriteria); 
            var DefaultList v_defaultArray;

            v_defaultArray[0] := activate(a_default(p_tpId));
            f_activateImsSipDefaults(v_defaultArray, 1, p_failCriteria, fail, p_tpId, p_forwardMtc, p_checkMessage);
            f_activateImsSipDefaults(v_defaultArray, v_size + 1, p_passCriteria, pass, p_tpId, p_forwardMtc, p_checkMessage);

			f_gen_receive(p_tpId, p_skip);

			for (var integer i := 0; i < sizeof(v_defaultArray); i := i + 1) {
                deactivate(v_defaultArray[i]);
            }
		}
		
		/**
         * @desc This function implements skipping of messages as well as timeout handling.
		 *       Prior to calling this function the message to be cheked for should be added
		 *       as defaults.
		 *       This function is independent of a specific interface component.
         * @param p_tpId The Test Purpose identifier
         * @param p_skipCount Indicate how many messages should be skipped prior to checking
         */     
        function f_gen_receive( 
          in charstring p_tpId,
          in template SkipType p_skip
        ) runs on ImsInterfaceMonitor {
            var integer skipCount := valueof(p_skip.skipCount);
			tc_wait.start;
            
            alt {
            	// preamble (consume prior messages)
            	[skipCount > 0 and ischosen(p_skip.skipMessage.request)] dPort.receive (p_skip.skipMessage.request) {
            		skipCount := skipCount - 1;
            		log("***f_gen_receive: Message skipped (intentionally) when checking for " & p_tpId & " at interface " & vc_interfaceName & " ****");
            		repeat;
            	}
            	[skipCount > 0 and ischosen(p_skip.skipMessage.response)] dPort.receive (p_skip.skipMessage.response) {
            		skipCount := skipCount - 1;
            		log("***f_gen_receive: Message skipped (intentionally) when checking for " & p_tpId & " at interface " & vc_interfaceName & " ****");
            		repeat;
            	}
	            [] tc_wait.timeout {
	            	f_setConformanceVerdict(inconc, "***f_gen_receive: Timer tc_wait expired when waiting for incoming message in " & p_tpId & " at interface " & vc_interfaceName & " ****");
	            }
            }
            
        }
        
		/**
		* @desc Activates for each entry in a expected IMS SIP message list a default 
		*       for receiving that message and setting the verdict as desired
		* @param p_default Reference to default array where deaults are to be added
		* @param p_startIdx Index into default array after which references for 
		*                   defaults created in this function should be added
		* @param p_list List of expected messages to be checked in default
		* @param p_verdict Verdict to be set in case the incoming message matches 
		                   any of the expcted messages 
		* @param p_tpId Test Purpose identifir
		*/
		function f_activateImsSipDefaults(
			inout DefaultList p_default,
			in integer p_startIdx,
			in template SipMessageList p_list,
			in verdicttype p_verdict,
			in charstring p_tpId,
			in boolean p_forwardMtc,
			in boolean p_checkMessage
		) runs on ImsInterfaceMonitor {
			var integer v_size := lengthof(p_list); 
			var integer v_idx := p_startIdx;

			for (var integer i := 0; i < v_size; i := i + 1) {
				if (ischosen(p_list[i].request)) {
					p_default[v_idx] := activate(
						a_receive_sipRequest(p_list[i].request,p_verdict, p_tpId, p_forwardMtc, p_checkMessage)
					);
				} else {
					p_default[v_idx] := activate(
						a_receive_sipResponse(p_list[i].response,p_verdict, p_tpId, p_forwardMtc, p_checkMessage)
					);
				}
				v_idx := v_idx + 1;
			}
		}
        
	}//end group
 	
 	
 	group misc {
 		
 		/**