Yes, you can use the <return> element in a function to return whatever you
want (e.g. a process's RC, or a list of the process's RC and its stderr if
it failed, or map of whatever you wanted, etc). For example:
<return>RC</return>
For more information on a function's <return> element, see section
"return: Return from a Function" in the STAX User's Guide at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_Return.
Then after the <call> of that function, what you returned is provided in
the STAXResult variable. So you can check it's value after the call of
the function. For example:
<parallel>
<sequence>
<call function="'Function1'">[remoteSystem]</call>
<if expr="STAXResult == 0">
<tcstatus result="'pass'"/>
<else>
<tcstatus result="'fail'"/>
</else>
</if>
</sequence>
<sequence>
<call function="'Function2'">[localSystem]</call>
<if expr="STAXResult == 0">
<tcstatus result="'pass'"/>
<else>
<tcstatus result="'fail'"/>
</else>
</if>
</sequence>
</parallel>
Or, if you wanted, in the function(s) where you run the <process> element,
you can use the <tcstatus> element to record a testcase pass or fail based
on the process's RC.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: Prasant Biswal <prasantkubis...@gmail.com>
To: staf-users@lists.sourceforge.net, Sharon Lucas/Austin/IBM@IBMUS,
Date: 09/07/2011 04:33 AM
Subject: [staf-users] How to get the process return code and
compair
Dear Staff users,Sharon
Is it possoble to get the return code of process and compair to get the
pass fail reust:
example:
i have a fun.xml file which has the functions written to run the differnt
exe with required arguments
examples:
Fun.xml:
------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
-----------------------------------------------
<function name="Function1">
<sequence>
<script>
parms = abcd
parms = '%s' % (parms)
</script>
<process>
<location>MachineToRun</location>
<command mode="'shell'">'%s %s'%(Function1,parms)</command>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<log message="1">'Process RC: %s, STAFResult: %s, STAXResult:
%s' % (RC, STAFResult, STAXResult)</log>
<if expr = "RC != 0">
<message>'Error:Something Worng.Please check'</message>
<else>
<message>'Executed successfully'</message>
</else>
</if>
<script>rc1= RC</script>
<return>rc1</return>
<log message="1">rc1</log>
</sequence>
</function>
-----------------------------------------
<function name="Function2">
<sequence>
<script>
parms = cdef
</script>
<process>
<location>MachineToRun1</location>
<command mode="'shell'">'%s %s'%(Function2,parms)</command>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<log message="1">'Process RC: %s, STAFResult: %s, STAXResult: %s' %
(RC, STAFResult, STAXResult)</log>
<log message="1">'Process RC: %s' %(RC)</log>
<if expr = "RC != 0">
<message>'Error:Something Worng.Please check'</message>
<else>
<message>'Executed successfully'</message>
</else>
</if>
<script>rc2= RC</script>
<log message="1">rc2</log>
<return>rc2</return>
</sequence>
</function>
----------------------------------------
----------------------------------------
TC.xml: This file calls (only calls) the functions written in fun.xml
(Fun.xml will run the process (exe) and retuns the RC of the process ,
but i can not use those RC in TC.xml to compair and get the status pass or
fail, i need to decied (pass,fail) that in TC.xml)
--------
<function name="main">
<sequence>
<import machine="ImportMachine" file="File1"/>
<import machine="ImportMachine" file="File2"/>
<testcase name = "'TC1'">
<sequence>
<parallel>
<call function="'Function1'">[remoteSystem]</call>
<call function="'Function2'">[localSystem]</call>
</parallel>
from here how can i get the return code of the process ran on fun.xml and
compair to get decide the test case pass or fail.
is it possible to get the process return code from fun.xml in this TC.xml
and compair return codes in TC.xml to get the pass or fail result for each
test
case.
<if expr ="'RC1' == 'RC2' == 0">
<!--<if expr = "'RC==0'">-->
<tcstatus result = "'PASS'"/>
<else>
<tcstatus result = "'Fail'"/>
Please help me to solve this. Is there any other method to procees on
this.
------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users