LibCommon_VerdictControl.ttcn 3.84 KB
Newer Older
1 2
/**
 *  @author   ETSI
3
 *  @version  $URL: https://oldforge.etsi.org/svn/LibCommon/tags/v1.4.0/ttcn/LibCommon_VerdictControl.ttcn $
4
 *            $Id: LibCommon_VerdictControl.ttcn 64 2016-12-14 15:09:43Z berge $
5 6 7 8 9 10 11 12 13
 *  @desc     Contains generic functions which set test component verdicts
 *            based on generic function return codes according to established
 *            test implementation practice. These functions should only be called
 *            from test case functions (see reusable t3 code methodology) only.
 *  @remark   End users should be aware that any changes made to the  in
 *            definitions this module may be overwritten in future releases.
 *            End users are encouraged to contact the distributers of this
 *            module regarding their modifications or additions so that future
 *            updates will include your changes.
14 15 16 17 18
 *  @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.
 *
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
 */
 module LibCommon_VerdictControl {

  /**
   * @desc  Collection of all possible function return codes.
   *        This type should be used as a return parameter type
   *        in all TTCN-3 function definitions (except for
   *        functions invoked from in TTCN-3 start statements).
   *        This return value should be used to communicate a
   *        verdict to the caller _instead of_ literally setting
   *        a verdict in the function! This warrants a higher
   *        degree of reuse for the function.
   */
  type enumerated FncRetCode {
    e_success(0),
    // error codes
    e_error(1),
    e_timeout(2)
  }

  /**
   * @desc  This function should be used for verdict
   *        setting after completion of, e.g., the test body
   *        execution.
   *        Sets verdicts are INCONC in case of a timeout, FAIL
   *        in case of an error, and PASS otherwise.
   * @param p_ret Current execution status
   */
  function f_setVerdict ( FncRetCode p_ret ) {
    if ( p_ret == e_success ) {
      setverdict(pass);
    } else if ( p_ret == e_timeout ) {
      setverdict(inconc);
    } else {
      setverdict(fail);
    }
  } // end function f_setVerdict


  /**
   * @desc  This function should be used for verdict
   *        setting after completion of a preamble
   *        execution.
   *        Sets verdicts are INCONC in case of a timeout or
   *        an error, and PASS otherwise.
   * @param p_ret Preamble execution status
   */
  function f_setVerdictPreamble ( FncRetCode p_ret ) {
	log("f_setVerdictPreamble: This function is deprecated. Use f_setVerdictPreOrPostamble instead. ");
    f_setVerdictPreOrPostamble(p_ret);
  } // end function f_setVerdictPreamble


  /**
   * @desc  This function should be used for verdict
   *        setting after completion of a postamble
   *        execution.
   *        Sets verdicts are INCONC in case of a timeout or
   *        an error, and PASS otherwise.
   * @param p_ret Postamble execution status
   */
  function f_setVerdictPostamble ( FncRetCode p_ret ) {
	log("f_setVerdictPostamble: This function is deprecated. Use f_setVerdictPreOrPostamble instead. ");
    f_setVerdictPreOrPostamble(p_ret);
  } // end function f_setVerdictPostamble

  /**
   * @desc 	This function should be used for verdict
	 *			  setting outside the test body.
	 *		    Sets verdicts are INCONC in case of a timeout or
	 *        an error
	 * @param p_ret Postamble execution status
	 */
	function f_setVerdictPreOrPostamble ( FncRetCode p_ret ) {
		if ( p_ret != e_success ) {
			setverdict(inconc);
		} 
	} // end function f_setVerdictPreOrPostamble

} // end module LibCommon_VerdictControl