Blame tests/General/RUN_template.Man

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
# 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
# default vars
Packit b099d7
Packit b099d7
set arglist = "$argv"
Packit b099d7
set Vistarun = false
Packit b099d7
set totalVista = false
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
#
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
set argcnt = $#argv
Packit b099d7
set argindex = 1
Packit b099d7
while ($argcnt != 0)
Packit b099d7
    switch ($argv[$argindex])
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
    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
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 ($Purifyrun == true) then
Packit b099d7
    echo "This is a Purify RUN" >> RUN_output
Packit b099d7
endif
Packit b099d7
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
# 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
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 (-e .purify) then
Packit b099d7
        mv .purify .purify.bak
Packit b099d7
    endif
Packit b099d7
    echo "This is a Purify RUN" >> RUN_output
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
    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            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
    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
# 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
            unset testname
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
    echo "Ending test "$test[1]"" >> RUN_output
Packit b099d7
    echo "" >> RUN_output
Packit b099d7
    echo "Ending test "$test[1]""
Packit b099d7
    echo ""
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
#
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
exit 0