Hello Eeryone.
I'm trying to write a bash script to make it possible that user could
specify a special test to run. The aim is that when user gives a
parameter, the parameter will be treat as a test name and only
testcases with exactly the same name will be run. If user does not
set any parameter, all test cases will be run.
--------bash script begins---------
#!/bin/bash
#filename: runTest.sh
....
START_FILE=`pwd`/run.xml
....
ARGS="'stafScriptsRoot': '$STAF_SCRIPTS_ROOT'"
if [ "$1" != "" ]; then
ARGS="$ARGS, 'testCode': '$1'"
fi
if [ "$2" != "" ]; then
ARGS="$ARGS, 'incCode': '$2'"
fi
echo $ARGS
echo "Now starting to run STAF tests ..."
STAF LOCAL STAX EXECUTE FILE $START_FILE ARGS "{$ARGS}" JOBNAME QAAF
CLEARLOGS ENABLED WAIT RETURNRESULT
....
--------bash script ends---------
*The content of run.xml please refer to the attachment.
But I met a strange problem in saving logs.
when I simply execute "./runTest.sh", all logs would be
saved to /usr/local/staf/data/STAF/service/log/MACHINE/rplcli/GLOBAL/
but when I give a parameter like "./runTest.sh
Filesystem_Basic_1_1_maintance" , all logs would be saved to
/usr/local/staf/data/Filesystem_Basic_1_1_maintance/service/log/MACHINE/rplcli/GLOBAL/
I have refered to the manual, it said that the log directory was
decided by DATADIR, but I did not change the DATADIR setting.
so it should be {STAF/Config/STAFRoot}/data/{STAF/Config/InstanceName}.
and "STAF/Config/InstanceName"'s default value is "STAF".
so usr/local/staf/data/STAF/service/log/ is correct,
but where dose
/usr/local/staf/data/Filesystem_Basic_1_1_maintance/service/log/ come from?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
<defaultcall function="testSequence"/>
<function name="testSequence" scope="global">
<function-map-args>
<function-optional-arg name="stafScriptsRoot" default="'/home/xxxxx/STAFscripts'"/>
<function-optional-arg name="testCode" default="''">
Code of test to be executed. If not specified all tests will be executed.
</function-optional-arg>
<function-optional-arg name="incCode" default="''">
Code of test incarnation to be executed. If not specified all incarnations will be executed.
</function-optional-arg>
</function-map-args>
<sequence>
<import machine="'local'" file="'library.xml'"/>
<call function="'preTest'"/>
<script>
hydraServerAN2IP="xxx.xxx.xxx.xxx"
from suit_jdom import *
from staf_util import *
suit = testsuit('generic.pro.xml');
#testsuit is class that parse generic.pro.xml and
#
testList = suit.testList;
</script>
<!--script>
testList = suit.get().testList
</script-->
<iterate var="test" in="testList">
<sequence>
<testcase name="test.testName">
<sequence>
<log>"testName = %s"%(test.testName)</log>
<if expr="testCode == '' or test.testName == testCode">
<sequence>
<if expr="incCode == '' or test.incarnation == incCode">
<sequence>
<log>"testName = %s; testInc = %s" %(test.testName, test.incarnation)</log>
<script>
testFile=test.testFile
testScript=stafScriptsRoot+"/tests.staf/tests/"+testFile
userParaList = getParaListFromTestScript(testScript)
if userParaList.count('testCaseName') == 1:
if not test.args.has_key('testCaseName'):
test.args['testCaseName'] = test.testName;
if userParaList.count('windowsServer') == 1:
if not test.args.has_key('windowsServer'):
test.args['windowsServer'] = suit.config.windowsServerName;
if userParaList.count('hydraServer') == 1:
if not test.args.has_key('hydraServer'):
test.args['hydraServer'] = suit.config.hydraServerIP;
if userParaList.count('guiAddress') == 1:
if not test.args.has_key('guiAddress'):
test.args['guiAddress'] = suit.config.GUIAddr;
if userParaList.count('backupServer') == 1:
if not test.args.has_key('backupServer'):
test.args['backupServer'] = suit.config.backupServer;
if userParaList.count('winServer') == 1:
if not test.args.has_key('winServer'):
test.args['winServer'] = suit.config.windowsServerName;
if userParaList.count('backupServerIP') == 1:
if not test.args.has_key('backupServerIP'):
test.args['backupServerIP'] = suit.config.backupServer;
if userParaList.count('hydraServerIP') == 1:
if not test.args.has_key('hydraServerIP'):
test.args['hydraServerIP'] = suit.config.hydraServerIP;
if userParaList.count('GUIAddr') == 1:
if not test.args.has_key('GUIAddr'):
test.args['GUIAddr'] = suit.config.GUIAddr;
</script>
<call function="'execJob'">{'testName': test.testName,'testScript': testScript, 'xmlArgs':test.args}</call>
</sequence>
</if>
</sequence>
</if>
</sequence>
</testcase>
</sequence>
</iterate>
<call function="'postTest'">{'gui': suit.config.GUIAddr}</call>
</sequence>
</function>
</stax>
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users