3 # This file contains support shell routines and steps common to all
8 # Some people don't include "." in their path (! in case an ls trojan horse,
9 # I guess - if someone does that to you, you have bigger problems). This
10 # code tests to see if you have a path to mpirun; if not, it tries ./mpirun.
12 # One particular problem is having multiple mpiruns in the path. An
13 # absolute path for mpirun will fix many problems
15 if [ -z "$MPICH_USE_LIB_MPIRUN" -a ! -x "$mpirun" ] ; then
16 IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:"
18 if [ -x $dir/mpirun ] ; then
19 if [ -n "${MPICH_VERSION}" ] ; then
20 # Test that we've found the correct mpirun
21 if strings $dir/mpirun | grep "MPIRUN for MPICH" > /dev/null ; then
24 # echo "$dir/mpirun isn't for MPICH"
34 if [ -z "$mpirun" -a -x "./mpirun" ] ; then
38 if [ -z "$mpirun" ] ; then
39 echo "No mpirun in path. Testing can not proceed."
44 # MakeExe program-name
46 if [ -s $STOPFILE ] ; then
47 echo "Found stopfile $STOPFILE; exiting"
53 if [ "$MPITEST_CONTINUE" = "always" ] ; then
54 echo "Could not build executable $1; skipping this test"
56 echo "Could not build executable $1; aborting tests"
63 # CleanExe program-name
65 if [ $makeeach = 1 ] ; then
72 if [ $quiet = 0 ] ; then
73 if [ -z "$hostname" ] ; then
81 # Do an "on the fly" check for problems.
82 # Checkout testname difffile
83 # difffile may be empty, in which case stdout is used.
84 # If $writesummaryfile is yes, output the results to $summaryfile.
85 # Use XML-style output for the summary file:
87 # <NAME NAME="" STATUS="PASS"|"FAIL">
88 # <WORKDIR>directory</WORKDIR>
94 # We'd also like to support
96 # but we don't have that information when this routine is called
101 if [ ! -s ${bfile}.out ] ; then
102 echo "No output file ${bfile}.out!"
105 # Handle Fortran systems that generate stop statements
107 grep -v 'FORTRAN STOP' ${bfile}.out > ${bfile}.tout
108 for stdfile in $srcdir/${bfile}.std $srcdir/${bfile}.std2 \
109 $srcdir/std/${bfile}.std ${bfile}.stdo ; do
110 if [ -z "$cmpfile" -a -s "$stdfile" ] ; then
113 if test -s $stdfile && diff -b ${bfile}.tout $stdfile > /dev/null ; then
118 if [ $fileok = "no" ] ; then
119 if [ -n "$difffile" ] ; then
120 if [ -n "$cmpfile" ] ; then
121 echo "Differences in ${bfile}.out" >> ${difffile}
122 diff -b ${bfile}.tout $cmpfile >> ${difffile}
124 echo "Cannot find a file to compare against for test ${bfile}.out"
127 if [ -n "$cmpfile" ] ; then
128 echo "Differences in ${bfile}.out"
129 diff -b ${bfile}.tout $cmpfile
131 echo "Cannot find a file to compare against for test ${bfile}.out"
136 if [ "$writesummaryfile" = "yes" ] ; then
137 if [ $fileok = "yes" ] ; then
143 cat >>$summaryfile <<EOF
146 <WORKDIR>$mydir</WORKDIR>
147 <STATUS>$passed</STATUS>
149 if [ -n "$np" ] ; then
150 echo "<NP>$np</NP>" >> $summaryfile
152 if [ $fileok = "no" ] ; then
153 echo "<TESTDIFF>" >> $summaryfile
154 if [ ! -s ${bfile}.out ] ; then
155 echo "No output file" >>$summaryfile
157 if [ -z "$cmpfile" ] ; then
160 diff -b ${bfile}.tout $cmpfile | \
161 sed -e 's/&/-AMP-amp;/g' -e 's/</-AMP-lt;/g' \
162 -e 's/>/-AMP-gt;/g' | \
163 sed -e 's/-AMP-/\&/g' >> $summaryfile
165 echo "</TESTDIFF>" >> $summaryfile
167 if [ -s "$bfile.tbk" ] ; then
168 echo "<TRACEBACK>" >> $summaryfile
169 echo "$bfile.tbk" >>$summaryfile
170 echo "</TRACEBACK>" >> $summaryfile
172 echo "</MPITEST>" >> $summaryfile
178 # Runtest pgm-name np marker-test args outfiles
179 # filename.tbk is a traceback file. Use a tool like pardump $1 > $1.tbk
185 testfiles="$testfiles $pgm.out"
186 /bin/rm -f $pgm.out $pgm.tbk
188 if [ ! -x $pgm ] ; then
189 # If no executable, put the make data into $1.out
190 $MAKE $pgm > $pgm.out 2>&1
193 if [ -z "$mname" ] ; then mname="*** $1 ***" ; fi
194 #echo "$mname" >> $pgm.out
197 if [ -n "$5" ] ; then rm -f $5 ;
198 if [ -n "$MPIRUNMVBACK" ] ; then mvarg="$MPIRUNMVBACK \"$5\"" ; fi
200 # The eval is necessary to ensure that the mvarg value is properly
201 # tokenized. The ./$1 ensures that the program will be found,
202 # even if . is not in the PATH.
204 eval $mpirun $args -np $np $mvarg ./$pgm $4 </dev/null >> $pgm.out 2>&1
205 if [ -n "$5" ] ; then
207 if [ -s $file ] ; then
208 cat $file >> $pgm.out ; rm -f $file
212 #echo "$mname" >> $pgm.out
213 if [ ! -s $srcdir/$pgm.std -a ! -s $pgm.stdo ] ; then
214 # We don't need a special file if the output is just "No Errors"
215 cat >>$pgm.stdo <<EOF
219 if [ "$CheckOutputWhileRunning" = "yes" -o "$check_at_once" = 1 ] ; then
229 # Check the output of the programs against the "standard" output. The
230 # possible files are:
234 # The last one is an automatically generated file for those programs
235 # that simply produce a " No errors" output.
239 /bin/rm -f ${difffile}
241 for file in $testfiles ; do
242 bfile=`basename $file .out`
243 CheckOutput $bfile ${difffile}
245 if [ -s ${difffile} ] ; then
247 elif [ $nodiff = 1 ] ; then
248 echo "-- No differences found; test successful"