| | |
| | | </sequence> |
| | | </function> |
| | | |
| | | <function name="runFunction"> |
| | | <function-map-args> |
| | | <function-arg-def name="functionName" type="required"> |
| | | <function-arg-description> |
| | | Name of the function to run |
| | | </function-arg-description> |
| | | </function-arg-def> |
| | | |
| | | <function-arg-def name="functionArguments" type="optional"> |
| | | <function-arg-description> |
| | | Arguments to be passed on to the called function. |
| | | This can be a map or a list of arguments, whatever the called function |
| | | expects will be carried on here. |
| | | . for a map, pass the arguments like this: |
| | | { 'argumentA' : 'argumentAvalue' , |
| | | 'argumentB' : 1 , |
| | | ... |
| | | } |
| | | . for a list, pass the arguments like this: |
| | | [ 'argumentAvalue, 1, ... ] |
| | | </function-arg-description> |
| | | </function-arg-def> |
| | | |
| | | <function-arg-def name="expectedRC" type="optional" default="0"> |
| | | <function-arg-description> |
| | | The expected return code of the function to run. |
| | | This is then passed onto the checkRC function. |
| | | It is also used to throw an exception if the argument |
| | | functionException is provided and set the test case status if the |
| | | argument functionSetsTCStatus is provided |
| | | </function-arg-description> |
| | | <function-arg-property name="type" value="integer"/> |
| | | </function-arg-def> |
| | | |
| | | <function-arg-def name="functionException" type="optional"> |
| | | <function-arg-description> |
| | | The exception to throw if the return code differs from the expected |
| | | RC. The exception is appended to STAXException. |
| | | </function-arg-description> |
| | | </function-arg-def> |
| | | |
| | | <function-arg-def name="functionMessage" type="optional"> |
| | | <function-arg-description> |
| | | An optional message to display before running the function |
| | | </function-arg-description> |
| | | </function-arg-def> |
| | | |
| | | <function-arg-def name="functionSetsTCStatus" type="optional"> |
| | | <function-arg-description> |
| | | Whether the function to run sets the testcase status or not. |
| | | If this is set, the test case status is set according to whether |
| | | or not the function meets the expected return code. |
| | | True or False should be used for this argument. |
| | | </function-arg-description> |
| | | </function-arg-def> |
| | | </function-map-args> |
| | | <sequence> |
| | | <script> |
| | | <!-- defining the booleans here should temporary while I find a nicer |
| | | solution. We have a chicken and egg problem between the |
| | | loadGlobalEnvironment and loadSharedLibraries functions in |
| | | environment.xml at the moment. |
| | | --> |
| | | if not False: |
| | | False=0 |
| | | |
| | | if not True: |
| | | True=1 |
| | | |
| | | _throwException=False |
| | | if functionException: |
| | | _throwException=True |
| | | |
| | | _displayMessage=False |
| | | if functionMessage: |
| | | _displayMessage=True |
| | | |
| | | _tcStatus='fail' |
| | | _doSetTCStatus=False |
| | | if functionSetsTCStatus: |
| | | _doSetTCStatus=True |
| | | </script> |
| | | <message log="1" level="'info'" if="_displayMessage == True">'%s' % functionMessage</message> |
| | | <message log="1" level="'debug'">'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)</message> |
| | | <call function="'%s' % functionName">functionArguments</call> |
| | | <message log="1" level="'debug'">'runFunction: %s: returned [%s]' % (functionName,RC)</message> |
| | | <script> |
| | | _functionRC = RC |
| | | </script> |
| | | <call function="'checkRC'" > |
| | | { 'returncode' : RC , |
| | | 'result' : STAXResult, |
| | | 'expected' : expectedRC |
| | | } |
| | | </call> |
| | | |
| | | <!-- this section handles the optional case when we need to set the |
| | | test case status |
| | | --> |
| | | <if expr="_doSetTCStatus == True"> |
| | | <sequence> |
| | | <if expr="_functionRC == expectedRC"> |
| | | <script>_tcStatus='pass'</script> |
| | | </if> |
| | | <tcstatus result="_tcStatus" /> |
| | | </sequence> |
| | | </if> |
| | | |
| | | <!-- this section handles the optional case when we need to throw an |
| | | exception upon unexpected function return code |
| | | --> |
| | | <if expr="_throwException == True" > |
| | | <if expr="_functionRC != expectedRC" > |
| | | <throw exception="'STAXException.%s' % functionException" /> |
| | | </if> |
| | | </if> |
| | | |
| | | <!-- bubble the function return code up one level --> |
| | | <return>_functionRC</return> |
| | | </sequence> |
| | | </function> |
| | | |
| | | </stax> |