Commit 86797beb authored by Yann Garcia's avatar Yann Garcia
Browse files

Add basics TTCN-3 functionalities

parent 5b058017
Loading
Loading
Loading
Loading
+100 −0
Original line number Diff line number Diff line
module ItsCps_TestCases {

  // LibItsCps
  import from LibItsCps_TestSystem all;
  
  // Ats Its
  import from ItsCps_TpFunctions all;

  group cpsLowerLayerParameters {

    /**
    * @desc Check that CPS is encapsulated in BTP type B packet
    * <pre>
    * Pics Selection: PICS_CPS_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 019-2 v1.5.1 TP/CPS/MSD/PAR/BV-01
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_CPS_MSD_PAR_BV_01() runs on ItsCps system ItsCpsSystem {

      f_CPS_MSD_PAR_BV_01();

    } // End of TC_CPS_MSD_PAR_BV_01

    /**
    * @desc Check that CPS is encapsulated in SHB packet
    * <pre>
    * Pics Selection: PICS_CPS_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 019-2 v1.5.1 TP/CPS/MSD/PAR/BV-02
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_CPS_MSD_PAR_BV_02() runs on ItsCps system ItsCpsSystem {

      f_CPS_MSD_PAR_BV_02();

    } // End of TC_CPS_MSD_PAR_BV_02

    /**
    * @desc Check that CPS is encapsulated in GN packet with lifetime lower than 1s
    * <pre>
    * Pics Selection: PICS_CPS_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 CCollectivePerceptionMessagePS
    *              encapsulated in a GN packet
    *                  containing Basic Header
    *                      containing Lifetime field 
    *                          indicating value lower than 1s
    *      }
    *  } 
    * </pre>
    * 
    * @see       ETSI TS 104 019-2 v1.5.1 TP/CPS/MSD/PAR/BV-03
    * @reference ETSI EN 302 637-2 v1.4.1, clause 5.3.4.1
    */
    testcase TC_CPS_MSD_PAR_BV_03() runs on ItsCps system ItsCpsSystem {

      f_CPS_MSD_PAR_BV_03();

    } // End of TC_CPS_MSD_PAR_BV_03                        

  } // End of cpsLowerLayerParameters  

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

  // ATS CPS
  import from ItsCps_TestCases all;
  
  // LibIts
  import from LibItsCps_Pics all;
  
  // Test Execution
  control {
    
    if(PICS_CPS_GENERATION) {
        execute(TC_CPS_MSD_PAR_BV_01());
        execute(TC_CPS_MSD_PAR_BV_02());
        execute(TC_CPS_MSD_PAR_BV_03());
    }

  }

} // End of module ItsCps_TestControl
 No newline at end of file
+192 −0
Original line number Diff line number Diff line
module ItsCps_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 CPM_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;

  // LibItsCps
  import from LibItsCps_TestSystem all;
  import from LibItsCps_Functions all;
  import from LibItsCps_Templates all;
  import from LibItsCps_TypesAndValues all;
  import from LibItsCps_Pics all;

  import from LibItsSecurity_Functions all;
  group cpsLowerLayerParameters {
    
    /**
     * @desc  TP Function for TC_CPS_MSD_PAR_BV_01
     */
    function f_CPS_MSD_PAR_BV_01() runs on ItsCps {
    
      // Local variables
      const UInt8 c_gnNhBtpB := 2;
      
      // Test control
      if (not PICS_CPS_GENERATION or PICS_IS_IUT_SECURED) {
        log("*** " & testcasename() & ": PICS_CPS_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 {
        [] cpmPort.receive(mw_cpsIndWithGnParameters(mw_cpmMsg_any, c_gnNhBtpB)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": PASS: Expected CPS message encapsultated in BTP-B packet received ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
        }
        [] cpmPort.receive(mw_cpsIndWithGnParameters(mw_cpmMsg_any, omit)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": INCONC: no GN NH information in CpsInd ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
        }      
        [] cpmPort.receive(mw_cpsInd(mw_cpmMsg_any)) { 
        tc_ac.stop;
        log("*** " & testcasename() & ": FAIL: Expected CPS message received, but not encapsulated in BTP-B packet ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
        }      
        [] tc_ac.timeout {
        log("*** " & testcasename() & ": INCONC: CPS message not received ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      }
      
      // Postamble
      f_poDefault();
      f_cfDown();
    
    } // End of function f_CPS_MSD_PAR_BV_01

    /**
     * @desc  TP Function for TC_CPS_MSD_PAR_BV_02
     */
    function f_CPS_MSD_PAR_BV_02() runs on ItsCps {
    
    // Local variables
    const UInt8 c_gnHtTsb := 5;
    const UInt8 c_GnHstSingleHop := 0;
    
    // Test control
    if (not PICS_CPS_GENERATION or PICS_IS_IUT_SECURED) {
      log("*** " & testcasename() & ": PICS_CPS_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 {
      [] cpmPort.receive(mw_cpsIndWithGnParameters(mw_cpmMsg_any, -, c_gnHtTsb, c_GnHstSingleHop)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": PASS: Expected CPS message encapsulated in SHB packet received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
      }
      [] cpmPort.receive(mw_cpsIndWithGnParameters(mw_cpmMsg_any, -, omit, omit)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": INCONC: no GN HT/HST information in CpsInd ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
      }      
      [] cpmPort.receive(mw_cpsInd(mw_cpmMsg_any)) { 
      tc_ac.stop;
      log("*** " & testcasename() & ": FAIL: Expected CPS message received, but not encapsulated in SHB packet ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
      }      
      [] tc_ac.timeout {
      log("*** " & testcasename() & ": INCONC: CPS message not received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
      }
    }
    
    // Postamble
    f_poDefault();
    f_cfDown();
    
    } // End of function f_CPS_MSD_PAR_BV_02
    
    /**
     * @desc  TP Function for TC_CPS_MSD_PAR_BV_03
     */
    function f_CPS_MSD_PAR_BV_03() runs on ItsCps {
    
    // Local variables
    var CpsInd v_cpsInd;
    
    // Test control
    if (not PICS_CPS_GENERATION or PICS_IS_IUT_SECURED) {
      log("*** " & testcasename() & ": PICS_CPS_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 {
      [] cpmPort.receive(mw_cpsIndWithGnParameters(mw_cpmMsg_any)) -> value v_cpsInd { 
      tc_ac.stop;
      if(not ispresent(v_cpsInd.gnLifetime)) {
        log("*** " & testcasename() & ": INCONC: no GN lifetime information in CpsInd ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
      }
      if(v_cpsInd.gnLifetime <= 1000) {
        log("*** " & testcasename() & ": PASS: Expected CPS message received encapsulted in GN packet with correct lifetime value ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
      }
      else {
        log("*** " & testcasename() & ": FAIL: Expected CPS message received encapsulted in GN packet with incorrect lifetime value ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);        
      }  
      }      
      [] tc_ac.timeout {
      log("*** " & testcasename() & ": INCONC: CPS message not received ***");
      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
      }
    }
    
    // Postamble
    f_poDefault();
    f_cfDown();
    
    } // End of function f_CPS_MSD_PAR_BV_03

  } // End of group cpsLowerLayerParameters

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

  // LibIts
  import from CPM_PDU_Descriptions language "ASN.1:1997" all;
  
  // LibItsCps
  import from LibItsCps_TypesAndValues all; 

  external function fx_enc_CpsReq (CpsReq p) return bitstring
      with {extension "prototype(convert) encode(LibIts_Interface)"}
  
  external function fx_dec_CpsReq (inout bitstring b, out CpsReq p) return integer
      with {extension "prototype(sliding) decode(LibIts_Interface)"}

  external function fx_dec_CpsInd (inout bitstring b, out CpsInd p) return integer
      with {extension "prototype(sliding) decode(LibIts_Interface)"}
      
  external function fx_enc_CPM (CollectivePerceptionMessage p) return bitstring
      with {extension "prototype(convert) encode(PER)"}

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

  external function fx_enc_UtCpsInitialize (UtCpsInitialize p) return bitstring
      with {extension "prototype(convert) encode(UpperTester)"}
  
  external function fx_dec_UtCpsEventInd (inout bitstring b, out UtCpsEventInd p) return integer
      with {extension "prototype(sliding) decode(UpperTester)"}

} // End of module LibItsCps_EncdecDeclarations
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
module LibItsCps_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 CPS generation
    * @see  ETSI TS 104 019-1 Table A.3
    */
  modulepar boolean PICS_CPS_GENERATION := true;

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

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