Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# #-- 09-unbound-control.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test

PRE="../.."

# exit value is 1 on usage
$PRE/unbound-control -h
if test $? -ne 1; then
	echo "wrong exit value for usage."
	exit 1
else
	echo "exit value for usage: OK"
fi

# use lock-verify if possible

# test if the server is up.
echo "> dig www.example.com."
dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> check answer"
if grep "10.20.30.40" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# exit value is 1 when a bad command is given.
echo "$PRE/unbound-control -c ub.conf blablargh"
$PRE/unbound-control -c ub.conf blablargh
if test $? -ne 1; then
	echo "wrong exit value on error."
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.lo
	exit 1
else
	echo "correct exit value on error"
fi

# reload the server. test if the server came up by putting a new
# local-data element in the server.
echo "server: local-data: 'afterreload. IN A 5.6.7.8'" >> ub.conf
echo "$PRE/unbound-control -c ub.conf reload"
$PRE/unbound-control -c ub.conf reload
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

echo "> dig afterreload."
dig @127.0.0.1 -p $UNBOUND_PORT afterreload. | tee outfile
echo "> check answer"
if grep "5.6.7.8" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# must have had queries now.  1 since reload.
echo "$PRE/unbound-control -c ub.conf stats"
$PRE/unbound-control -c ub.conf stats > tmp.$$
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
if grep "^total.num.queries=[1-9][0-9]*$" tmp.$$; then
	echo "OK"
else
	echo "bad stats"
	cat tmp.$$
	exit 1
fi

# verbosity
echo "$PRE/unbound-control -c ub.conf verbosity 2"
$PRE/unbound-control -c ub.conf verbosity 2
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

# check syntax error in parse 
echo "$PRE/unbound-control -c ub.conf verbosity jkdf"
$PRE/unbound-control -c ub.conf verbosity jkdf
if test $? -ne 1; then
	echo "wrong exit value after failure"
	exit 1
fi

# check bad credentials
cp ub.conf bad.conf
echo "remote-control:" >> bad.conf
echo "	server-key-file: bad_server.key" >> bad.conf
echo "	server-cert-file: bad_server.pem" >> bad.conf
echo "	control-key-file: bad_control.key" >> bad.conf
echo "	control-cert-file: bad_control.pem" >> bad.conf
echo "$PRE/unbound-control -c bad.conf verbosity 2"
$PRE/unbound-control -c bad.conf verbosity 2
if test $? -ne 1; then
	echo "wrong exit value after failure"
	exit 1
fi

# check spoofedclient credentials
rm -f bad.conf
cp ub.conf bad.conf
echo "remote-control:" >> bad.conf
echo "	server-key-file: unbound_server.key" >> bad.conf
echo "	server-cert-file: unbound_server.pem" >> bad.conf
echo "	control-key-file: bad_control.key" >> bad.conf
echo "	control-cert-file: bad_control.pem" >> bad.conf
echo "$PRE/unbound-control -c bad.conf verbosity 2"
$PRE/unbound-control -c bad.conf verbosity 2
if test $? -ne 1; then
	echo "wrong exit value after failure"
	exit 1
fi

# create a new local zone
echo "> test of local zone"
echo "$PRE/unbound-control -c ub.conf local_zone example.net static"
$PRE/unbound-control -c ub.conf local_zone example.net static
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "$PRE/unbound-control -c ub.conf local_data www.example.net A 192.0.2.1"
$PRE/unbound-control -c ub.conf local_data www.example.net A 192.0.2.1
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

# check that www.example.net exists
echo "> dig www.example.net."
dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
echo "> check answer"
if grep "192.0.2.1" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# check that mail.example.net has nxdomain
echo "> dig mail.example.net."
dig @127.0.0.1 -p $UNBOUND_PORT mail.example.net. | tee outfile
echo "> check answer"
if grep "NXDOMAIN" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# remove www.example.net - check it gets nxdomain
echo "$PRE/unbound-control -c ub.conf local_data_remove www.example.net"
$PRE/unbound-control -c ub.conf local_data_remove www.example.net
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> dig www.example.net."
dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
echo "> check answer"
if grep "NXDOMAIN" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# remove nonexistent name - check bug#287(segfault) does not happen.
echo "$PRE/unbound-control -c ub.conf local_data_remove test.example.net"
$PRE/unbound-control -c ub.conf local_data_remove test.example.net
# if crash then then we get: error: could not SSL_read from unbound-control
if test $? -ne 0; then
	echo "wrong exit value after success"
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# remove example.net - check its gone.
echo "$PRE/unbound-control -c ub.conf local_zone_remove example.net"
$PRE/unbound-control -c ub.conf local_zone_remove example.net
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> dig www.example.net."
dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
echo "> check answer"
if grep "SERVFAIL" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# dump the cache
echo "> test cache dump"
# fillup cache
echo "dig www.example.com"
dig @127.0.0.1 -p $UNBOUND_PORT www.example.com.
echo "$PRE/unbound-control -c ub.conf dump_cache"
$PRE/unbound-control -c ub.conf dump_cache > tmp.$$
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
cat tmp.$$
if grep 10.20.30.40 tmp.$$; then
	echo "OK example.com is in cache dump"
else
	echo "Not OK cache dump"
	exit 1
fi

# test lookup 
echo "$PRE/unbound-control -c ub.conf lookup www.example.com"
$PRE/unbound-control -c ub.conf lookup www.example.com
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
# answer to lookup is meaningless because of use a forwarder, oh well.

# load the cache dump.
echo "$PRE/unbound-control -c ub.conf load_cache < tmp.$$"
$PRE/unbound-control -c ub.conf load_cache < tmp.$$
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> dig www.example.com."
dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> check answer"
if grep "10.20.30.40" outfile; then
	echo "OK"
else
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "Not OK"
	exit 1
fi

# load local-zones from file
echo "$PRE/unbound-control -c ub.conf local_zones < local_zones"
$PRE/unbound-control -c ub.conf local_zones < local_zones
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> dig localzonefromfile."
dig @127.0.0.1 -p $UNBOUND_PORT localzonefromfile | tee outfile
echo "> check answer"
if grep "REFUSED" outfile; then
	echo "OK"
else
	echo "Not OK"
	exit 1
fi

# load local-data from file
echo "$PRE/unbound-control -c ub.conf local_datas < local_data"
$PRE/unbound-control -c ub.conf local_datas < local_data
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> dig localdatafromfile."
dig @127.0.0.1 -p $UNBOUND_PORT -t txt localdatafromfile | tee outfile
echo "> check answer"
if grep "local data from file OK" outfile; then
	echo "OK"
else
	echo "Not OK"
	exit 1
fi

# remove local-zone and local-data from file
echo "$PRE/unbound-control -c ub.conf local_zones_remove < local_zones_remove"
$PRE/unbound-control -c ub.conf local_zones_remove < local_zones_remove
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "$PRE/unbound-control -c ub.conf local_datas_remove < local_data_remove"
$PRE/unbound-control -c ub.conf local_datas_remove < local_data_remove
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
echo "> check zone and data removal list_local_zones"
$PRE/unbound-control -c ub.conf list_local_zones | tee outfile
if grep "localzonefromfile" outfile; then
	echo "Not OK"
	exit 1
fi
if grep "local data from file OK" outfile; then
	echo "Not OK"
	exit 1
fi
if grep "otherlocalzone" outfile; then
	echo "OK"
else
	echo "Not OK"
	exit 1
fi

# flushing
echo "$PRE/unbound-control -c ub.conf flush www.example.net"
$PRE/unbound-control -c ub.conf flush www.example.net
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

echo "$PRE/unbound-control -c ub.conf flush_type www.example.net TXT"
$PRE/unbound-control -c ub.conf flush_type www.example.net TXT
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

echo "$PRE/unbound-control -c ub.conf flush_zone example.net"
$PRE/unbound-control -c ub.conf flush_zone example.net
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi

# now stop the server
echo "$PRE/unbound-control -c ub.conf stop"
$PRE/unbound-control -c ub.conf stop
if test $? -ne 0; then
	echo "wrong exit value after success"
	exit 1
fi
# see if the server has really exited.
TRY_MAX=20
for (( try=0 ; try <= $TRY_MAX ; try++ )) ; do
	if kill -0 $UNBOUND_PID 2>&1 | tee tmp.$$; then
		echo "not stopped yet, waiting"
		sleep 1
	else
		echo "stopped OK; break"
		break;
	fi
	if grep "No such process" tmp.$$; then
		echo "stopped OK; break"
		break;
	fi
done
if kill -0 $UNBOUND_PID; then
	echo "still up!"
	echo "> cat logfiles"
	cat fwd.log 
	cat unbound.log
	echo "not stopped, failure"
	exit 1
else
	echo "stopped OK"

        if test -f ublocktrace.0; then
		if $PRE/lock-verify ublocktrace.*; then
			echo "lock-verify test worked."
		else
			echo "lock-verify test failed."
			cat fwd.log 
			cat unbound.log
			exit 1
		fi
	fi
fi

echo "> cat logfiles"
cat fwd.log 
cat unbound.log
echo "> OK"
exit 0