/
runtest.sh.in
223 lines (201 loc) · 5.91 KB
/
runtest.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/sh
#
# Copyright (C) 2012,2013 The ESPResSo project
# Copyright (C) 2006,2007,2008,2009,2010,2011,2012 Olaf Lenz, Axel Arnold
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
# Max-Planck-Institute for Polymer Research, Theory Group
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
usage() {
cat <<EOF
Usage: $0 [-p PROCESSORS] [TESTCASES]...
Run TESTCASES on PROCESSORS processors.
Instead of specifying PROCESSORS and TESTCASES on the command line,
you can set the environment variables TESTCASES and PROCESSORS.
EOF
exit 2
}
# list of tests that are not supported by this version
BLACKLIST=
TESTLOG=runtest.log
srcdir=@srcdir@
ESPRESSO=@top_builddir@/Espresso
ESMPIEXEC=@ESPRESSO_MPIEXEC@
# tests need to be run from the directory where this script is located
cd ${0%runtest.sh}
# handle processors
if test x@MPI_FAKE@ = "xyes" || test @CPU_COUNT@ = "1"; then
processors=1
elif test "$1" = "-p"; then
processors="$2"
shift 2
elif test -n "$PROCESSORS"; then
processors=$PROCESSORS
else
processors="@CPU_COUNT@"
fi
echo "$0 started on "`date` > $TESTLOG
echo "processors=$processors" >> $TESTLOG
# handle testcases
testcases=$TESTCASES
test $# -ge 1 && testcases="$@"
echo "testcases=$testcases" >> $TESTLOG
# check if testcases are available
if test -z "$testcases"; then
echo "No testcases specified!"
usage
fi
# check for blacklisted tests
testcases_old=$testcases
testcases=
blacklisted=
for testcase in $testcases_old; do
ignore=
for bl_testcase in $BLACKLIST; do
if test "$bl_testcase" = "$testcase"; then
ignore=1
break;
fi
done
if ! test "$ignore"; then
testcases="$testcases $testcase"
else
blacklisted="$blacklisted $testcase"
fi
done
# link all files from the src directory to the run directory, if they are not identical
for file in `ls $srcdir/`; do
if test -f $srcdir/$file && ! test -f $file; then
echo @LN_S@ $srcdir/$file .
@LN_S@ $srcdir/$file .
fi
done
# execute the tests
for np in $processors; do
echo "** RUNNING TESTSUITE FOR $np tasks"
echo >> $TESTLOG
echo "**************************************************" >> $TESTLOG
echo "**** RUNNING TESTSUITE FOR $np tasks" >> $TESTLOG
failed=
ignored=
succeeded=
for testcase in $testcases; do
if test x@MPI_FAKE@ = "xyes"; then
CMD="$ESPRESSO $srcdir/$testcase -quiet"
else
CMD="$ESMPIEXEC -n $np $ESPRESSO $srcdir/$testcase -quiet"
fi
printf "%35s - " $testcase
echo "**************************************************" >> $TESTLOG
echo "** $testcase" >> $TESTLOG
echo $CMD >> $TESTLOG
$CMD >> $TESTLOG 2>&1
rc=$?
echo >> $TESTLOG
case $rc in
(0)
echo "ok"
echo "SUCCESS: $testcase" >> $TESTLOG
succeeded="$succeeded $testcase"
;;
(42)
# 42 is the constant used to denote that a test is to be ignored
echo "ignored"
echo "IGNORED: $testcase" >> $TESTLOG
ignored="$ignored $testcase"
;;
(66)
echo "ERROR"
echo "FAILED: $testcase" >> $TESTLOG
failed="$failed $testcase"
;;
(130)
# SIGINT
echo "INTERRUPT"
echo "INTERRUPT: $testcase" >> $TESTCASE
interrupted=yes
break
;;
(*)
echo "ERROR (code=$rc)"
echo "UNKNOWN ERROR: $testcase (probably interrupted?)" >> $TESTLOG
echo "Exit code: $rc" >> $TESTLOG
interrupted=yes
failed="$failed $testcase"
break
;;
esac
done
echo
# interrupt if not all test cases on a certain processor number
# were successful
if test "x$failed" != "x"; then
echo "Some test cases failed with $np tasks, interrupting test suite."
echo "**************************************************" >> $TESTLOG
echo "Some test cases failed with $np tasks, interrupting test suite." >> $TESTLOG
break
fi
done
echo >> $TESTLOG
echo "************************************" >> $TESTLOG
echo "************************************" >> $TESTLOG
echo "************ SUMMARY ***************" >> $TESTLOG
echo "************************************" >> $TESTLOG
echo "************************************" >> $TESTLOG
echo "$np TASKS" >> $TESTLOG
if test "x$blacklisted" != "x"; then
echo "BLACKLISTED TESTS:" >> $TESTLOG
for testcase in $blacklisted; do
echo " $testcase" >> $TESTLOG
done
fi
if test "x$ignored" != "x"; then
echo "IGNORED TESTS:" >> $TESTLOG
for testcase in $ignored; do
echo " $testcase" >> $TESTLOG
done
fi
if test "x$succeeded" != "x"; then
echo "SUCEEDED TESTS:" >> $TESTLOG
for testcase in $succeeded; do
echo " $testcase" >> $TESTLOG
done
fi
if test "x$failed" != "x"; then
echo "FAILED TESTS:" >> $TESTLOG
for testcase in $failed; do
echo " $testcase" >> $TESTLOG
done
echo
echo "**************************************************"
echo "** Not all test cases were successful!"
echo "** Have a look at the file testsuite/runtest.log"
echo "** for the output of the testcases."
if test "x$interrupted" != "x"; then
echo "**************************************************"
echo "** The testsuite was interrupted!"
fi
echo "**************************************************"
echo
exit 1
else
echo
echo "**************************************************"
echo "** All tests were successful!"
echo "**************************************************"
echo
fi