Blame tests/General/RUN_template

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