~samiam/MaraDNS

ref: 3.5.0021 MaraDNS/deadwood-github/sqa/do.tests -rwxr-xr-x 7.8 KiB
ca00f282 — Sam Trenholme MaraDNS release 3.5.0021 5 months ago
                                                                                
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/bash

# This is a shell script that will do all of the sqa tests; this script
# will halt if any of the tests does not give the desired result

# This test needs to be run from root, it needs to be run with Deadwood 
# inside the MaraDNS source tree, and it needs to be run with the
# current working directory the directory this test is in

# Before running this test, be sure to have no processes which bind
# to either UDP or TCP port 53 on the system running the tests

if ! command -v askmara > /dev/null 2>&1 ; then
	echo askmara must be in path to run tests
	exit 1
fi

if ! command -v askmara-tcp > /dev/null 2>&1 ; then
	echo askmara-tcp must be in path to run tests
	exit 1
fi

if ! id | grep root > /dev/null 2>&1 ; then
	echo the tests must be run as a root user
	exit 1
fi

SQADIR=$(pwd)
export CC=gcc

cd ../..
if [ ! -e maradns.gpg.key ] ; then
	echo These tests must be run inside of MaraDNS\; place the
	echo Deadwood code off of MaraDNS\' top-level directory before
        echo running these tests
	exit 0
fi
# Make sure MaraDNS is compiled
echo compiling MaraDNS...
make clean > /dev/null 2>&1 # MaraDNS
make > /dev/null 2>&1 # MaraDNS
#make # MaraDNS

# Now compile Deadwood
cd $SQADIR
cd ../src
export FLAGS='-O3'
echo compiling Deadwood...
make -f Makefile.sl6 clean > /dev/null 2>&1 
make -f Makefile.sl6 > /dev/null 2>&1 
#make -f Makefile.sl6

# Now, back to the SQA directory to run the tests
cd $SQADIR

TESTS=""
# I need to test ipv6 but haven't yet
#TESTS=$TESTS"basic_test basic_tcp_test basic_ipv6_test "

# Here are the tests we currently run
#TESTS=$TESTS"

# sqa_tcp is first because the example.com nameserver and DNS info
# constantly move
TESTS=$TESTS"sqa_tcp " # Disable this if you have no internet

# These tests sometimes fail
#TESTS=$TESTS"sqa_tcp_buffering_2,5 " 
TESTS=$TESTS"dwood2rc_n_maxprocs,2 "
TESTS=$TESTS"dwood2rc_s_cache_file,2 "
TESTS=$TESTS"sqa_one_upstream_down,5 "
TESTS=$TESTS"sqa_easydns_bad_truncation,2 "
TESTS=$TESTS"dwood2rc_n_num_retries,2 "

# These tests are stable and don't fail
TESTS=$TESTS"basic_test basic_tcp_test "
TESTS=$TESTS"sqa_server_fail "
TESTS=$TESTS"sqa_root_upstream "
TESTS=$TESTS"sqa_ip4 "
TESTS=$TESTS"dwood2rc_s_bind_address,2 "
#TESTS=$TESTS"dwood2rc_n_dns_port,3 " # Disabled, requires dig
TESTS=$TESTS"dwood2rc_n_filter_rfc1918 "
TESTS=$TESTS"dwood2rc_n_handle_noreply "
TESTS=$TESTS"dwood2rc_n_handle_noreply_tcp "
TESTS=$TESTS"dwood2rc_n_handle_overload "
TESTS=$TESTS"dwood2rc_s_ipv4_bind_addresses,3 "
TESTS=$TESTS"dwood2rc_n_maximum_cache_elements,2 " # Sometimes fails...
TESTS=$TESTS"dwood2rc_n_maradns_gid "
TESTS=$TESTS"dwood2rc_n_maradns_uid "
TESTS=$TESTS"dwood2rc_n_max_ar_chain "
TESTS=$TESTS"dwood2rc_s_random_seed_file "
TESTS=$TESTS"dwood2rc_n_recurse_min_bind_port "
TESTS=$TESTS"dwood2rc_n_recurse_number_ports "
TESTS=$TESTS"dwood2rc_s_recursive_acl "
TESTS=$TESTS"dwood2rc_n_resurrections "

# CentOS 5.5's select() timeout broke this test; it's a bug caused because
# CentOS 5.5's select() doubles the timeout (e.g. you ask for a one second 
# timeout but CentOS 5.5 select() doesn't time out for two seconds)
#
# I updated the test to work around CentOS 5.5's broken select(), and
# submitted a bug for both CentOS and RedHat:
#
# http://bugs.centos.org/view.php?id=4465
# https://bugzilla.redhat.com/show_bug.cgi?id=619664 
TESTS=$TESTS"dwood2rc_n_timeout_seconds "

TESTS=$TESTS"dwood2rc_n_ttl_age "
TESTS=$TESTS"dwood2rc_n_upstream_port "
TESTS=$TESTS"dwood2rc_d_upstream_servers "
TESTS=$TESTS"dwood2rc_n_verbose_level "
TESTS=$TESTS"recurse_2link_cname "
TESTS=$TESTS"recurse_es-us.noticias.yahoo.com "
TESTS=$TESTS"sqa_badid_question "
TESTS=$TESTS"sqa_bigpacket " # Needs BIND to run
TESTS=$TESTS"sqa_cname_chain,3 "
TESTS=$TESTS"sqa_roy_arends "
#TESTS=$TESTS"sqa_tcp_buffering "
TESTS=$TESTS"sqa_ttl_expire "
# This test is last since it recompiles Deadwood
# We run it seven times because some memleaks only happen some of the time
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "
TESTS=$TESTS"sqa_valgrind "

# Allow it to be possible to specify tests on the command line
# e.g. ./do.tests sqa_rg32
if [ ! -z "$*" ] ; then
	TESTS="$*"
fi

FAILS=""
for PAIR in $TESTS ; do
	TEST=$( echo $PAIR | cut -f1 -d, )
	TRIES="$( echo $PAIR | cut -f2 -d, -s )"
	if [ -z "$TRIES" ] ; then
		TRIES=1
	fi
	if [ "$TRIES" -lt 1 ] ; then
		TRIES=1
	fi
	TRY=0
	echo test $TEST tries $TRIES
	while [ $TRY -lt $TRIES ]; do
		cd $TEST
		sh ./do.test > output.test 2> /dev/null
		sleep 2
		if ! cmp output.success output.test > /dev/null 2>&1 ; then
			echo test $test failed
			TRY=$(( $TRY + 1 ))
			if [ $TRY -ge $TRIES ] ; then
				# exit 1
				echo TEST FAILURE
				FAILS="$TEST $FAILS"
				exit 1 # Something stuck on port 53
			else
				echo trying again
			fi
		else
			# Success!
			TRY=$TRIES
		fi
		rm output.test
		cd ..
	done
done

# Let's test RG32
cd sqa_rg32
echo running RG32 test
sh ./do.test > output.test 2> /dev/null
sleep 2
if ! cmp output.success output.test > /dev/null 2>&1 ; then
	echo test sqa_rg32 failed
	exit 1
fi
echo RG32 pass
rm -f output.test 2> /dev/null
cd .. 

# Let's test RG64
cd sqa_rg64
echo running RG64 test
sh ./do.test > output.test 2> /dev/null
sleep 2
if ! cmp output.success output.test > /dev/null 2>&1 ; then
	echo test sqa_rg64 failed
	exit 1
fi
echo RG64 pass
rm -f output.test 2> /dev/null
cd .. 

# Let's test hash_magic_number
cd ../src
make -f Makefile.sl6 clean > /dev/null 2>&1
export FLAGS='-O3 -DHASH_DEBUG -DXTRA_STUFF'
make -f Makefile.sl6 > /dev/null 2>&1
cd $SQADIR
cd dwood2rc_n_hash_magic_number
sh ./do.test > output.test 2> /dev/null
sleep 2
if ! cmp output.success output.test > /dev/null 2>&1 ; then
	echo test dwood2rc_n_hash_magic_number failed
	#exit 1
else
	echo test dwood2rc_n_hash_magic_number succeeded
fi
rm output.test
cd ..

# Inflight test
cd $SQADIR
cd ../src
make -f Makefile.sl6 clean > /dev/null 2>&1
export FLAGS='-O3 -DINFLIGHT_VERBOSE -DVALGRIND_NOERRORS'
#export FLAGS='-g -DINFLIGHT_VERBOSE -DVALGRIND_NOERRORS'
make -f Makefile.sl6 > /dev/null 2>&1
cd $SQADIR
cd dwood2rc_n_max_inflights
sh ./do.test > output.test 2> /dev/null
sleep 2
if ! cmp output.success output.test > /dev/null 2>&1 ; then
	echo test dwood2rc_n_max_inflights failed
	exit 1
else
	echo test dwood2rc_n_max_inflights succeeded
fi

# Now, let's test IPv6
#cd $SQADIR
#cd ../..
#make clean > /dev/null 2>&1 # MaraDNS
#./configure --ipv6 > /dev/null 2>&1
#make > /dev/null 2>&1 # MaraDNS
#cd $SQADIR
#cd ../src
#make -f Makefile.sl6 clean > /dev/null 2>&1
#export FLAGS='-O3 -DIPV6'
#make -f Makefile.sl6 > /dev/null 2>&1
#cd $SQADIR
#cd basic_ipv6_test
#sh ./do.test > output.test 2> /dev/null
#sleep 2
#if ! cmp output.success output.test > /dev/null 2>&1 ; then
#	echo test basic_ipv6_test failed
#	exit 1
#else
#	echo test basic_ipv6_test succeeded
#fi
#rm output.test

# dwood2rc_s_ip_blocklist
#cd $SQADIR
#cd dwood2rc_s_ip_blocklist
#sh ./do.test > output.test 2> /dev/null
#sleep 2
#if ! cmp output.success output.test > /dev/null 2>&1 ; then
#	echo test dwood2rc_s_ip_blocklist failed
#	exit 1
#else
#	echo test dwood2rc_s_ip_blocklist succeeded
#fi
#rm output.test

# No warnings when compiled with gcc44
cd $SQADIR
cd ../src
make -f Makefile.sl6 clean > /dev/null 2>&1
export FLAGS='-O3'
#export CC='gcc43' # For CentOS 5.3
#export CC='gcc44'
export CC='gcc' # Scientific Linux 6's normal gcc is GCC 4.4.4
rm -f foo1 foo2 > /dev/null 2>&1
make -f Makefile.sl6 > /dev/null 2> foo1
touch foo2
if ! cmp foo1 foo2 > /dev/null 2>&1 ; then
	echo test gcc44 compile failed
	exit 1
else
	echo test gcc44 compile succeeded
fi
rm foo1 foo2

# OK, clean up
cd $SQADIR
cd ../src
make -f Makefile.sl6 clean > /dev/null 2>&1
cd $SQADIR
cd ../../
make clean > /dev/null 2>&1

if [ -z "$FAILS" ] ; then
	echo All tests successful
else
	echo Test failures: $FAILS	
	exit 1
fi

cd ..