LibS1AP_Steps.ttcn 12.2 KB
Newer Older
garciay's avatar
garciay committed
 *    @author   ETSI / STF519
 *    @version  $URL:$
 *              $Id:$
 *    @desc     This module provides functions used in S1AP.
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
 *    @see      ETSI TS 136 413 / 3GPP TS 36.413 version 13.4.0 Release 13
garciay's avatar
garciay committed
module LibS1AP_Steps {
    
    //LibCommon
    import from LibCommon_Sync all;
garciay's avatar
garciay committed
    import from LibCommon_VerdictControl all;
    import from LibCommon_BasicTypesAndValues all;
garciay's avatar
garciay committed
    // LibS1AP
    import from S1AP_PDU_Descriptions language "ASN.1:1997" all;
garciay's avatar
garciay committed
    import from LibS1AP_Interface all;
    import from LibS1AP_Pixits all;
    import from LibS1AP_Templates all;
    
    group CommonFunctions{
    
        /**
        *
        * @desc  f_gtZero, return true if value of p_int greater than 0
        * @param p_int - integer value
        */
garciay's avatar
garciay committed
        function f_gtZero(
                          in integer p_int
        ) return boolean {
            if (p_int > 0){
                return true;
            }
            else{
                return false;
            }
garciay's avatar
garciay committed
        } // End of function f_gtZero
        
garciay's avatar
garciay committed
         * @desc  f_Inc, return incremented value of p_int 0
         * @param p_int - integer value
         */
        function f_inc(
                       inout UInt32 p_int
        ) return UInt32 {
            p_int:=p_int + 1;
            return p_int;
garciay's avatar
garciay committed
        } // End of function f_inc
        
    } // End of group CommonFunctions
    
    group ReceivePDU {
garciay's avatar
garciay committed
        
garciay's avatar
garciay committed
         *  @desc    This is a test step that assign common S1AP
         *  @param
         */
        function f_S1APPDU_Get(
                               inout S1AP_PDU p_PDU
        ) runs on S1APComponent {
            
            vc_recvS1AP_PDU := p_PDU;
            
            if (ischosen(p_PDU.initiatingMessage)) {
                //TODO...
            }
            if (ischosen(p_PDU.successfulOutcome)) {
                //TODO...
            }
            if (ischosen(p_PDU.unsuccessfulOutcome)) {
                 //TODO...
            }
        } // End of function f_S1APPDU_Get
        
        /**
         *
         * @desc receive S1AP PDU
         * @param p_PDU template of the message to be received
         */
        function f_recv_S1AP_PDU(
                                 in template S1AP_PDU p_PDU
        ) runs on S1APComponent {
            var S1AP_PDU v_PDU;
garciay's avatar
garciay committed
            
            tc_wait.start;
garciay's avatar
garciay committed
            alt {
                [] S1_MMEeNB_P.receive(p_PDU) -> value v_PDU {
                    tc_wait.stop;
garciay's avatar
garciay committed
                    f_S1APPDU_Get(v_PDU)
                }
                [] tc_wait.timeout {
                    setverdict(inconc,"*** " & __SCOPE__ & ": INCONC: Message was not received in due time. ***");
garciay's avatar
garciay committed
                    //Stop the component in case of timeout
                    all timer.stop;
                    f_componentStop();
                }
garciay's avatar
garciay committed
            }
            
        } // End of function f_recv_S1AP_PDU
garciay's avatar
garciay committed
        /**
         * @desc 
         * @param p_initiatingMessage
         * @verdict 
         */
        function f_recv_S1AP_initiatingMessage(
                                               template (present)InitiatingMessage p_initiatingMessage
        ) runs on S1APComponent {
            f_recv_S1AP_PDU( {initiatingMessage := p_initiatingMessage})
garciay's avatar
garciay committed
        } // End of function f_recv_S1AP_initiatingMessage
        
        /**
         * @desc 
         * @param p_successfulOutcome
         * @verdict 
         */
        function f_recv_S1AP_successfulOutcome(
                                               template (present)SuccessfulOutcome p_successfulOutcome
        ) runs on S1APComponent {
            f_recv_S1AP_PDU( {successfulOutcome := p_successfulOutcome})
garciay's avatar
garciay committed
        } // End of f_recv_S1AP_successfulOutcome
        
        /**
         * @desc 
         */
        function f_recv_S1AP_unsuccessfulOutcome(
                                                 template (present) UnsuccessfulOutcome p_unsuccessfulOutcome
        ) runs on S1APComponent {
            f_recv_S1AP_PDU( {unsuccessfulOutcome := p_unsuccessfulOutcome})
garciay's avatar
garciay committed
        } // End of function f_recv_S1AP_unsuccessfulOutcome
garciay's avatar
garciay committed
    } // End of group ReceivePDU
garciay's avatar
garciay committed
    group SendPDU {
        
garciay's avatar
garciay committed
         *  @desc    This is a test step that assign common S1AP
         *  @param
         */
        function f_S1APPDU_Set(
                               inout template (value) S1AP_PDU p_PDU
        ) runs on S1APComponent {
            
            if (ischosen(p_PDU.initiatingMessage)) {
                //TODO...
                vc_sendS1AP_PDU:=valueof(p_PDU);
            }
garciay's avatar
garciay committed
            if (ischosen(p_PDU.successfulOutcome)) {
                //TODO...
                vc_sendS1AP_PDU:=valueof(p_PDU);
            }
garciay's avatar
garciay committed
            if (ischosen(p_PDU.unsuccessfulOutcome)) {
                 //TODO...
                 vc_sendS1AP_PDU:=valueof(p_PDU);
            }
garciay's avatar
garciay committed
            
        } // End of function f_S1APPDU_Set
    
        /**
        *
        * @desc  send S1AP PDU
        * @param p_PDU template of the message to be sent
        */
garciay's avatar
garciay committed
        function f_send_S1AP_PDU(
                                 in template (value) S1AP_PDU p_PDU
        ) runs on S1APComponent {
            f_S1APPDU_Set(p_PDU);
            S1_MMEeNB_P.send(p_PDU);
garciay's avatar
garciay committed
        } // End of function f_send_S1APPDU
        
        /**
         * @desc 
         */
        function f_send_S1AP_initiatingMessage(
                                               in template (value) InitiatingMessage p_initiatingMessage
        ) runs on S1APComponent {
            f_send_S1AP_PDU( {initiatingMessage := p_initiatingMessage})
garciay's avatar
garciay committed
        } // End of function f_send_S1AP_initiatingMessage
garciay's avatar
garciay committed
        /**
         * @desc 
         */
        function f_send_S1AP_successfulOutcome(
                                               in template (value) SuccessfulOutcome p_successfulOutcome
		) runs on S1APComponent {
            f_send_S1AP_PDU( {successfulOutcome := p_successfulOutcome})
garciay's avatar
garciay committed
        } // End of function f_send_S1AP_successfulOutcome
garciay's avatar
garciay committed
        /**
         * @desc 
         */
        function f_send_S1AP_unsuccessfulOutcome(
                                                 in template (value)UnsuccessfulOutcome p_unsuccessfulOutcome
		) runs on S1APComponent {
            f_send_S1AP_PDU( {unsuccessfulOutcome := p_unsuccessfulOutcome})
garciay's avatar
garciay committed
        } // End of function f_send_S1AP_unsuccessfulOutcome 
garciay's avatar
garciay committed
    } // End of group SendPDU

    group GlobalSteps{
        
        /**
        *  @desc    This is a test step that init S1AP component
        *  @param
        */
        function f_S1AP_Init_Component()
        runs on S1APComponent {
garciay's avatar
garciay committed
            
        } // End of function  f_S1AP_Init_Component
        
        /**
        *
        * @desc component termination
        */
        function f_S1AP_terminate_component()
        runs on S1APComponent {
            
            log("component terminated - forced!");
            deactivate;
            stop;
garciay's avatar
garciay committed
        } // End of function f_S1AP_terminate_component
    
        /**
        * @desc component termination
        */
        function f_componentStop()
        runs on S1APComponent {
            
            syncPort.send(m_syncClientStop);
            S1_MMEeNB_P.clear;
            stop;
garciay's avatar
garciay committed
        } // End of function f_componentStop
    
        /**
        *
        * @desc original copied from older LibCommon_VerdictControl
        */
        function f_getVerdict()
        return FncRetCode {
            
            var FncRetCode v_ret := e_error;
garciay's avatar
garciay committed
            if (getverdict == pass or getverdict == none) {
                v_ret := e_success;
            }
            return v_ret;
        } // End of function 
    
        /**
        * 
        * @desc function waits for particular time before next expected message
        */    
garciay's avatar
garciay committed
        function f_wait(float p_time) // TODO Replace by LibCommon.f_sleep
        runs on S1APComponent {
            
            tc_wait.start(p_time);
            alt {
garciay's avatar
garciay committed
                [] tc_wait.timeout{ }
garciay's avatar
garciay committed
        } // End of function f_wait
    
    } // End of group GlobalSteps
    
    group Preambles {
garciay's avatar
garciay committed
    	
        group preamble_S1AP{
garciay's avatar
garciay committed
            
            /**
             * @desc 
             * @verdict 
             */
            function f_preambleS1AP_MME()
            runs on S1APComponent {
                //TODO:...        
garciay's avatar
garciay committed
            } // End of function f_preambleS1AP_MME
garciay's avatar
garciay committed
            /**
             * @desc 
             * @verdict 
             */
            function f_preambleS1AP_eNB()
            runs on S1APComponent {
                //TODO:...        
garciay's avatar
garciay committed
            } // End of function f_preambleS1AP_eNB
            
        } // End of group preamble_S1AP
        
    } // End of group Preambles
    
    group Postambles {
garciay's avatar
garciay committed
        
        group postamble_S1AP{
garciay's avatar
garciay committed
            
            /**
             * @desc 
             * @verdict 
             */
            function f_postambleS1AP_MME()
            runs on S1APComponent {
garciay's avatar
garciay committed
                // TODO:...
            } // End of function f_postambleS1AP_MME
            
            /**
             * @desc 
             * @verdict 
             */
            function f_postambleS1AP_eNB()
            runs on S1APComponent {
garciay's avatar
garciay committed
                // TODO:...
            } // End of function f_postambleS1AP_eNB
            
        } // End of group postamble_S1AP
        
    } // End of group Postambles
garciay's avatar
garciay committed
    group DefaultsTestStep {
        
        /**
         * @desc 
         * @verdict 
         */
        altstep a_defaultS1AP()
garciay's avatar
garciay committed
        runs on S1APComponent {
            [] any timer.timeout {
                all timer.stop;
                if (vc_serverStop==false) {
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                else {
                    stop;
                }
            }
            [] S1_MMEeNB_P.receive (S1AP_PDU:{initiatingMessage := ?}) -> value vc_recvS1AP_PDUDefault {
                repeat;
            }
            [] S1_MMEeNB_P.receive (S1AP_PDU:{successfulOutcome := ?}) -> value vc_recvS1AP_PDUDefault {
                repeat;
            }
            [] S1_MMEeNB_P.receive (S1AP_PDU:{unsuccessfulOutcome := ?}) -> value vc_recvS1AP_PDUDefault {
                repeat;
            }
            [] S1_MMEeNB_P.receive (S1AP_PDU:?) -> value vc_recvS1AP_PDUDefault {
                if (vc_serverStop==false) {
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                else {
                    stop;
                }
            }
            [] S1_MMEeNB_P.receive {
                if (vc_serverStop==false) {
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                else {
                    stop;
                }
            }
            [] a_shutdown() {
                // Process temination on error
                log("*** a_defaultS1AP() : Process temination on error ***");
                // Terminate component execution
                stop;
            }
garciay's avatar
garciay committed
        } // End of altstep a_defaultS1AP
        
        altstep a_defaultS1AP_MME()
garciay's avatar
garciay committed
        runs on S1APComponent {
            [] any timer.timeout {
                all timer.stop;
                if (vc_serverStop==false) {
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                else {
                    stop;
                }
            }
            //TODO:...
        } // End of altstep a_defaultS1AP_MME
        
        altstep a_defaultS1AP_eNB()
garciay's avatar
garciay committed
        runs on S1APComponent {
            [] any timer.timeout {
                all timer.stop;
                if (vc_serverStop==false) {
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                else {
                    stop;
                }
            }
             //TODO:...
garciay's avatar
garciay committed
        } // End of altstep a_defaultS1AP_eNB
        
    } // End of group DefaultsTestStep
garciay's avatar
garciay committed
} // End of module LibS1AP_Steps