Commit a059f9ee authored by ASN.1 Documenter's avatar ASN.1 Documenter
Browse files

Initial

parent 94bbd9e3
Loading
Loading
Loading
Loading

ItsBtp_TestCases.ttcn

0 → 100755
+390 −0
Original line number Diff line number Diff line
/**
 *  @author   ETSI / STF405
 *  @version  $Url: https://oldforge.etsi.org/svn/ITS/tags/20170222_STF527_Final/ttcn/AtsBTP/ItsBtp_TestCases.ttcn $
 *            $Id: ItsBtp_TestCases.ttcn 2655 2017-01-26 10:46:08Z filatov $
 *  @desc     Testcases for Basic Transport Protocol (TP version: 0.0.3)
 *  @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.
 *
 */
module ItsBtp_TestCases {
    
    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_Time all;
//    import from LibCommon_VerdictControl all;

    // LibIts
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_Functions all;
    import from LibItsBtp_Templates all;
//    import from LibItsBtp_Pixits all;
//    import from LibItsBtp_TypesAndValues all;
//    import from LibItsCommon_Functions all;
    
    group btpPacketGeneration {
        
        group btpBtpA {

        /**
         * @desc    Checks that BTP-A packets is well-formatted
         * <pre>        
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT is requested to send a BTP packet via a BTP-data request
         *              containing BTP Type
         *                  indicationg value 'BTP-A'
         *              containing Source PorT
         *                  indicating value 'SOURCE_PORT'
         *              containing Destination Port
         *                  indicating value 'DESTINATION_PORT'
         *      }
         *      then {
         *          the IUT sends a valid BTP-A packet
         *              containing source port
         *                  indicating 'SOURCE_PORT',
         *              containing destination port
         *                  indicating 'DESTINATION_PORT',
         *              containing the Upper Layer payload
         *      }
         *  }
         * </pre>
         * 
         * @version 0.0.3
         * @see     ETSI TS 102 870-2 v1.1.1 TP/BTP/PGA/BV/01
         */
        testcase TC_BTP_PGA_BV_01() runs on ItsBtp system ItsBtpSystem {

            // Local variables
                        
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                
            // Test Body
            f_utTriggerEvent(m_generateBtpA(f_getBtpDstPort(), f_getBtpSrcPort()));
            tc_ac.start;
            alt {
                [] btpPort.receive( mw_btpInd( mw_btpA (f_getBtpDstPort(), f_getBtpSrcPort(), *)))  {
                    tc_ac.stop;
                    log("*** TC_BTP_PGA_BV_01: PASS: BTP-A packet correclty received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                }
                    
                [] tc_ac.timeout {
                    log("*** TC_BTP_PGA_BV_01: INCONC: Expected BTP packet not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }   
             }

            // Postamble
            f_poDefault();
            f_cfDown();
                  
        }// end TC_BTP_PGA_BV_0
          
        } // end btpBtpA
        
        group btpBtpB {
          
        /**
         * @desc    Checks that BTP-B packets is well-formatted if Destination Port info is provided
         * <pre>        
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT is requested to send a BTP packet via a BTP-data request
         *              containing BTP Type
         *                  indicationg value 'BTP-B'
         *              containing Destination Port
         *                  indicating value 'DESTINATION_PORT'
         *              containing Destination Port Info
         *                  indicating value 'DESTINATION_PORT_INFO'
         *      }
         *      then {
         *          the IUT sends a valid BTP-B packet
         *              containing Destination Port
         *                  indicating value 'DESTINATION_PORT'
         *              containing Destination Port Info
         *                  indicating value 'DESTINATION_PORT_INFO'
         *              containing the Upper Layer payload
         *      }
         *  }
         * </pre>
         * 
         * @version 0.0.3
         * @see     ETSI TS 102 870-2 v1.1.1 TP/BTP/PGB/BV/01
         */
        testcase TC_BTP_PGB_BV_01() runs on ItsBtp system ItsBtpSystem {

            // Local variables
                        
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                
            // Test Body
            f_utTriggerEvent(m_generateBtpB(f_getBtpDstPort(), f_getBtpDstPortInfo()));
            tc_ac.start;
            alt {
                [] btpPort.receive( mw_btpInd( mw_btpB (f_getBtpDstPort(), f_getBtpDstPortInfo(), *))) {
                    tc_ac.stop;
                    log("*** TC_BTP_PGB_BV_01: PASS: BTP-B packet correclty received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                }
                    
                [] tc_ac.timeout {
                    log("*** TC_BTP_PGB_BV_01: INCONC: Expected BTP packet not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }   
             }
            
            // Postamble
            f_poDefault();
            f_cfDown();
                  
        }// end TC_BTP_PGB_BV_01

        /**
         * @desc    Checks that BTP-B packets are well-formatted if no Destination Port Info is provided
         * <pre>        
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT is requested to send a BTP packet via a BTP-data request
         *              containing BTP Type
         *                  indicationg value 'BTP-B'
         *              containing Destination Port
         *                  indicating value 'DESTINATION_PORT'
         *              not containing Destination Port Info parameter
         *      }
         *      then {
         *          the IUT sends a valid BTP-B packet
         *              containing Destination Port
         *                  indicating value 'DESTINATION_PORT'
         *              containing Destination Port Info
         *                  indicating '0'
         *              containing the Upper Layer payload
         *      }
         *  }
         * </pre>
         * 
         * @version 0.0.3
         * @see     ETSI TS 102 870-2 v1.1.1 TP/BTP/PGB/BV/02
         */
        testcase TC_BTP_PGB_BV_02() runs on ItsBtp system ItsBtpSystem {

            // Local variables
                        
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                
            // Test Body
            f_utTriggerEvent(m_generateBtpB(f_getBtpDstPort(), 0));
            tc_ac.start;
            alt {
                [] btpPort.receive( mw_btpInd( mw_btpB (f_getBtpDstPort(), 0, *))) {
                    tc_ac.stop;
                    log("*** TC_BTP_PGB_BV_02: PASS: BTP-B packet correclty received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                }
                
                [] tc_ac.timeout {
                    log("*** TC_BTP_PGB_BV_02: INCONC: Expected BTP packet not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }
             }
            
            // Postamble
            f_poDefault();
            f_cfDown();
                  
        }// end TC_BTP_PGB_BV_02

        } // end btpBtpB
        
    } // end btpPacketGeneration
    
    group btpPacketProcessing {
    
        group btpValid {
          
        /**
         * @desc    Checks that BTP passes a valid BTP-A packets to the upper protocol entity
         * <pre>        
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT receives a valid BTP-A packet
         *              containing Source Port
         *                  indicating 'SOURCE_PORT'
         *              containing Destination Port
         *                  indicating'DESTINATION_PORT'
         *              containing the payload
         *      }
         *      then {
         *          the IUT passes the payload to the upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 0.0.3
         * @see     ETSI TS 102 870-2 v1.1.1 TP/BTP/PP/BV/01
         */
        testcase TC_BTP_PP_BV_01() runs on ItsBtp system ItsBtpSystem {

            // Local variables
            var BtpReq v_btpReq;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_btpReq := valueof(m_btpReq( m_btpAWithPorts (f_getBtpDstPort(), f_getBtpSrcPort(), f_getBtpPayload())));
            btpPort.send(v_btpReq);

            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_btpReq.msgOut.payload, vc_utEvents[i].rawPayload); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: BTP was transmitted to upper layer***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: BTP was not transmitted to upper layer***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            }

            // Postamble
            f_poDefault();
            f_cfDown();
                  
        }// end TC_BTP_PP_BV_01
          
        /**
         * @desc    Checks that BTP passes a valid BTP-B packets to the upper protocol entity
         * <pre>        
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT receives a valid BTP-B packet
         *              containing Destination Port
         *                  indicating'DESTINATION_PORT'
         *              containing Destination Port Info
         *                  indicating'DESTINATION_PORT_INFO'
         *              containing the payload
         *      }
         *      then {
         *          the IUT passes the payload to the upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 0.0.3
         * @see     ETSI TS 102 870-2 v1.1.1 TP/BTP/PP/BV/02
         */
        testcase TC_BTP_PP_BV_02() runs on ItsBtp system ItsBtpSystem {

            // Local variables
            var BtpReq v_btpReq;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                
            // Test Body
            v_btpReq := valueof(m_btpReq( m_btpBWithPorts (f_getBtpDstPort(), f_getBtpDstPortInfo(), f_getBtpPayload())));
            btpPort.send(v_btpReq);

            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_btpReq.msgOut.payload, vc_utEvents[i].rawPayload); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: BTP was transmitted to upper layer***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: BTP was not transmitted to upper layer***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            }

            // Postamble
            f_poDefault();
            f_cfDown();
                  
        }// end TC_BTP_PP_BV_02
          
        } // end btpValid
        
    } // end btpPacketProcessing
    
} // end ItsBtp_TestCases
+28 −0
Original line number Diff line number Diff line
/**
 *  @author   ETSI / STF405
 *  @version  $Url: https://oldforge.etsi.org/svn/ITS/tags/20170222_STF527_Final/ttcn/AtsBTP/ItsBtp_TestControl.ttcn $
 *            $Id: ItsBtp_TestControl.ttcn 2655 2017-01-26 10:46:08Z filatov $
 *  @desc     Test Control file for Basic Transport Protocol
 *  @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.
 *
 */
module ItsBtp_TestControl {
    
    // ATS BTP
    import from ItsBtp_TestCases {testcase all};
    
    // Test Execution
    control {

        execute(TC_BTP_PGA_BV_01());
        execute(TC_BTP_PGB_BV_01());
        execute(TC_BTP_PGB_BV_02());
        execute(TC_BTP_PP_BV_01());
        execute(TC_BTP_PP_BV_02());
        
    }
    
} // end ItsBtp_TestControl
+30 −0
Original line number Diff line number Diff line
module LibItsBtp_EncdecDeclarations {
    
    // LibItsBtp
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_TestSystem all;
    
    /*  TODO RGy function not implemented! (decvalue() not used by test suite @29-06-2016)    
    external function fx_dec_BtpPayload (inout bitstring b, out BtpPayload p) return integer
        with {extension "prototype(sliding) decode(LibItsBtp)"}
    */

    external function fx_enc_BtpReq (BtpReq p) return bitstring
        with {extension "prototype(convert) encode(LibIts_Interface)"}

    external function fx_enc_BtpInd (BtpInd p) return bitstring
        with {extension "prototype(convert) encode(LibIts_Interface)"}

    external function fx_dec_BtpInd (inout bitstring b, out BtpInd p) return integer
        with {extension "prototype(sliding) decode(LibIts_Interface)"}

    external function fx_dec_BtpReq (inout bitstring b, out BtpReq p) return integer
        with {extension "prototype(sliding) decode(LibIts_Interface)"}

    external function fx_enc_BtpPacket (BtpPacket p) return bitstring
        with {extension "prototype(convert) encode(LibIts_Interface)"}

    external function fx_dec_BtpPacket (inout bitstring b, out BtpPacket p) return integer
        with {extension "prototype(sliding) decode(LibIts_Interface)"}
        
} // End of module LibItsBtp_EncdecDeclarations 
+237 −0
Original line number Diff line number Diff line
/**
 *  @author     ETSI / STF405
 *  @version    $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_Functions.ttcn $
 *              $Id: LibItsBtp_Functions.ttcn 1318 2017-01-26 10:20:53Z filatov $
 *  @desc       Module containing functions for basic Transport Protocol
 *  @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.
 *
 */
 
 module LibItsBtp_Functions {
     
    // LibCommon
    import from LibCommon_Sync all;
    
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
    
    // LibItsBtp
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Templates all;
    import from LibItsBtp_Pixits all;

    group utFuntions { 
            
        /**
         * @desc    Requests to bring the IUT in an initial state
         * @param   p_init The initialisation to trigger.
         */
        function f_utInitializeIut(template (value) UtBtpInitialize p_init) runs on ItsBtp {
            
            //deactivate btpPort default alts
            vc_btpDefaultActive := false;
            
            utPort.send(p_init);
            tc_wait.start;
            alt {
                [] utPort.receive(UtBtpResults: { utBtpInitializeResult := true}) {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT initialized ***");
                }
                [] utPort.receive {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] tc_wait.timeout {
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
            }
            
            //activate btpPort default alts
            vc_btpDefaultActive := true;
            
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtBtpTrigger p_event) runs on ItsBtp {
            
            //deactivate btpPort default alts
            vc_btpDefaultActive := false;
            
            utPort.send(p_event);
            alt {
	      [] utPort.receive(UtBtpResults: { utBtpTriggerResult := true }) {
                    tc_wait.stop;
                }
                [] utPort.receive {
                    tc_wait.stop;
                }
                [] tc_wait.timeout {
                }
            }
            
            //activate btpPort default alts
            vc_btpDefaultActive := true;
            
        }
        
    } // End of group utFunctions
     
    group configurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsBtp system ItsBtpSystem {
            
            map(self:utPort, system:utPort);
            map(self:btpPort, system:btpPort);
            f_connect4SelfOrClientSync();
            
        } // end f_cfUp
        
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsBtp system ItsBtpSystem {
            
            unmap(self:utPort, system:utPort);
            unmap(self:btpPort, system:btpPort);
            f_disconnect4SelfOrClientSync();
            
        } // end f_cfDown
        
    } // end configurationFunctions
    
    group btpAltsteps {
        
        /**
         * @desc The base default.
         */
        altstep a_default() runs on ItsBtp {
            
            [vc_btpDefaultActive] btpPort.receive {
                log("*** a_default: ERROR: Received an unexpected message ***");
                f_selfOrClientSyncAndVerdict("error", e_error);
            }
            [] tc_wait.timeout {
                log("*** a_default: INCONC: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] tc_ac.timeout {
                log("*** a_default: INCONC: Timeout while awaiting the reception of a message ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] a_shutdown() {
                f_poDefault();
                f_cfDown();
                log("*** a_default: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;   
            }
        }
        
        /**
         * @desc The default for handling upper tester messages.
         */
        altstep a_utDefault() runs on ItsBtp {
            var UtBtpEventInd v_ind;
            [vc_utDefaultActive] utPort.receive(UtBtpEventInd:?) -> value v_ind {
                //store every upper tester indication received
                vc_utEvents[lengthof(vc_utEvents)] := v_ind;
                repeat;
            }
            [vc_utDefaultActive] utPort.receive {
                log("*** " & testcasename() & ": INFO: Received unhandled/unknown UT message from IUT ***");
                repeat;
            }
        }
        
    } //end btpAltsteps

    group preambles {
        
        /**
         * @desc The default preamble.
         */
        function f_prDefault() runs on ItsBtp {
            activate(a_default());
            activate(a_utDefault());
        }
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_prInitialState() runs on ItsBtp {
            
            f_utInitializeIut(m_btpInitialize);
            f_prDefault();

        }
        
    } // end of group preambles    
    

    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsBtp {
            //empty
        }
        
    } // end postambles
    
    group getFunctions {
        
        /**
         * @desc Gets the BTP source port of the IUT.
         * @return BTP source port ID
         */
        function f_getBtpSrcPort() return BtpPortId {
            return PX_SOURCE_PORT;
        }
        
        /**
         * @desc Gets the BTP destination port of the IUT.
         * @return BTP destination port ID
         */
        function f_getBtpDstPort() return BtpPortId {
            return PX_DESTINATION_PORT;
        }
        
        /**
         * @desc Gets a unknown BTP destination port of the IUT.
         * @return Unknown BTP destination port ID
         */
        function f_getBtpUnknownDstPort() return BtpPortId {
            return PX_UNKNOWN_DESTINATION_PORT;
        }
        
        /**
         * @desc Gets the BTP destination port info of the IUT.
         * @return BTP destination port info
         */
        function f_getBtpDstPortInfo() return BtpPortId {
            return PX_DESTINATION_PORT_INFO;
        }
        
        /**
         * @desc Gets the BTP payload to use.
         * @return BTP payload
         */
        function f_getBtpPayload() return BtpRawPayload {
            return PX_PAYLOAD;
        }
        
    } // end getFunctions
} // end LibItsBtp_Functions
+49 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading