Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid into...
[simgrid.git] / teshsuite / smpi / mpich-test / env / runtests
1 #! /bin/sh
2 #
3 # Run some of the tests.  If any arguments are provided, pass them to the
4 # test programs.
5 #
6 # -mvhome is needed for the ANL SP, and is ignored by others
7
8 device=
9 MPICH_VERSION=
10 STOPFILE=${MPITEST_STOPTEST:-"$HOME/.stopmpichtests"}
11 MAKE="make --no-print-directory"
12
13 #
14 # Set mpirun to the name/path of the mpirun program
15 #FindMPIRUN
16 #
17 quiet=0
18 runtests=1
19 makeeach=0
20 have_fortran=0
21 writesummaryfile=no
22 MAKE="make --no-print-directory"
23 for arg in "$@" ; do
24     case $arg in 
25     -basedir=* )
26         basedir=`echo $arg | sed 's/-basedir=//'`
27         ;; 
28     -srcdir=* )
29         srcdir=`echo $arg | sed 's/-srcdir=//'`
30         ;; 
31         -fort=* )
32         have_fortran=`echo $arg | sed 's/-fort=//'`
33         ;;
34         -checkonly )
35         runtests=0
36         ;;
37         -margs=*)
38         margs=`echo $arg | sed 's/-margs=//'`
39         args="$args $margs"
40         ;;
41         -summaryfile=*)
42         writesummaryfile=yes
43         summaryfile=`echo A$arg | sed 's/A-summaryfile=//'`
44         ;;
45         -small)
46         makeeach=1
47         shift
48         ;;
49         -quiet)
50         shift
51         quiet=1
52         ;;
53         -help|-u)
54         echo "runtests [-checkonly] [-margs='...']"
55         echo "run tests in this directory.  If -checkonly set, just run"
56         echo "the differences check (do NO rerun the test programs)."
57         echo "If -margs is used, these options are passed to mpirun."
58         echo "If -small is used, the examples are built, run, and deleted."
59         exit 1
60         ;;
61         *)
62         if test -n "$arg" ; then
63             echo "runtests: Unknown argument ($arg)"
64             exit 1
65         fi
66         ;;
67     esac
68 done
69
70 mpirun=" ${basedir}/bin/smpirun -platform ${srcdir}/../../../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir}/../../hostfile  --log=root.thres:critical"
71 #
72 # Load basic procedures
73 . ${srcdir}/../runbase
74
75 # If the programs are not available, run make.
76 if [ ! -x timers -a $makeeach = 0 -a $runtests = 1 ] ; then
77     $MAKE
78 fi
79 #
80 testfiles=""
81 if [ $runtests = 1 ] ; then
82
83 #RunTest timers 1 "*** Timer tests ***"
84
85 RunTest init 2 "*** MPI_Initialized tests ***"
86 # uses MPI_Attr_get
87 #RunTest baseattr 1 "*** Basic attributes ***"
88
89 RunTest gtime 1 "*** WTIME_IS_GLOBAL ***"
90 #uses errhandlers
91 #RunTest errhand 1 "*** Tests of error handling ***"
92
93 #RunTest errhand2 1 "*** Tests of error handling reference counting ***"
94
95 # Do not run sigchk by default because it generates warnings that are not
96 # errors, and the basic test should be clean
97 if [ "$MPICH_TESTS_SIGCHK" = yes ] ; then
98     RunTest sigchk 1 "*** Tests of signals used ***"
99 fi
100
101 RunTest getproc 1 "*** Test Get Processor Name ***"
102
103 #OutTime
104 #testfiles="$testfiles cmdline.out"
105 #rm -f cmdline.out
106 #MakeExe cmdline
107 #echo "*** Tests of command line handling ***"
108 #echo "*** Tests of command line handling ***" >> cmdline.out
109 #$mpirun $args -np 2 ./cmdline a "b c" "d'e" 'f"g" h' $* </dev/null l>> cmdline.out 2>&1
110 #echo "*** Tests of command line handling ***" >> cmdline.out
111 #CleanExe cmdline
112 #if [ ! -s cmdline.stdo ] ; then
113 #    cat >cmdline.stdo <<EOF
114 #*** Tests of command line handling ***
115 # No Errors
116 #*** Tests of command line handling ***
117 #EOF
118 #fi
119
120 #
121 # If there was a Unix standard interface to ps, we could check for orphaned
122 # processes...
123 if ps -fwu $LOGNAME > /dev/null 2>&1 ; then
124    # This is a better choice than ps aux because it restricts the list of 
125    # processes to those of the running user.  The w is needed on some
126    # systems to get a long output for the command
127    PSPGM="ps -fwu $LOGNAME"
128 elif ps -fu $LOGNAME > /dev/null 2>&1 ; then
129    # This is a better choice than ps aux because it restricts the list of 
130    # processes to those of the running user.
131    PSPGM="ps -fu $LOGNAME"
132 else
133    PSPGM="ps auxww"
134 fi
135 OutTime
136 testfiles="$testfiles aborttest.out"
137 rm -f aborttest.out aborttest.p1 aborttest.p2 aborttest.out2
138 MakeExe aborttest
139 echo "*** Tests of MPI_Abort ***"
140 echo "*** Tests of MPI_Abort ***" >> aborttest.out
141 # We also remove lines that look like build lines in case this system
142 # is being used for other tests.  This is incomplete, but
143 # it may help reduce false positives
144 $PSPGM | grep $LOGNAME | grep -v grep | grep -v runtests | \
145     grep -v 'make ' | grep -v ' /ld' | grep -v 'gcc' | \
146     grep -v 'collect2' > aborttest.p1
147 # Send the output of aborttest to a file in case there is a problem
148 $mpirun $args -np 2 ./aborttest $* < /dev/null >> aborttest.out2 2>&1
149 # allow some time for processes to exit
150 sleep 5
151 $PSPGM | grep $LOGNAME | grep -v grep | grep -v runtests | \
152     grep -v 'make ' | grep -v ' /ld' | grep -v 'gcc' | \
153     grep -v 'collect2' > aborttest.p2
154 # If there was a consistant format, we could process it ...
155 ndiff="`cat aborttest.p1 | wc -l` - `cat aborttest.p2 | wc -l`"
156 ndiff=`expr $ndiff`
157 if test "$ndiff" = 0 ; then
158     echo "All processes aborted" >> aborttest.out    
159 else
160     echo "Suspicious processes remain" >> aborttest.out
161     #echo "Processes before" >> aborttest.out
162     #cat aborttest.p1 >> aborttest.out
163     #echo "Processes after" >> aborttest.out
164     #cat aborttest.p2 >> aborttest.out
165     echo "Differences are" >> aborttest.out
166     diff -b aborttest.p1 aborttest.p2 >> aborttest.out
167     if [ -s aborttest.out2 ] ; then
168         echo "Output from mpirun was"
169         cat aborttest.out2 >> aborttest.out
170     fi
171     # Try to kill them
172     $PSPGM | grep $LOGNAME | grep aborttest | awk '{ print "kill ", $2 }' | sh
173 fi
174 echo "*** Tests of MPI_Abort ***" >> aborttest.out
175 rm -f aborttest.p1 aborttest.p2 aborttest.out2
176
177 OutTime
178 rm -f aborttest.p1 aborttest.p2 aborttest.out2
179 echo "*** Tests of MPI_Abort (alt) ***"
180 echo "*** Tests of MPI_Abort (alt) ***" >> aborttest.out
181 $PSPGM | grep $LOGNAME | grep -v grep | grep -v runtests | \
182     grep -v 'make ' | grep -v ' /ld' | grep -v 'gcc' | \
183     grep -v 'collect2' > aborttest.p1
184 $mpirun $args -np 2 ./aborttest -altmaster $* >aborttest.out2 2>&1
185 sleep 5
186 $PSPGM | grep $LOGNAME | grep -v grep | grep -v runtests | \
187     grep -v 'make ' | grep -v ' /ld' | grep -v 'gcc' | \
188     grep -v 'collect2' > aborttest.p2
189 ndiff="`cat aborttest.p1 | wc -l` - `cat aborttest.p2 | wc -l`"
190 ndiff=`expr $ndiff`
191 if test "$ndiff" = 0 ; then
192     echo "All processes aborted" >> aborttest.out    
193 else
194     echo "Suspicious processes remain" >> aborttest.out
195     #echo "Processes before" >> aborttest.out
196     #cat aborttest.p1 >> aborttest.out
197     #echo "Processes after" >> aborttest.out
198     #cat aborttest.p2 >> aborttest.out
199     echo "Differences are" >> aborttest.out
200     diff -b aborttest.p1 aborttest.p2 >> aborttest.out
201     if [ -s aborttest.out2 ] ; then
202         echo "Output from mpirun was"
203         cat aborttest.out2 >> aborttest.out
204     fi
205     # Try to kill them
206     $PSPGM | grep $LOGNAME | grep aborttest | awk '{ print "kill ", $2 }' | sh
207 fi
208 echo "*** Tests of MPI_Abort (alt) ***" >> aborttest.out
209 rm -f aborttest.p1 aborttest.p2 aborttest.out2
210 CleanExe aborttest
211
212 #
213 # Run Fortran tests ONLY if Fortran available
214 if [ $have_fortran -eq "1" ] ; then 
215
216 #    RunTest errstringsf 1 "*** Tests of Fortran error strings ***"
217
218     RunTest getprocf 1 "*** Test MPI_Get_processor_name in Fortran ***"
219
220 #    RunTest errhandf 1 "*** Tests of error handling in Fortran ***"
221 fi
222
223 else
224     # Just run checks
225     testfiles=*.out
226     if test "$testfiles" eq "*.out" ; then
227         echo "No output files remain from previous test!"
228         exit 1
229     fi
230 fi
231
232 #
233 echo '*** Checking for differences from expected output ***'
234 CheckAllOutput env.diff
235 exit 0