Tool for Automated Testing P. Sivera European Southern Observatory Garching – January 2007ESO
ALMA Project Garching, January 2007Tool for Automated Testing2 tat tat - Tool for Automated Testing –run multiple tests with one command –produce reproducible output –automatic setup –compare output against reference file(s)
ALMA Project Garching, January 2007Tool for Automated Testing3 How tat works Looks for /test/TestList Redefine LD_LIBRARY_PATH, PYTHONPATH, PATH Executes “make clean all” Source a tcl script for additional env vars Executes a prologue script Executes the tests suite and compare output with the reference Executes an epilogue script Executes “make clean”
ALMA Project Garching, January 2007Tool for Automated Testing4 TestList directives 1.SOURCE 2.PROLOGUE [ ] 3. (1 or more) 4.EPILOGUE [ ] The 3rd directive is the only mandatory one
ALMA Project Garching, January 2007Tool for Automated Testing5 TestList syntax Blank lines are allowed Comment lines start with “#” A test directive can be split on multiple lines => continuation character is “\”
ALMA Project Garching, January 2007Tool for Automated Testing6 Test case syntax [.. ] Ex: 1 mySimpleTest checkCompStatus 2 myComplexTest sendMsg checkCompStatus setParam makeCrash 3 myComplexTest sendMsg 10” checkCompStatus 10” “setParam 3” 10” makeCrash
ALMA Project Garching, January 2007Tool for Automated Testing7 Cookbook - 1 getTemplate for MODROOT getTemplate for Makefile under test getTemplate for script/program update Makefile write/try the script/program prepare TestList
ALMA Project Garching, January 2007Tool for Automated Testing8 Cookbook – 2 create reference file: $ tat –g testscript Reference file acstHello.sh.ref generated Reference file generated. run the test: $ tat testscript TEST acstHello.sh PASSED. PASSED.
ALMA Project Garching, January 2007Tool for Automated Testing9 How to deal with the CDB Create directory: test/CDB Put your CDB files Redefine environment variable: ACS_CDB=`pwd` (in the SOURCE script)
ALMA Project Garching, January 2007Tool for Automated Testing10 How to run tat Run as –tat (make all, source, prologue, test suite, compare with ref, epilogue, make clean) or –tat makeEnv (make all, source, prologue) –tat or tat –tat cleanEnv (epilogue, make clean)
ALMA Project Garching, January 2007Tool for Automated Testing11 Some options -v to run tat in verbose mode -nc (not clean) to run “make all” and not “make clean all” -f to use another different testlist besides the TestList
ALMA Project Garching, January 2007Tool for Automated Testing12 Files and log files TestList.grep → grep –v –f TestList.grep TestList.sed → sed –f TestList.sed test/tatlogs/run$$ →.out, out.orig and.diff (.diff is the unix diff between.ref and.out)
ALMA Project Garching, January 2007Tool for Automated Testing13 Example of SOURCE SOURCE needs a tcl script under test dir Add a line in TestList.lite: SOURCE.tcl Write the file: set env(VARIABLE) WHATEVER
ALMA Project Garching, January 2007Tool for Automated Testing14 Example of prologue #! /bin/bash acsStart > $ACS_TMP/acsStart.log 2>&1 & sleep 3 acsStartContainer bilboContainer >$ACS_TMP2/bilbo.log 2>&1 & sleep 3 See standard prologue: $ACSROOT/bin/acsutilTATPrologue
ALMA Project Garching, January 2007Tool for Automated Testing15 Example of epilogue #! /bin/bash acsStopContainer bilboContainer >bilboStop.log 2>&1 sleep 3 acsStop >acsStop.log 2>&1 sleep 3 See standard epilogue: $ACSROOT/bin/acsutilTATEpilogue