diff options
author | kevinrs <kevinrs> | 2005-12-23 21:09:32 +0000 |
---|---|---|
committer | kevinrs <kevinrs> | 2005-12-23 21:09:32 +0000 |
commit | f9f5199fb819ca7897ef895f9a4a86aecb147446 (patch) | |
tree | 290f03232fdcb1f16fc21af062fa4725fc96c5d9 /tapset/test/run.sh | |
parent | d003aa24c4f339bdfc2b2e87ac0ba16b09cf221e (diff) | |
download | systemtap-steved-f9f5199fb819ca7897ef895f9a4a86aecb147446.tar.gz systemtap-steved-f9f5199fb819ca7897ef895f9a4a86aecb147446.tar.xz systemtap-steved-f9f5199fb819ca7897ef895f9a4a86aecb147446.zip |
2005-12-23 Kevin Stafford <krstaffo@us.ibm.com>
SCRIPTS:
run.sh - This is the driver for automated testing.
To run: ./run.sh stpdirectory c_binaries_directory
Result: log/timestamp.log discerpancy report
ctostp.sh - This script generates corresponding stp probe script
files for every C file found in the input directory.
To Run: ctostp.sh input output where input is the
directory containing the C files to convert. Output
is the directory to store the corresponding stp
files.
build.sh - This script expedites the process of compiling all
of the c files. When the "compile" flag is given
it creates a directory called bin, which stores the
compiled C programs. ./build.sh clean removes the
binaries, and ./build.sh run attempts to execute all
of the programs in cfiles/bin.
Diffstat (limited to 'tapset/test/run.sh')
-rwxr-xr-x | tapset/test/run.sh | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/tapset/test/run.sh b/tapset/test/run.sh new file mode 100755 index 00000000..c842c72d --- /dev/null +++ b/tapset/test/run.sh @@ -0,0 +1,150 @@ +function usage { + echo -ne " \033[1mUsage:\033[0m run stpdir bindir\n" + echo -ne " \033[1mstpdir:\033[0m\n" + echo -ne "\tthe directory containing the stp files\n" + echo -ne " \033[1mbindir:\033[0m\n" + echo -ne "\tthe directory containing the c executables\n" + exit +} +function cleanup { + rm -f tmp* +} +function even { + k=$1 + while [ $k -ne $2 ]; do + if [ $# -eq 3 ]; then + echo -ne " " >> $logfile + else + echo -ne " " + fi + k=`expr $k + 1` + done +} +function spit { + echo -ne "\t\t\tFUNCTION: `echo $1 | cut -d"." -f4`\n" >> $logfile + echo "Expected output:" >> $logfile + cat $2 >> $logfile + echo "Actual output:" >> $logfile + cat $1 >> $logfile + echo -ne "___________________________________" >> $logfile + echo "___________________________________" >> $logfile +} +function spiteven { + echo -ne "\t\t\tFUNCTION: `echo $1 | cut -d"." -f4`\n" >> $logfile + echo -ne "Expected Output:\t\t\t\tActual Output:\n" >> $logfile + i=1 + lines=`cat $1|wc -l` + while [ $i -le $lines ]; do + echo -ne "`head -$i $2|tail -1`" >> $logfile + even `head -$i $2|tail -1|wc -m` 49 9 + echo -ne "`head -$i $1|tail -1`\n" >> $logfile + i=`expr $i + 1` + done + echo -ne "___________________________________" >> $logfile + echo "___________________________________" >> $logfile +} +trap got_trap 1 2 3 6 +function got_trap { + echo -e "\nGot signaled. Cleaning up...\n" + if [ `ps -A|grep stpd|sed 's/^[ ^t]*//'|cut -d" " -f1 | wc -l` -gt 0 ] + then + kill `ps -A|grep stpd|sed 's/^[ ^t]*//'|cut -d" " -f1` + fi + if [ `ps -A|grep stap|sed 's/^[ ^t]*//'|cut -d" " -f1 | wc -l` -gt 0 ] + then + kill `ps -A|grep stap|sed 's/^[ ^t]*//'|cut -d" " -f1` + fi + cleanup + exit 1 +} +function waitforoutput { + t=0 + while [ `cat $1|wc -l` -eq 0 -a $t -ne 4 ]; do + sleep 1 + t=`expr $t + 1` + done + if [ $t -eq 4 ]; then + even 1 3 + echo -en "\033[0;36mPROBEMISS\033[0m\n" + failures=`expr $failures + 1` + #spit $1 $2 + else + validate $1 $2 + fi +} +function validate { + if [ `diff $1 $2|wc -l` -gt 0 ]; then + even 1 3 + echo -en "\033[0;31mFAIL\033[0m\n" + failures=`expr $failures + 1` + if [ `cat $1|wc -l` -eq `cat $2|wc -l` ]; then + spiteven $1 $2 + else + spit $1 $2 + fi + else + even 1 3 + echo -en "\033[0;32mPASS\033[0m\n" + fi +} +# start +++++++++++++++++++++++++++++++++++ +stpdir=`echo $1|sed -e 's/\/$//'` +bindir=`echo $2|sed -e 's/\/$//'` +# sanity... +if [[ ! -d $stpdir || ! -d $bindir ]]; then + echo "Invalid arguments. Try again." + usage +elif [ `ls $stpdir/*.stp|wc -l` -le 0 ]; then + echo "No .stp files found in $stpdir" + exit +elif [ `ls $bindir/|wc -l` -le 0 ]; then + echo "No executable files found in $bindir" + exit +elif [ $UID -ne 0 ]; then + echo "You must be root to do that!" + exit +elif [ ! -d log ]; then + mkdir log +fi + +total=`ls $stpdir|wc -l` +logfile=log/`date +%m%d%y_%H%M%S`.log +clear +echo -en "Prog\t\tScript" +echo -e "\t\t\t\t Status" + +# iterate through script files +ct=1 +failures=0 +for i in `ls $stpdir` +do + # create some tmp files for output + stp_tmpf="tmp.stp.$$.$i" + c_tmpf="tmp.c.$$.$i" + echo -ne "$ct/$total:\t" + if [ $ct -lt 100 ]; then + echo -ne "\t" + fi + echo -ne $i + #insmod the ko + stap -DMAXNESTING=10 $stpdir/$i > $stp_tmpf & + # make sure module is loaded + pid=""; ast="" + while [[ "$pid" == "" || "$ast" == "" ]] + do + pid=`ps|grep stpd|sed 's/^[ ^t]*//'|cut -d" " -f1` + ast=`ps|grep stap|sed 's/^[ ^t]*//'|cut -d" " -f1` + sleep 1 + done + even `echo $i|wc -m` 30 + echo -n "+++" + # now we can safely run the user c program + su -c "./$bindir/e_`echo $i|cut -d"." -f1` > $c_tmpf" krstaffo + # kill off stap + kill $pid + # give it some breathing room + waitforoutput $stp_tmpf $c_tmpf + ct=`expr $ct + 1` + cleanup +done +echo "Total Failures: $failures/$total" |