#!/bin/csh
# Motif
#
# Copyright (c) 1987-2012, The Open Group. All rights reserved.
#
# These libraries and programs are free software; you can
# redistribute them and/or modify them under the terms of the GNU
# Lesser General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# These libraries and programs are distributed in the hope that
# they will be useful, but WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with these librararies and programs; if not, write
# to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
# Floor, Boston, MA 02110-1301 USA
#
# HISTORY
#!/bin/csh
# a known restriction of this script is that the arguments to -xrm (or
# any other flag!) must contain no spaces.
# revision history
# 11/21/91 libby always output RUN_ouput and move $status check
# 12/21/91 libby pass through flags to tests and change meaning
# of modes (now: "compare" by default; "record = -r";
# "nocompare = -c"
# 12/31/91 libby quote "$arglist"
# 12/31/91 msr remove this unexplainable quote
# 1/17/92 libby modify msr's date and remove unneeded code re .prt's
#
# XFILESEARCHPATH mechanism for using the defaults file in each directory.
# First check to see if the variable is already set. If it is, save it.
# The, set XFILESEARCHPATH to $cwd/$cwd:t.defaults.
#
printenv XFILESEARCHPATH
if ($status == 0) then
set Storepath = $XFILESEARCHPATH
set pathExists = true
endif
setenv XFILESEARCHPATH $cwd/$cwd:t.defaults
# default vars
onintr Cleanup
set mode = compare
set Vistarun = false
set totalVista = false
#
# The following are Purify RUN related variables
#
# The format for specifying will be as follows:
#
# RUN -memory <memory_switch>
#
# The various values of "memory_switch" and their meanings are as follows:
#
# -all - Log the complete Purify output
# -leaks - Log only memoryleaks
# -fm - Log only Freed Memory Read (Write) access errors
# -um - Log only Uninintialized Memory Read (Write) access errors
# -ab - Log only Array Bound Read (Write) access errors
# -fu - Log only Freed and Uninintialized Memory access errors
# -fa - Log only Freed and Array Bound Memory access errors
# -ua - Log only Uninintialized and Array Bound Memory access errors
# -nocopy - Don't copy a .purify file in your current directory. If you
# have a customized .purify in your current directory, it will
# use it, else it will act as -all.
#
# All of the above will have memory leak information along with the
# specified information. Memory leak information will need to be
# stripped out with all the cases other than "-all" and "-leaks"
#
set Purifyrun = false
set memoryInfo = "-all"
# The following are report generation related RUN variables.
# The format for specifying will be as follows:
#
# RUN -genrep <report_switch>
# -Dir -Generates a directory level report
# -test -Generates a test level report
# -panel -Generates a panel level report
#
#
set Reportrun = false
set reportInfo = "-test"
set argcnt = $#argv
set argindex = 1
while ($argcnt != 0)
switch ($argv[$argindex])
case -r*:
set mode = record
breaksw
case -c*:
set mode = nocompare
breaksw
case -bfa*:
set Vistarun = true
set argv[$argindex] = ""
breaksw
case -BFA*:
set Vistarun = true
set totalVista = true
set argv[$argindex] = ""
breaksw
case -memory:
set Purifyrun = true
set argv[$argindex] = ""
@ argcnt--
@ argindex++
set memoryInfo = $argv[$argindex]
set argv[$argindex] = ""
breaksw
case -d*:
@ argcnt--
@ argindex++
setenv DISPLAY $argv[$argindex]
breaksw
case -genrep:
set Reportrun = true
set argv[$argindex] = ""
@ argcnt--
@ argindex++
set reportInfo = $argv[$argindex]
set argv[$argindex] = ""
breaksw
endsw
@ argcnt--
@ argindex++
end
set arglist = "$argv"
# Counter used for setting up Purify environment first time around
@ count = 0
@ Total_Test_Num = 0
echo "Mode is " $mode
if ($Vistarun == true) then
echo "This is a Vista RUN"
endif
# clean up from previous runs
if (-e ./RUN_failures) then
echo "backing up RUN_failures file"
mv RUN_failures RUN_failures.bak
endif
touch RUN_failures
if (-e ./RUN_output) then
echo "backing up output file"
mv RUN_output RUN_output.bak
endif
touch RUN_output
if (-e .TotalTests) then
rm -f .TotalTests
endif
touch .TotalTests
rm -f core
if ($Vistarun == true) then
ls *.metg >& /dev/null
if ($status == 0) then
rm -f *.metg
endif
ls *.audg >& /dev/null
if ($status == 0) then
rm -f *.audg
endif
ls *.covg >& /dev/null
if ($status == 0) then
rm -f *.covg
endif
endif
# set the path so that scripts for report generation can be read
set path = (/project/motif/qa/qauser/qatools/auto_rep $path)
# noglob is needed to handle special cases
set noglob
# special cases. Specify ALL flags for tests which require them.
# remember all arguments MUST be a single word (ie no spaces)
# use single quotes around the right side.
# START CUSTOMIZE #
<Customize>
# END CUSTOMIZE #
if ($count == 0 && $Purifyrun == true) then
if (-e .purify.bak) then
rm -f .purify.bak
endif
if ($memoryInfo == -nocopy) then
if (-e .purify) then
echo "Using the local .purify" >> RUN_output
endif
else
if (-e .purify) then
mv .purify .purify.bak
endif
endif
echo "This is a Purify RUN" >> RUN_output
if ($mode == compare) then
echo "No .prt comparison will be done at the end" >> RUN_output
endif
switch($memoryInfo)
case -all:
cp $TOP/tests/memory/.purify.all .purify
breaksw
case -fm:
cp $TOP/tests/memory/.purify.fm .purify
breaksw
case -um:
cp $TOP/tests/memory/.purify.um .purify
breaksw
case -ab:
cp $TOP/tests/memory/.purify.ab .purify
breaksw
case -leaks:
cp $TOP/tests/memory/.purify.leaks .purify
breaksw
case -fu:
cp $TOP/tests/memory/.purify.fu .purify
breaksw
case -fa:
cp $TOP/tests/memory/.purify.fa .purify
breaksw
case -ua:
cp $TOP/tests/memory/.purify.ua .purify
breaksw
endsw
@ count++
endif
set test =($test)
@ Total_Test_Num++
foreach word ($test)
if ($?name_flag) then
set test_output = $word
unset name_flag
endif
if ("$word" =~ "-O") then
set name_flag = 1
endif
end
if ($Vistarun == true) then
if !(-e $TOP/tests/Vista/libXm.M) then
echo "Map file libXm.M not found in $TOP/tests/Vista" >> RUN_output
echo "No Vista reports generated" >> RUN_output
set Vistarun = false
endif
endif
if ($Vistarun == true) then
set testname = `echo $test | awk '{print $1}'`
endif
if ($Purifyrun == true) then
if ($?test_output) then
set testname = `echo $test_output | awk -F'.' '{print $1}'`
else
set testname = `echo $test | awk '{print $1}'`
endif
endif
if ($Purifyrun == true) then
if (-e $testname.purify) then
mv -f $testname.purify $testname.purify.bak
endif
setenv PURIFYLOGFILE $testname.purify
endif
echo "" >> RUN_output
echo "Beginning test " $test[1] >> RUN_output
echo "Beginning test " $test[1]
#
# If totalVista == true, only one "hits" file will be generated for the
# whole directory and a total coverage report for the directory as a whole
# will be generated
#
if ($Vistarun == true && $totalVista == false) then
set HIT_FILE = $TOP/tests/Vista/$testname.hits
if (-e ${HIT_FILE}) then
rm -f ${HIT_FILE}
endif
endif
if ($Purifyrun == true) then
if (-e $testname.purify) then
rm -f $testname.purify
endif
setenv PURIFYLOGFILE $testname.purify
endif
if ($?test_output) then
echo "Output redirected to " $test_output
echo "Output redirected to " $test_output >> RUN_output
endif
# try to prevent it quitting if the test wasn't built
if (-e $test[1]) then
echo "Running " $test $arglist
$test $arglist
if ($status != 0) then
if (-e core) then
echo "backing up core to "$test[1]".core"
mv core $test[1].core
endif
echo "failure in test: "$test[1] >> RUN_failures
echo "FAILURE IN TEST: "$test[1] >> RUN_output
echo "FAILURE IN TEST: "$test[1]
else if ($Vistarun == true && $totalVista == false) then
if (-e hits) then
mv hits ${HIT_FILE}
if (-e $testname.metg) then
MetGen $TOP/tests/Vista/libXm.M \
./$testname.M >> $testname.metg
AudGen -T $testname.tally $TOP/tests/Vista/libXm.M \
./$testname.M \
${HIT_FILE} >> $testname.audg
CovGen $TOP/tests/Vista/libXm.M \
./$testname.M \
$testname.tally >> $testname.covg
else
MetGen $TOP/tests/Vista/libXm.M \
./$testname.M > $testname.metg
AudGen -T $testname.tally $TOP/tests/Vista/libXm.M \
./$testname.M \
${HIT_FILE} > $testname.audg
CovGen $TOP/tests/Vista/libXm.M \
./$testname.M \
$testname.tally > $testname.covg
endif
rm ${HIT_FILE}
rm $testname.tally
endif
unset HIT_FILE
unset testname
else if ($Purifyrun == true) then
unsetenv PURIFYLOGFILE
endif
else
echo "Error - Test " $test " does not exist."
echo "Error - Test " $test " does not exist" >> RUN_output
continue
endif
#we only need to do this in compare and manual modes
if ($mode != record) then
if ($?test_output) then
cat $test_output >> RUN_output
else
cat $test[1].prt >> RUN_output
endif
endif
echo "Ending test "$test[1]"" >> RUN_output
echo "" >> RUN_output
echo "Ending test "$test[1]""
echo ""
unset test_output
end
unset noglob
#
# if totalVista is true, generate the overall coverage report for the
# directory
#
if ($Vistarun == true && $totalVista == true) then
set dirname = `echo $cwd | awk -F '/' '{print $NF}'`
if (-e hits) then
MetGen $TOP/tests/Vista/libXm.M *.M > $dirname.metg
AudGen -T $dirname.tally $TOP/tests/Vista/libXm.M *.M \
hits > $dirname.audg
CovGen $TOP/tests/Vista/libXm.M *.M $dirname.tally > $dirname.covg
else
echo "No hits file generated"
endif
endif
# the .prt files are now automatically written in $AUTOVPATH in record mode
if ($mode == compare) then
if ($Purifyrun == false) then
#compare number of *.prt files in both places only if not Purify RUN
set prts_here = `ls -l ./*.prt | wc -l`
set prts_there = `ls -l $AUTOVPATH/*.prt | wc -l`
if ($prts_here > $prts_there) then
echo "There are .prt files missing in " $AUTOVPATH >> RUN_failures
echo "There are .prt files missing in " $AUTOVPATH
else if ($prts_there > $prts_here) then
echo "There are .prt files missing in " $cwd >> RUN_failures
echo "There are .prt files missing in " $cwd
endif
foreach file ($AUTOVPATH/*.prt)
if (-e $cwd/$file:t) then
diff $file $cwd/$file:t > $file:t.diff
mv $file:t.diff $file:t.err
else
echo "No "$file:t file found in $AUTOVPATH >> RUN_output
echo "No "$file:t file found in $AUTOVPATH
endif
end
endif
endif
#
# If Purifyrun, Generate memory related reports
#
if ($Purifyrun == true) then
GetLeaks
endif
Cleanup:
# remove empty .err files of no interest
if ($mode != nocompare) then
set num_errfiles = `ls -l *.err | wc -l`
if ($num_errfiles) then
foreach errfile (*.err)
sed -e '/^$/d' $errfile > $errfile.stp
rm $errfile
if !(-z $errfile.stp) then
mv $errfile.stp $errfile
else
rm $errfile.stp
endif
end
endif
echo "Automated run of directory" $cwd:t " complete" >> RUN_output
endif
# if Reportrun is true, generate reports of the appropriate level.
if ($Reportrun == true) then
echo "This is a Report RUN" >> RUN_output
switch($reportInfo)
case -Dir:
run_dir $cwd
breaksw
case -test:
foreach difffile ($cwd/*.err)
run_test -file $difffile
end
breaksw
case -panel:
foreach difffile ($cwd/*.err)
run_panel $difffile
end
breaksw
endsw
endif
#
# If Vista build but not Vista report generating RUN, remove hits file
#
if (-e hits) then
rm -f hits
endif
echo $Total_Test_Num >> .TotalTests
# Reset XFILESEARCHPATH
if (pathExists == true) then
setenv XFILESEARCHPATH $Storepath
else
unsetenv XFILESEARCHPATH
endif
exit 0