forked from dyninst/mrnet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_tests.sh
executable file
·285 lines (259 loc) · 8.46 KB
/
run_tests.sh
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/bin/bash
bin_dir=$PWD/build/x86_64-pc-linux-gnu/bin
TOPGEN="${bin_dir}/mrnet_topgen"
topology_dir="${bin_dir}/mrnet_test_files"
if [ ! -d $topology_dir ]; then
topology_dir="$PWD/topology_files"
if [ ! -d $topology_dir ]; then
echo "Error: could not locate directory containing topology files"
exit
fi
fi
topologies=(1x1 1x4 1x16 1x1x2 1x2x4 1x4x16 1x1x1x1)
remote_topology_specs=(1 4 16 1:2 2:2x2 4:4x4 1:1:1)
usage="Usage: $0 ( -l | -r hostfile | -a hostfile ) [ -filter ] [ -lightweight ]"
print_usage()
{
echo $usage
return 0
}
print_help()
{
echo $usage
echo " One of the following must be provided:"
echo " -l : run tests on the local host only"
echo " -r : run tests on remote hosts"
echo " -a : run tests locally and remotely"
echo " Optional switches:"
echo " -filter : test dynamic filter loading"
echo " -lightweight : additionally run tests using lightweight back-ends"
return 0
}
create_remote_topologies()
{
# $1, 1st arg, is the hostfile mapping localhost:n => remotehost
remote_topology_prefix="remote"
for (( idx = 0 ; idx < ${#topologies[@]}; idx++ ));
do
remote_topology="$remote_topology_prefix-${topologies[$idx]}.top"
echo -n "Creating \"$remote_topology\" ... "
/bin/rm -f $remote_topology
$TOPGEN -t g:${remote_topology_specs[$idx]} -h $1 -o $remote_topology
if [ "$?" == 0 ]; then
echo "success!"
else
echo "failure!"
/bin/rm -f $remote_topology
fi
done
}
run_test()
{
# $1, 1st arg, is front-end program
# $2, 2nd arg, is back-end program
# $3, 3rd arg, says to use local or remote topology files
# $4, 4th arg, specifies the shared object file, if applicable
# $5, 5th arg, says to use standard or lightweight output file names
front_end=$1
back_end=$2
test=`basename $front_end`
for (( idx = 0 ; idx < ${#topologies[@]}; idx++ ));
do
topology=${topologies[$idx]}
if [ $3 = "remote" ]; then
topology_file="remote-$topology.top"
if [ "$5" = "lightweight" ]; then
outfile="$test-remote-lightweight-$topology.out"
logfile="$test-remote-lightweight-$topology.log"
else
outfile="$test-remote-$topology.out"
logfile="$test-remote-$topology.log"
fi
echo -n "Running $test(\"remote\", \"$topology\") ... "
else
topology_file="$topology_dir/local-$topology.top"
if [ "$5" = "lightweight" ]; then
outfile="$test-local-lightweight-$topology.out"
logfile="$test-local-lightweight-$topology.log"
else
outfile="$test-local-$topology.out"
logfile="$test-local-$topology.log"
fi
echo -n "Running $test(\"local\", \"$topology\") ... "
fi
if [ ! -f $topology_file ]; then
echo "Error: topology file $topology_file does not exist."
else
/bin/rm -f $outfile
/bin/rm -f $logfile
case "$front_end" in
"test_DynamicFilters_FE" )
$bin_dir/$front_end $4 $topology_file $back_end > $outfile 2> $logfile
;;
"microbench_FE" )
$bind_dir/$front_end 5 500 $topology_file $back_end > $outfile 2> $logfile
;;
"test_MultStreams_FE" )
$bin_dir/$front_end $topology_file 5 $back_end > $outfile 2> $logfile
;;
* )
$bin_dir/$front_end $topology_file $back_end > $outfile 2> $logfile
;;
esac
if [ "$?" = 0 ]; then
echo "exited with $?."
echo -n " Checking results ... ";
/bin/rm -f mrnet_tests_grep.out
grep -i failure $outfile > mrnet_tests_grep.out
if [ "$?" != 0 ]; then
echo "success!"
/bin/rm -f $logfile
else
echo "Error: (details in $outfile and $logfile)"
fi
/bin/rm -f mrnet_tests_grep.out
else
echo "Error: (details in $outfile and $logfile)"
fi
fi
done
}
##### "main()" starts here
## Parse the command line
if [ $# -lt 1 ]; then
print_usage
exit -1;
fi
local="true"
remote="false"
sharedobject=""
lightweight="false"
while [ $# -gt 0 ]
do
case "$1" in
-lightweight )
lightweight="true"
shift
;;
-l )
local="true"
shift
;;
-a )
local="true"
remote="true"
shift
if [ $# -lt 1 ]; then
print_usage
echo " Must specify a hostfile after -a option"
exit -1;
fi
if test -r $1; then
hostfile="$1"
else
echo " $1 doesn't exist or is not readable"
exit -1
fi
shift
;;
-r )
remote="true"
local="false"
shift
if [ $# -lt 1 ]; then
print_usage
echo " Must specify a hostfile after -r option"
exit -1;
fi
if test -r "$1" ; then
hostfile="$1"
else
echo "Error: $1 doesn't exist or is not readable"
exit -1
fi
shift
;;
-filter )
sharedobject="${topology_dir}/test_DynamicFilters.so"
if [ ! -f $sharedobject ]; then
sharedobject="{bin_dir}/../lib/test_DynamicFilters.so"
if [ ! -f $sharedobject ] ; then
echo "Error: could not located test_DynamicFilters.so"
exit
fi
fi
shift
;;
*)
print_usage;
exit 0;
;;
esac
case $1 in
esac
done
if [ "$local" == "true" ]; then
run_test "test_basic_FE" "test_basic_BE" "local" "" ""
echo
run_test "test_arrays_FE" "test_arrays_BE" "local" "" ""
echo
run_test "test_MultStreams_FE" "test_MultStreams_BE" "local" "" ""
echo
run_test "test_NativeFilters_FE" "test_NativeFilters_BE" "local" "" ""
echo
if [ "$sharedobject" != "" ]; then
run_test "test_DynamicFilters_FE" "test_DynamicFilters_BE" "local" $sharedobject ""
echo
fi
run_test "microbench_FE" "microbench_BE" "local" ""
echo
if [ "$lightweight" == "true" ]; then
run_test "test_basic_FE" "test_basic_BE_lightweight" "local" "" "lightweight"
echo
run_test "test_arrays_FE" "test_arrays_BE_lightweight" "local" "" "lightweight"
echo
run_test "test_MultStreams_FE" "test_MultStreams_BE_lightweight" "local" "" "lightweight"
echo
run_test "test_NativeFilters_FE" "test_NativeFilters_BE_lightweight" "local" "" "lightweight"
echo
if [ "$sharedobject" != "" ]; then
run_test "test_DynamicFilters_FE" "test_DynamicFilters_BE_lightweight" "local" $sharedobject "lightweight"
echo
fi
run_test "microbench_FE" "microbench_BE_lightweight" "local" "" "lightweight"
echo
fi
fi
if [ "$remote" == "true" ]; then
create_remote_topologies $hostfile
run_test "test_basic_FE" "test_basic_BE" "remote" "" ""
echo
run_test "test_arrays_FE" "test_arrays_BE" "remote" "" ""
echo
run_test "test_MultStreams_FE" "test_MultStreams_BE" "remote" "" ""
echo
run_test "test_NativeFilters_FE" "test_NativeFilters_BE" "remote" "" ""
echo
if [ "$sharedobject" != "" ]; then
run_test "test_DynamicFilters_FE" "test_DynamicFilters_BE" "remote" $sharedobject ""
echo
fi
run_test "microbench_FE" "microbench_BE" "remote" "" ""
echo
if [ "$lightweight" == "true" ]; then
run_test "test_basic_FE" "test_basic_BE_lightweight" "remote" "" "lightweight"
echo
run_test "test_arrays_FE" "test_arrays_BE_lightweight" "remote" "" "lightweight"
echo
run_test "test_MultStreams_FE" "test_MultStreams_BE_lightweight" "remote" "" "lightweight"
echo
run_test "test_NativeFilters_FE" "test_NativeFilters_BE_lightweight" "remote" "" "lightweight"
echo
if [ "$sharedobject" != "" ]; then
run_test "test_DynamicFilters_FE" "test_DynamicFilters_BE_lightweight" "remote" $sharedobject "lightweight"
echo
fi
run_test "microbench_FE" "microbench_BE_lightweight" "remote" "" "lightweight"
echo
fi
fi