Commit 9c9a94a3 authored by Yann Garcia's avatar Yann Garcia
Browse files

Add basics TTCN-3 functionalities

parent 151fa8d5
Loading
Loading
Loading
Loading
+100 −0
Original line number Diff line number Diff line
module ItsVru_TestCases {

  // LibItsVru
  import from LibItsVru_TestSystem all;
  
  // Ats Its
  import from ItsVru_TpFunctions all;

  group vruLowerLayerParameters {

    /**
    * @desc Check that VAM is encapsulated in BTP type B packet
    * <pre>
    * Pics Selection: PICS_VRU_GENERATION AND NOT PICS_IS_IUT_SECURED
    * Initial conditions: 
    *     with {
    *         the IUT being in the "initial state"
    *     }
    * Expected behaviour:
    *  ensure that {
    *      when {
    *          a CollectivePerceptionMessage is generated
    *      }
    *      then {
    *          the IUT sends a CollectivePerceptionMessage
    *              encapsulated in a BTP-B packet
    *      }
    *  } 
    * </pre>
    * 
    * @see       ETSI TS 104 018-2 v1.5.1 TP/VRU/MSD/PAR/BV-01
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_VRU_MSD_PAR_BV_01() runs on ItsVru system ItsVruSystem {

      f_VRU_MSD_PAR_BV_01();

    } // End of TC_VRU_MSD_PAR_BV_01

    /**
    * @desc Check that VAM is encapsulated in SHB packet
    * <pre>
    * Pics Selection: PICS_VRU_GENERATION AND NOT PICS_IS_IUT_SECURED
    * Initial conditions: 
    *     with {
    *         the IUT being in the "initial state"
    *     }
    * Expected behaviour:
    *  ensure that {
    *      when {
    *          a CollectivePerceptionMessage is generated
    *      }
    *      then {
    *          the IUT sends a CollectivePerceptionMessage
    *              encapsulated in a SHB packet
    *      }
    *  } 
    * </pre>
    * 
    * @see       ETSI TS 104 018-2 v1.5.1 TP/VRU/MSD/PAR/BV-02
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_VRU_MSD_PAR_BV_02() runs on ItsVru system ItsVruSystem {

      f_VRU_MSD_PAR_BV_02();

    } // End of TC_VRU_MSD_PAR_BV_02

    /**
    * @desc Check that VRU is encapsulated in GN packet with lifetime lower than 1s
    * <pre>
    * Pics Selection: PICS_VRU_GENERATION AND NOT PICS_IS_IUT_SECURED
    * Initial conditions: 
    *     with {
    *         the IUT being in the "initial state"
    *     }
    * Expected behaviour:
    *  ensure that {
    *      when {
    *          a CollectivePerceptionMessage is generated
    *      }
    *      then {
    *          the IUT sends a VAM
    *              encapsulated in a GN packet
    *                  containing Basic Header
    *                      containing Lifetime field 
    *                          indicating value lower than 1s
    *      }
    *  } 
    * </pre>
    * 
    * @see       ETSI TS 104 018-2 v1.5.1 TP/VRU/MSD/PAR/BV-03
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_VRU_MSD_PAR_BV_03() runs on ItsVru system ItsVruSystem {

      f_VRU_MSD_PAR_BV_03();

    } // End of TC_VRU_MSD_PAR_BV_03                        

  } // End of vruLowerLayerParameters  

} // End of module ItsVru_TestCases
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
module ItsVru_TestControl {

  // ATS VRU
  import from ItsVru_TestCases all;
  
  // LibIts
  import from LibItsVru_Pics all;
  
  // Test Execution
  control {
    
    if(PICS_VRU_GENERATION) {
        execute(TC_VRU_MSD_PAR_BV_01());
        execute(TC_VRU_MSD_PAR_BV_02());
        execute(TC_VRU_MSD_PAR_BV_03());
    }

  }

} // End of module ItsVru_TestControl
 No newline at end of file
+192 −0
Original line number Diff line number Diff line
module ItsVru_TpFunctions {

  // LibCommon
  import from LibCommon_Sync all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Time all;
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;

  // LibIts
  import from ETSI_ITS_CDD language "ASN.1:1997" all;
  import from VAM_PDU_Descriptions language "ASN.1:1997" all;

  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;
  import from LibItsCommon_Functions all;
  import from LibItsCommon_Pixits all;
  import from LibItsCommon_ASN1_NamedNumbers all;

  // LibItsVru
  import from LibItsVru_TestSystem all;
  import from LibItsVru_Functions all;
  import from LibItsVru_Templates all;
  import from LibItsVru_TypesAndValues all;
  import from LibItsVru_Pics all;

  import from LibItsSecurity_Functions all;
  group vruLowerLayerParameters {
    
    /**
     * @desc  TP Function for TC_VRU_MSD_PAR_BV_01
     */
    function f_VRU_MSD_PAR_BV_01() runs on ItsVru {
    
      // Local variables
      const UInt8 c_gnNhBtpB := 2;
      
      // Test control
      if (not PICS_VRU_GENERATION or PICS_IS_IUT_SECURED) {
        log("*** " & testcasename() & ": PICS_VRU_GENERATION and not PICS_IS_IUT_SECURED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }
      
      // Test component configuration
      f_cfUp();
      
      // Test adapter configuration
      
      // Preamble
      f_prInitialState();
      f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
      
      // Test Body
      tc_ac.start;
      alt {
        [] vamPort.receive(mw_vamIndWithGnParameters(mw_vamMsg_any, c_gnNhBtpB)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": PASS: Expected VRU message encapsultated in BTP-B packet received ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
        }
        [] vamPort.receive(mw_vamIndWithGnParameters(mw_vamMsg_any, omit)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": INCONC: no GN NH information in CpmInd ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
        }      
        [] vamPort.receive(mw_vamInd(mw_vamMsg_any)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": FAIL: Expected VRU message received, but not encapsulated in BTP-B packet ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
        }      
        [] tc_ac.timeout {
        log("*** " & testcasename() & ": INCONC: VRU message not received ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      }
      
      // Postamble
      f_poDefault();
      f_cfDown();
    
    } // End of function f_VRU_MSD_PAR_BV_01

    /**
     * @desc  TP Function for TC_VRU_MSD_PAR_BV_02
     */
    function f_VRU_MSD_PAR_BV_02() runs on ItsVru {
    
    // Local variables
    const UInt8 c_gnHtTsb := 5;
    const UInt8 c_GnHstSingleHop := 0;
    
    // Test control
    if (not PICS_VRU_GENERATION or PICS_IS_IUT_SECURED) {
      log("*** " & testcasename() & ": PICS_VRU_GENERATION and not PICS_IS_IUT_SECURED required for executing the TC ***");
      setverdict(inconc);
      stop;
    }    
    
    // Test component configuration
    f_cfUp();
    
    // Test adapter configuration
    
    // Preamble
    f_prInitialState();
    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
    
    // Test Body
    tc_ac.start;
    alt {
      [] vamPort.receive(mw_vamIndWithGnParameters(mw_vamMsg_any, -, c_gnHtTsb, c_GnHstSingleHop)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": PASS: Expected VRU message encapsulated in SHB packet received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
      }
      [] vamPort.receive(mw_vamIndWithGnParameters(mw_vamMsg_any, -, omit, omit)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": INCONC: no GN HT/HST information in CpmInd ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
      }      
      [] vamPort.receive(mw_vamInd(mw_vamMsg_any)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": FAIL: Expected VRU message received, but not encapsulated in SHB packet ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
      }      
      [] tc_ac.timeout {
      log("*** " & testcasename() & ": INCONC: VRU message not received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
      }
    }
    
    // Postamble
    f_poDefault();
    f_cfDown();
    
    } // End of function f_VRU_MSD_PAR_BV_02
    
    /**
     * @desc  TP Function for TC_VRU_MSD_PAR_BV_03
     */
    function f_VRU_MSD_PAR_BV_03() runs on ItsVru {
    
    // Local variables
    var VamInd v_vamInd;
    
    // Test control
    if (not PICS_VRU_GENERATION or PICS_IS_IUT_SECURED) {
      log("*** " & testcasename() & ": PICS_VRU_GENERATION and not PICS_IS_IUT_SECURED required for executing the TC ***");
      setverdict(inconc);
      stop;
    }    
    
    // Test component configuration
    f_cfUp();
    
    // Test adapter configuration
    
    // Preamble
    f_prInitialState();
    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
    
    // Test Body
    tc_ac.start;
    alt {
      [] vamPort.receive(mw_vamIndWithGnParameters(mw_vamMsg_any)) -> value v_vamInd { 
      tc_ac.stop;
      if(not ispresent(v_vamInd.gnLifetime)) {
        log("*** " & testcasename() & ": INCONC: no GN lifetime information in CpmInd ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
      }
      if(v_vamInd.gnLifetime <= 1000) {
        log("*** " & testcasename() & ": PASS: Expected VRU message received encapsulted in GN packet with correct lifetime value ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
      }
      else {
        log("*** " & testcasename() & ": FAIL: Expected VRU message received encapsulted in GN packet with incorrect lifetime value ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);        
      }  
      }      
      [] tc_ac.timeout {
      log("*** " & testcasename() & ": INCONC: VRU message not received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
      }
    }
    
    // Postamble
    f_poDefault();
    f_cfDown();
    
    } // End of function f_VRU_MSD_PAR_BV_03

  } // End of group vruLowerLayerParameters

} // End of module ItsVru_TpFunctions
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
module LibItsVru_EncdecDeclarations {

  // LibIts
  import from VAM_PDU_Descriptions language "ASN.1:1997" all;
  
  // LibItsVru
  import from LibItsVru_TypesAndValues all; 

  external function fx_enc_VruReq (VamReq p) return bitstring
      with {extension "prototype(convert) encode(LibIts_Interface)"}
  
  external function fx_dec_VruReq (inout bitstring b, out VamReq p) return integer
      with {extension "prototype(sliding) decode(LibIts_Interface)"}

  external function fx_dec_VruInd (inout bitstring b, out VamInd p) return integer
      with {extension "prototype(sliding) decode(LibIts_Interface)"}
      
  external function fx_enc_VAM (VAM p) return bitstring
      with {extension "prototype(convert) encode(PER)"}

  external function fx_dec_VAM (inout bitstring b, out VAM p) return integer
      with {extension "prototype(sliding) decode(PER)"}

  external function fx_enc_UtVruInitialize (UtVruInitialize p) return bitstring
      with {extension "prototype(convert) encode(UpperTester)"}
  
  external function fx_dec_UtVruEventInd (inout bitstring b, out UtVruEventInd p) return integer
      with {extension "prototype(sliding) decode(UpperTester)"}

} // End of module LibItsVru_EncdecDeclarations
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
module LibItsVru_Pics {

  // LibCommon
  import from LibCommon_BasicTypesAndValues all;

  /**
    * @desc Is the IUT running in secured mode?
    * @see  ETSI TS 104 019-1 Table A.1
    */
  modulepar boolean PICS_IS_IUT_SECURED := false;
  
  /**
    * @desc Support for VRU generation
    * @see  ETSI TS 104 019-1 Table A.3
    */
  modulepar boolean PICS_VRU_GENERATION := true;

  /**
    * @desc Support for VRU reception
    * @see  ETSI TS 104 019-1 Table A.3
    */
  modulepar boolean PICS_VRU_RECEPTION := true;

} // End of module LibItsVru_Pics
 No newline at end of file
Loading