Blame maint/createcoverage.in

Packit 0848f5
#! /bin/sh
Packit 0848f5
#
Packit 0848f5
# Get coverage information for mpich
Packit 0848f5
#
Packit 0848f5
#set -x
Packit 0848f5
# The default approach is to prepare the coverage for this MPICH 
Packit 0848f5
# distribution and to place the coverage web pages into a 
Packit 0848f5
# (mpichsrc)/www/coverage
Packit 0848f5
srcdir=@abs_mpichsrcdir@
Packit 0848f5
tsuites=$srcdir/tests/mpi
Packit 0848f5
weblocbase=$srcdir/www/coverage
Packit 0848f5
weblocprefix=""
Packit 0848f5
blddir=/tmp/$LOGNAME/mpich-cov
Packit 0848f5
mpiinstalldir=/tmp/$LOGNAME/mpich-cinst
Packit 0848f5
Packit 0848f5
logfile=""
Packit 0848f5
#pm=gforker
Packit 0848f5
pm=hydra
Packit 0848f5
# device and channel
Packit 0848f5
# (we'll also want this to be in the path)
Packit 0848f5
device="ch3:sock"
Packit 0848f5
Packit 0848f5
test_intel=yes
Packit 0848f5
test_mpich=yes
Packit 0848f5
test_mpich1=yes
Packit 0848f5
test_cxx=yes
Packit 0848f5
test_io=yes
Packit 0848f5
testNames="intel mpich1 mpich cxx io"
Packit 0848f5
build_mpich=yes
Packit 0848f5
alltest=yes
Packit 0848f5
update_web=yes
Packit 0848f5
quiet=no
Packit 0848f5
#
Packit 0848f5
# Process args to see if we are running only a subset of the steps, 
Packit 0848f5
# for example, to rerun a test suite
Packit 0848f5
for arg ; do 
Packit 0848f5
    # Extract option, if any
Packit 0848f5
    case $arg in 
Packit 0848f5
    *=*)
Packit 0848f5
    option=`echo A$arg | sed -e 's/^[^=]*=//'`
Packit 0848f5
    ;;
Packit 0848f5
    *)
Packit 0848f5
    option=""
Packit 0848f5
    ;;
Packit 0848f5
    esac
Packit 0848f5
Packit 0848f5
    case $arg in 
Packit 0848f5
    -nobuild)
Packit 0848f5
    build_mpich=no
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -quiet)
Packit 0848f5
    quiet=yes
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -logfile=*)
Packit 0848f5
    logfile=$option
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -srcdir=*)
Packit 0848f5
    srcdir=$option
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -device=*)
Packit 0848f5
    device=$option
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -pm=*)
Packit 0848f5
    pm=$option
Packit 0848f5
    ;; 
Packit 0848f5
Packit 0848f5
    -test=*)
Packit 0848f5
    if [ $alltest = yes ] ; then
Packit 0848f5
        alltest=no
Packit 0848f5
	test_intel=no
Packit 0848f5
	test_mpich1=no
Packit 0848f5
	test_mpich=no
Packit 0848f5
	test_io=no
Packit 0848f5
	test_cxx=no
Packit 0848f5
    fi
Packit 0848f5
    name=`echo A$arg | sed -e 's/A-test=//'`
Packit 0848f5
    eval test_$name=yes
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -notest=*)
Packit 0848f5
    # Turn off just one test
Packit 0848f5
    alltest=no
Packit 0848f5
    name=`echo A$arg | sed -e 's/A-notest=//'`
Packit 0848f5
    eval test_$name=no
Packit 0848f5
    ;;
Packit 0848f5
    
Packit 0848f5
    -notest)
Packit 0848f5
    alltest=no
Packit 0848f5
    test_intel=no
Packit 0848f5
    test_mpich1=no
Packit 0848f5
    test_mpich=no
Packit 0848f5
    test_io=no
Packit 0848f5
    test_cxx=no
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -blddir=*)
Packit 0848f5
    blddir=`echo A$arg | sed -e 's/A-blddir=//'`
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -noupdateweb)
Packit 0848f5
    update_web=no
Packit 0848f5
    ;;
Packit 0848f5
    -updateweb)
Packit 0848f5
    update_web=yes
Packit 0848f5
    ;;
Packit 0848f5
    -webdir)
Packit 0848f5
    weblocbase=$option
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -help)
Packit 0848f5
    cat <
Packit 0848f5
createcoverage [ -srcdir=sourcedir ] [ -blddir=builddir ] 
Packit 0848f5
               [ -test=onetest ] [ -notest=skiptest ]
Packit 0848f5
               [ -device=device ] [ -nobuild ] [ -quiet ] [ -pm=pm ]
Packit 0848f5
               [ -[no]updateweb ] [ -webdir=webdir ]
Packit 0848f5
     sourcedir   - Directory containing the source  for MPICH.
Packit 0848f5
                   Default is $srcdir
Packit 0848f5
     blddir      - Directory where the coverage tests should be built.
Packit 0848f5
                   Default is $blddir
Packit 0848f5
     onetest     - Run only this test suite.  Available tests are
Packit 0848f5
                   $testNames
Packit 0848f5
     skiptest    - Skip this test suite.
Packit 0848f5
     device      - Device to test.  Default is $device
Packit 0848f5
     pm          - Select the process manager.  Default is $pm
Packit 0848f5
     -updateweb  - Update the web page containing the single file listing
Packit 0848f5
                   at $weblocbase/$device/coverage.txt
Packit 0848f5
     webdir      - Directory into which to place the web pages.
Packit 0848f5
                   The default is $weblocbase 
Packit 0848f5
                   (the final directory is webdir/$device ).
Packit 0848f5
EOF
Packit 0848f5
    exit 1;
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    *)
Packit 0848f5
    echo "Argument $arg unrecognized"
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    esac
Packit 0848f5
done
Packit 0848f5
Packit 0848f5
# Move everthing into a device-specific directory
Packit 0848f5
webloc="$weblocbase/$device"
Packit 0848f5
if [ "$update_web" = yes ] ; then
Packit 0848f5
    if [ ! -d $webloc ] ; then mkdir -p $webloc ; fi
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# Set the derived directories
Packit 0848f5
annotedir=$webloc
Packit 0848f5
if [ -n "$weblocprefix" ] ; then
Packit 0848f5
    # Only add device to the location if we are not using relative paths
Packit 0848f5
    # for the web pages
Packit 0848f5
    annotewebprefix="$weblocprefix/$device"
Packit 0848f5
fi
Packit 0848f5
annoteindex=$webloc/index.htm
Packit 0848f5
# Locations of the test directories
Packit 0848f5
mpichsrcdir=$srcdir/Test/mpi
Packit 0848f5
intelsrcdir=$tsuites/IntelMPITEST
Packit 0848f5
mpich1srcdir=$tsuites/mpich1test
Packit 0848f5
cxxsrcdir=$tsuites/mpicxxtest
Packit 0848f5
iosrcdir=$tsuites/Testmpio
Packit 0848f5
Packit 0848f5
# For each of the tests selected, turn off those for which the 
Packit 0848f5
# test source directories are not available
Packit 0848f5
for test in $testNames ; do
Packit 0848f5
    eval t="test_$test"
Packit 0848f5
    eval tval=\$$t
Packit 0848f5
    if [ "$tval" = yes ] ; then
Packit 0848f5
        eval tloc=\$${test}srcdir
Packit 0848f5
        if [ ! -d "$tloc" ] ; then
Packit 0848f5
            echo "Turning off test $test because test source directory $tloc is not available"
Packit 0848f5
	    eval $t=no
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
done
Packit 0848f5
Packit 0848f5
# Compute the appropriate device directories
Packit 0848f5
# Base directories
Packit 0848f5
case $device in
Packit 0848f5
    ch3|ch3:nemesis)
Packit 0848f5
    devsrcdirs="src/mpid/ch3/channels/nemesis/src src/mpid/ch3/src src/mpid/ch3/channels/nemesis/netmod/tcp src/mpid/ch3/channels/nemesis/netmod/none"
Packit 0848f5
    extra_opts="$extra_opts --enable-nemesis-dbg-localoddeven"
Packit 0848f5
    ;;
Packit 0848f5
    ch3:sock)
Packit 0848f5
    devsrcdirs="src/mpid/ch3/channels/sock/src src/mpid/ch3/src src/mpid/common/sock/poll src/mpid/ch3/util/sock"
Packit 0848f5
    ;;
Packit 0848f5
    ch3*)
Packit 0848f5
    devsrcdirs="src/mpid/ch3/src"
Packit 0848f5
    ;;
Packit 0848f5
    *)
Packit 0848f5
    if [ -d "$srcdir/src/mpid/$device" ] ; then
Packit 0848f5
        devsrcdirs="src/mpid/$device"
Packit 0848f5
    fi
Packit 0848f5
    ;;
Packit 0848f5
esac
Packit 0848f5
Packit 0848f5
# Set a timeout for mpiexec just in case
Packit 0848f5
MPIEXEC_TIMEOUT=180
Packit 0848f5
export MPIEXEC_TIMEOUT
Packit 0848f5
#
Packit 0848f5
# We use fd 6 to redirect output.  If we have selected "-quiet", this
Packit 0848f5
# sends stdout to /dev/null 
Packit 0848f5
if [ "$quiet" = yes ] ; then
Packit 0848f5
    exec 6>/dev/null
Packit 0848f5
elif [ -n "$logfile" ] ; then
Packit 0848f5
    exec 6>$logfile
Packit 0848f5
else
Packit 0848f5
    set -x
Packit 0848f5
    exec 6>&1
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
if [ ! -d $blddir ] ; then
Packit 0848f5
    # Try to build it
Packit 0848f5
    mkdir $blddir
Packit 0848f5
fi
Packit 0848f5
if [ ! -d $blddir ] ; then
Packit 0848f5
    echo "$blddir does not exist" 
Packit 0848f5
    echo "Create it and rerun this script"
Packit 0848f5
    exit 1
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
# Build with the coverage options
Packit 0848f5
if [ $build_mpich = yes ] ; then
Packit 0848f5
    echo "------ Build MPICH ------" >&6
Packit 0848f5
    cd $blddir
Packit 0848f5
    $srcdir/configure --enable-coverage --with-pm=$pm --enable-romio \
Packit 0848f5
    		--with-device=$device \
Packit 0848f5
		  -prefix=$mpiinstalldir $extra_opts >&6 2>&6
Packit 0848f5
    rc=$?
Packit 0848f5
    if [ "$rc" != 0 ] ; then 
Packit 0848f5
	echo "$srcdir/configure failed with return code $rc"
Packit 0848f5
	exit 1
Packit 0848f5
    fi
Packit 0848f5
    make clean >&6 2>&6
Packit 0848f5
    # Make sure that we clean away any old results
Packit 0848f5
    find . -name '*.bb' -o -name '*.bbg' -o -name '*.da' -print | \
Packit 0848f5
	xargs @XARGS_NODATA_OPT@ rm -f
Packit 0848f5
    find . -name '*.gcov' -print | xargs @XARGS_NODATA_OPT@ rm -f
Packit 0848f5
    rm -f lib/*
Packit 0848f5
    make >&6 2>&6
Packit 0848f5
    rc=$?
Packit 0848f5
    if [ "$rc" != 0 ] ; then
Packit 0848f5
        echo "Make step failed with return code $rc"
Packit 0848f5
	exit 1
Packit 0848f5
    fi
Packit 0848f5
    echo "------ Install MPICH ------" >&6
Packit 0848f5
    make install >&6 2>&6
Packit 0848f5
    rc=$?
Packit 0848f5
    if [ "$rc" != 0 ] ; then
Packit 0848f5
	echo "Make install step failed with return code $rc"
Packit 0848f5
        exit 1
Packit 0848f5
    fi
Packit 0848f5
    echo "------ End of Install MPICH ------" >&6
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# Run the tests
Packit 0848f5
if [ $test_mpich = yes ] ; then
Packit 0848f5
    # The mpich tests are easy
Packit 0848f5
    echo "------ Run MPICH Tests ------" >&6
Packit 0848f5
    cd $blddir
Packit 0848f5
    make testing >&6 2>&6
Packit 0848f5
    echo "------ End Run MPICH Tests ------" >&6
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
if [ ! -d $blddir/othertest ] ; then
Packit 0848f5
    mkdir $blddir/othertest
Packit 0848f5
fi
Packit 0848f5
for dir in intel cxx mpich1 Testmpio ; do
Packit 0848f5
    if [ ! -d $blddir/othertest/$dir ] ; then
Packit 0848f5
        mkdir $blddir/othertest/$dir 
Packit 0848f5
    fi
Packit 0848f5
done
Packit 0848f5
Packit 0848f5
if [ $test_intel = yes ] ; then
Packit 0848f5
    echo "------ Run Intel Tests ------" >&6
Packit 0848f5
    # The intel tests aren't hard
Packit 0848f5
Packit 0848f5
    cd $blddir/othertest/intel
Packit 0848f5
    $intelsrcdir/configure --enable-coverage \
Packit 0848f5
	--with-mpich=$mpiinstalldir >&6 2>&6
Packit 0848f5
    make clean >&6 2>&6
Packit 0848f5
    make testing >&6 2>&6
Packit 0848f5
    echo "------ End Run Intel Tests ------" >&6
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
if [ $test_cxx = yes ] ; then
Packit 0848f5
    echo "------ Run C++ Tests ------" >&6
Packit 0848f5
    # Neither are the cxx test
Packit 0848f5
    # Build mpicxxtest --enable-coverage (still need to implement)
Packit 0848f5
    cd $blddir/othertest/cxx
Packit 0848f5
    $cxxsrcdir/configure --enable-coverage --with-mpich=$mpiinstalldir \
Packit 0848f5
	--enable-xml  >&6 2>&6
Packit 0848f5
    make clean >&6 2>&6
Packit 0848f5
    make testing >&6 2>&6
Packit 0848f5
    echo "------ End Run C++ Tests ------" >&6
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
if [ $test_io = yes ] ; then
Packit 0848f5
    echo "------ Run MPI-IO Tests ------" >&6
Packit 0848f5
    # These tests do not even have a configure or make!
Packit 0848f5
    cd $blddir/othertest/Testmpio
Packit 0848f5
    $mpiinstalldir/bin/mpicc -o testmpio $iosrcdir/testmpio.c >&6 2>&6
Packit 0848f5
    if [ ! -x testmpio ] ; then
Packit 0848f5
	echo "Unable to build MPI-IO test testmpio.  See log file $logfile for reason (build attempted in $blddir/othertest/Testmpio)"
Packit 0848f5
    else
Packit 0848f5
        if [ ! -d t1 ] ; then mkdir t1 ; fi
Packit 0848f5
        MPIO_USER_PATH=`pwd`/t1
Packit 0848f5
        export MPIO_USER_PATH
Packit 0848f5
        $mpiinstalldir/bin/mpiexec -n 4 ./testmpio 1 >&6 2>&6
Packit 0848f5
    fi
Packit 0848f5
    echo "------ End Run MPI-IO Tests ------" >&6
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
if [ $test_mpich1 = yes ] ; then
Packit 0848f5
    echo "------ Run MPICH-1 Tests ------" >&6
Packit 0848f5
    # Nor are the mpich1 tests
Packit 0848f5
    # Build mpich tests --enable-coverage
Packit 0848f5
    #   Need to provide a target that does not do the "runtest -check" step,
Packit 0848f5
    #   since there may be output about "Can't read output file foo.da"
Packit 0848f5
    cd $blddir/othertest/mpich1
Packit 0848f5
    MPIRUN=$mpiinstalldir/bin/mpiexec
Packit 0848f5
    export MPIRUN
Packit 0848f5
    MPITEST_IGNORE_RUNTEST=yes
Packit 0848f5
    export MPITEST_IGNORE_RUNTEST
Packit 0848f5
    $mpich1srcdir/configure --enable-coverage -cc=$mpiinstalldir/bin/mpicc \
Packit 0848f5
			-fc=$mpiinstalldir/bin/mpifort --enable-io \
Packit 0848f5
			-mpilibname=mpich \
Packit 0848f5
			-prefix=$mpiinstalldir >&6 2>&6
Packit 0848f5
    make clean  >&6 2>&6
Packit 0848f5
    make testing >&6 2>&6
Packit 0848f5
    echo "------ End Run MPICH-1 Tests ------" >&6
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
# Now create the summary
Packit 0848f5
echo "------ Collect Coverage Information ------" >&6
Packit 0848f5
cd $blddir
Packit 0848f5
# Ignore the output from gcov
Packit 0848f5
make coverage >/dev/null 2>&1
Packit 0848f5
rc=$?
Packit 0848f5
if [ "$rc" != 0 ] ; then
Packit 0848f5
    echo "Make coverage step failed with return code $rc"
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# The following list of directories gets the following:
Packit 0848f5
#  All of the top-level MPI routines (src/mpi and src/util/info)
Packit 0848f5
#  Support routines for nameservice using the file option (src/nameserv/file)
Packit 0848f5
#  Support routines for datatypes
Packit 0848f5
#  Basic implementation of the channel device.  This is included
Packit 0848f5
#  because some of the top-level MPI routines just push operations down
Packit 0848f5
#  to the device (e.g., MPI_Put).  src/mpid/ch3/src contains the "common"
Packit 0848f5
#  code for the channel devices, so it is reasonable to try for good
Packit 0848f5
#  coverage of this code as well.
Packit 0848f5
# annoteindex is not used with 
Packit 0848f5
rm -f coverage.txt
Packit 0848f5
if [ "$update_web" = yes ] ; then
Packit 0848f5
    # Clean out the old annotated files
Packit 0848f5
    if [ -d "$annotedir/src" ] ; then
Packit 0848f5
	(cd $annotedir/src && \
Packit 0848f5
	    find . -name '*.c.htm' -ctime +2 -print | \
Packit 0848f5
	    xargs @XARGS_NODATA_OPT@ rm -f )
Packit 0848f5
    fi
Packit 0848f5
    $srcdir/maint/getcoverage -annote=$annotedir \
Packit 0848f5
    -annoteweb=$annotewebprefix \
Packit 0848f5
    -indexdir=$annotedir \
Packit 0848f5
    src/mpi src/util/info src/nameserv/file \
Packit 0848f5
	src/mpid/common/datatype \
Packit 0848f5
        $devsrcdirs \
Packit 0848f5
        src/pmi/simple src/binding/f77 src/binding/cxx > coverage.txt
Packit 0848f5
else 
Packit 0848f5
    $srcdir/maint/getcoverage \
Packit 0848f5
    src/mpi src/util/info src/nameserv/file \
Packit 0848f5
	src/mpid/common/datatype \
Packit 0848f5
	$devsrcdirs \
Packit 0848f5
        src/pmi/simple src/binding/f77 src/binding/cxx > coverage.txt
Packit 0848f5
fi
Packit 0848f5
# The coverage data is in the build dir ($blddir).
Packit 0848f5
echo "------ End Collect Coverage Information ------" >&6
Packit 0848f5
if [ "$update_web" = yes ] ; then
Packit 0848f5
    if [ -d $webloc ] ; then 
Packit 0848f5
        rm -f $webloc/coverage.txt
Packit 0848f5
        cp coverage.txt $webloc/coverage.txt
Packit 0848f5
    else
Packit 0848f5
        echo "Unable to access $webloc to install coverage output"
Packit 0848f5
    fi
Packit 0848f5
    # Make the logfile available on the web page
Packit 0848f5
    if [ -n "$logfile" -a -s "$logfile" ] ; then
Packit 0848f5
	rm -f $webloc/cov-logfile.txt
Packit 0848f5
	cp $logfile $webloc/cov-logfile.txt
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# From mpich build directory:
Packit 0848f5
# make coverage >/dev/null 2>&1
Packit 0848f5
#   The above step creates the *.gcov files
Packit 0848f5
# maint/getcoverage.in src/mpi/*.gcov src/util/info/*.gcov \
Packit 0848f5
#   src/mpid/ch3/src/*.gcov src/mpid/ch3/channels/sock/src/*.gcov etc. \
Packit 0848f5
#    > coverage.txt
Packit 0848f5
#
Packit 0848f5
# The above generates a file that shows each missed executable line, along
Packit 0848f5
# with some context (the two lines preceding the missed line).
Packit 0848f5
#
Packit 0848f5
# It doesn't get all of the files; for example, it misses others in util
Packit 0848f5
# (e.g., util/mem), and it misses all of ROMIO because of the file 
Packit 0848f5
# structure of ROMIO (src/mpi/romio/{adio|mpi-io}/*.gcov).