Home | History | Annotate | Line # | Download | only in dnstap
tests.sh revision 1.1.1.1.2.2
      1 #!/bin/sh
      2 #
      3 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      4 #
      5 # This Source Code Form is subject to the terms of the Mozilla Public
      6 # License, v. 2.0. If a copy of the MPL was not distributed with this
      7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      8 #
      9 # See the COPYRIGHT file distributed with this work for additional
     10 # information regarding copyright ownership.
     11 
     12 SYSTEMTESTTOP=..
     13 . $SYSTEMTESTTOP/conf.sh
     14 
     15 DIGOPTS="+short -p ${PORT}"
     16 RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf"
     17 
     18 status=0
     19 
     20 for bad in bad-*.conf
     21 do
     22 	ret=0
     23 	echo_i "checking that named-checkconf detects error in $bad"
     24 	$CHECKCONF $bad > /dev/null 2>&1
     25 	if [ $? != 1 ]; then echo_i "failed"; ret=1; fi
     26 	status=`expr $status + $ret`
     27 done
     28 
     29 for good in good-*.conf
     30 do
     31 	ret=0
     32 	echo_i "checking that named-checkconf detects no error in $good"
     33 	$CHECKCONF $good > /dev/null 2>&1
     34 	if [ $? != 0 ]; then echo_i "failed"; ret=1; fi
     35 	status=`expr $status + $ret`
     36 done
     37 
     38 $DIG $DIGOPTS @10.53.0.3 a.example > dig.out
     39 
     40 # check three different dnstap reopen/roll methods:
     41 # ns1: dnstap-reopen; ns2: dnstap -reopen; ns3: dnstap -roll
     42 mv ns1/dnstap.out ns1/dnstap.out.save
     43 mv ns2/dnstap.out ns2/dnstap.out.save
     44 
     45 if [ -n "$FSTRM_CAPTURE" ] ; then
     46 	$FSTRM_CAPTURE -t protobuf:dnstap.Dnstap -u ns4/dnstap.out \
     47 		-w dnstap.out > fstrm_capture.out 2>&1 &
     48 	fstrm_capture_pid=$!
     49 fi
     50 
     51 $RNDCCMD -s 10.53.0.1 dnstap-reopen | sed 's/^/ns1 /' | cat_i
     52 $RNDCCMD -s 10.53.0.2 dnstap -reopen | sed 's/^/ns2 /' | cat_i
     53 $RNDCCMD -s 10.53.0.3 dnstap -roll | sed 's/^/ns3 /' | cat_i
     54 $RNDCCMD -s 10.53.0.4 dnstap -reopen | sed 's/^/ns4 /' | cat_i
     55 
     56 $DIG $DIGOPTS @10.53.0.3 a.example > dig.out
     57 
     58 # XXX: file output should be flushed once a second according
     59 # to the libfstrm source, but it doesn't seem to happen until
     60 # enough data has accumulated. to get all the output, we stop
     61 # the name servers, forcing a flush on shutdown. it would be
     62 # nice to find a better way to do this.
     63 $RNDCCMD -s 10.53.0.1 stop | sed 's/^/ns1 /' | cat_i
     64 $RNDCCMD -s 10.53.0.2 stop | sed 's/^/ns2 /' | cat_i
     65 $RNDCCMD -s 10.53.0.3 stop | sed 's/^/ns3 /' | cat_i
     66 sleep 1
     67 
     68 echo_i "checking initial message counts"
     69 
     70 udp1=`$DNSTAPREAD ns1/dnstap.out.save | grep "UDP " | wc -l`
     71 tcp1=`$DNSTAPREAD ns1/dnstap.out.save | grep "TCP " | wc -l`
     72 aq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "AQ " | wc -l`
     73 ar1=`$DNSTAPREAD ns1/dnstap.out.save | grep "AR " | wc -l`
     74 cq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "CQ " | wc -l`
     75 cr1=`$DNSTAPREAD ns1/dnstap.out.save | grep "CR " | wc -l`
     76 rq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "RQ " | wc -l`
     77 rr1=`$DNSTAPREAD ns1/dnstap.out.save | grep "RR " | wc -l`
     78 
     79 udp2=`$DNSTAPREAD ns2/dnstap.out.save | grep "UDP " | wc -l`
     80 tcp2=`$DNSTAPREAD ns2/dnstap.out.save | grep "TCP " | wc -l`
     81 aq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "AQ " | wc -l`
     82 ar2=`$DNSTAPREAD ns2/dnstap.out.save | grep "AR " | wc -l`
     83 cq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "CQ " | wc -l`
     84 cr2=`$DNSTAPREAD ns2/dnstap.out.save | grep "CR " | wc -l`
     85 rq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "RQ " | wc -l`
     86 rr2=`$DNSTAPREAD ns2/dnstap.out.save | grep "RR " | wc -l`
     87 
     88 mv ns3/dnstap.out.0 ns3/dnstap.out.save
     89 udp3=`$DNSTAPREAD ns3/dnstap.out.save | grep "UDP " | wc -l`
     90 tcp3=`$DNSTAPREAD ns3/dnstap.out.save | grep "TCP " | wc -l`
     91 aq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "AQ " | wc -l`
     92 ar3=`$DNSTAPREAD ns3/dnstap.out.save | grep "AR " | wc -l`
     93 cq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "CQ " | wc -l`
     94 cr3=`$DNSTAPREAD ns3/dnstap.out.save | grep "CR " | wc -l`
     95 rq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "RQ " | wc -l`
     96 rr3=`$DNSTAPREAD ns3/dnstap.out.save | grep "RR " | wc -l`
     97 
     98 echo_i "checking UDP message counts"
     99 ret=0
    100 [ $udp1 -eq 0 ] || {
    101 	echo_i "ns1 $udp1 expected 0"
    102 	ret=1
    103 }
    104 [ $udp2 -eq 2 ] || {
    105 	echo_i "ns2 $udp2 expected 2"
    106 	ret=1
    107 }
    108 [ $udp3 -eq 4 ] || {
    109 	echo_i "ns3 $udp3 expected 4"
    110 	ret=1
    111 }
    112 if [ $ret != 0 ]; then echo_i "failed"; fi
    113 status=`expr $status + $ret`
    114 
    115 echo_i "checking TCP message counts"
    116 ret=0
    117 [ $tcp1 -eq 6 ] || {
    118 	echo_i "ns1 $tcp1 expected 6"
    119 	ret=1
    120 }
    121 [ $tcp2 -eq 2 ] || {
    122 	echo_i "ns2 $tcp2 expected 2"
    123 	ret=1
    124 }
    125 [ $tcp3 -eq 6 ] || {
    126 	echo_i "ns3 $tcp3 expected 6"
    127 	ret=1
    128 }
    129 if [ $ret != 0 ]; then echo_i "failed"; fi
    130 status=`expr $status + $ret`
    131 
    132 echo_i "checking AUTH_QUERY message counts"
    133 ret=0
    134 [ $aq1 -eq 2 ] || {
    135 	echo_i "ns1 $aq1 exepcted 2"
    136 	ret=1
    137 }
    138 [ $aq2 -eq 1 ] || {
    139 	echo_i "ns2 $aq2 expected 1"
    140 	ret=1
    141 }
    142 [ $aq3 -eq 0 ] || {
    143 	echo_i "ns3 $aq3 expected 0"
    144 	ret=1
    145 }
    146 if [ $ret != 0 ]; then echo_i "failed"; fi
    147 status=`expr $status + $ret`
    148 
    149 echo_i "checking AUTH_RESPONSE message counts"
    150 ret=0
    151 [ $ar1 -eq 2 ] || {
    152 	echo_i "ns1 $ar1 expected 2"
    153 	ret=1
    154 }
    155 [ $ar2 -eq 1 ] || {
    156 	echo_i "ns2 $ar2 expected 1"
    157 	ret=1
    158 }
    159 [ $ar3 -eq 0 ] || {
    160 	echo_i "ns3 $ar3 expected 0"
    161 	ret=1
    162 }
    163 if [ $ret != 0 ]; then echo_i "failed"; fi
    164 status=`expr $status + $ret`
    165 
    166 echo_i "checking CLIENT_QUERY message counts"
    167 ret=0
    168 [ $cq1 -eq 1 ] || {
    169 	echo_i "ns1 $cq1 expected 1"
    170 	ret=1
    171 }
    172 [ $cq2 -eq 1 ] || {
    173 	echo_i "ns2 $cq2 expected 1"
    174 	ret=1
    175 }
    176 [ $cq3 -eq 2 ] || {
    177 	echo_i "ns3 $cq3 expected 2"
    178 	ret=1
    179 }
    180 if [ $ret != 0 ]; then echo_i "failed"; fi
    181 status=`expr $status + $ret`
    182 
    183 echo_i "checking CLIENT_RESPONSE message counts"
    184 ret=0
    185 [ $cr1 -eq 1 ] || {
    186 	echo_i "ns1 $cr1 expected 1"
    187 	ret=1
    188 }
    189 [ $cr2 -eq 1 ] || {
    190 	echo_i "ns2 $cr2 expected 1"
    191 	ret=1
    192 }
    193 [ $cr3 -eq 2 ] || {
    194 	echo_i "ns3 $cr3 expected 2"
    195 	ret=1
    196 }
    197 if [ $ret != 0 ]; then echo_i "failed"; fi
    198 status=`expr $status + $ret`
    199 
    200 echo_i "checking RESOLVER_QUERY message counts"
    201 ret=0
    202 [ $rq1 -eq 0 ] || {
    203 	echo_i "ns1 $rq1 expected 0"
    204 	ret=1
    205 }
    206 [ $rq2 -eq 0 ] || {
    207 	echo_i "ns2 $rq2 expected 0"
    208 	ret=1
    209 }
    210 [ $rq3 -eq 3 ] || {
    211 	echo_i "ns3 $rq3 expected 3"
    212 	ret=1
    213 }
    214 if [ $ret != 0 ]; then echo_i "failed"; fi
    215 status=`expr $status + $ret`
    216 
    217 echo_i "checking RESOLVER_RESPONSE message counts"
    218 ret=0
    219 [ $rr1 -eq 0 ] || {
    220 	echo_i "ns1 $rr1 expected 0"
    221 	ret=1
    222 }
    223 [ $rr2 -eq 0 ] || {
    224 	echo_i "ns2 $rr2 expected 0"
    225 	ret=1
    226 }
    227 [ $rr3 -eq 3 ] || {
    228 	echo_i "ns3 $rr3 expected 3"
    229 	ret=1
    230 }
    231 if [ $ret != 0 ]; then echo_i "failed"; fi
    232 status=`expr $status + $ret`
    233 
    234 echo_i "checking reopened message counts"
    235 
    236 udp1=`$DNSTAPREAD ns1/dnstap.out | grep "UDP " | wc -l`
    237 tcp1=`$DNSTAPREAD ns1/dnstap.out | grep "TCP " | wc -l`
    238 aq1=`$DNSTAPREAD ns1/dnstap.out | grep "AQ " | wc -l`
    239 ar1=`$DNSTAPREAD ns1/dnstap.out | grep "AR " | wc -l`
    240 cq1=`$DNSTAPREAD ns1/dnstap.out | grep "CQ " | wc -l`
    241 cr1=`$DNSTAPREAD ns1/dnstap.out | grep "CR " | wc -l`
    242 rq1=`$DNSTAPREAD ns1/dnstap.out | grep "RQ " | wc -l`
    243 rr1=`$DNSTAPREAD ns1/dnstap.out | grep "RR " | wc -l`
    244 
    245 udp2=`$DNSTAPREAD ns2/dnstap.out | grep "UDP " | wc -l`
    246 tcp2=`$DNSTAPREAD ns2/dnstap.out | grep "TCP " | wc -l`
    247 aq2=`$DNSTAPREAD ns2/dnstap.out | grep "AQ " | wc -l`
    248 ar2=`$DNSTAPREAD ns2/dnstap.out | grep "AR " | wc -l`
    249 cq2=`$DNSTAPREAD ns2/dnstap.out | grep "CQ " | wc -l`
    250 cr2=`$DNSTAPREAD ns2/dnstap.out | grep "CR " | wc -l`
    251 rq2=`$DNSTAPREAD ns2/dnstap.out | grep "RQ " | wc -l`
    252 rr2=`$DNSTAPREAD ns2/dnstap.out | grep "RR " | wc -l`
    253 
    254 udp3=`$DNSTAPREAD ns3/dnstap.out | grep "UDP " | wc -l`
    255 tcp3=`$DNSTAPREAD ns3/dnstap.out | grep "TCP " | wc -l`
    256 aq3=`$DNSTAPREAD ns3/dnstap.out | grep "AQ " | wc -l`
    257 ar3=`$DNSTAPREAD ns3/dnstap.out | grep "AR " | wc -l`
    258 cq3=`$DNSTAPREAD ns3/dnstap.out | grep "CQ " | wc -l`
    259 cr3=`$DNSTAPREAD ns3/dnstap.out | grep "CR " | wc -l`
    260 rq3=`$DNSTAPREAD ns3/dnstap.out | grep "RQ " | wc -l`
    261 rr3=`$DNSTAPREAD ns3/dnstap.out | grep "RR " | wc -l`
    262 
    263 echo_i "checking UDP message counts"
    264 ret=0
    265 [ $udp1 -eq 0 ] || {
    266 	echo_i "ns1 $udp1 expected 0"
    267 	ret=1
    268 }
    269 [ $udp2 -eq 0 ] || {
    270 	echo_i "ns2 $udp2 expected 0"
    271 	ret=1
    272 }
    273 [ $udp3 -eq 2 ] || {
    274 	echo_i "ns3 $udp3 expected 2"
    275 	ret=1
    276 }
    277 if [ $ret != 0 ]; then echo_i "failed"; fi
    278 status=`expr $status + $ret`
    279 
    280 echo_i "checking TCP message counts"
    281 ret=0
    282 [ $tcp1 -eq 0 ] || {
    283 	echo_i "ns1 $tcp1 expected 0"
    284 	ret=1
    285 }
    286 [ $tcp2 -eq 0 ] || {
    287 	echo_i "ns2 $tcp2 expected 0"
    288 	ret=1
    289 }
    290 [ $tcp3 -eq 0 ] || {
    291 	echo_i "ns3 $tcp3 expected 0"
    292 	ret=1
    293 }
    294 if [ $ret != 0 ]; then echo_i "failed"; fi
    295 status=`expr $status + $ret`
    296 
    297 echo_i "checking AUTH_QUERY message counts"
    298 ret=0
    299 [ $aq1 -eq 0 ] || {
    300 	echo_i "ns1 $aq1 exepcted 0"
    301 	ret=1
    302 }
    303 [ $aq2 -eq 0 ] || {
    304 	echo_i "ns2 $aq2 expected 0"
    305 	ret=1
    306 }
    307 [ $aq3 -eq 0 ] || {
    308 	echo_i "ns3 $aq3 expected 0"
    309 	ret=1
    310 }
    311 if [ $ret != 0 ]; then echo_i "failed"; fi
    312 status=`expr $status + $ret`
    313 
    314 echo_i "checking AUTH_RESPONSE message counts"
    315 ret=0
    316 [ $ar1 -eq 0 ] || {
    317 	echo_i "ns1 $ar1 expected 0"
    318 	ret=1
    319 }
    320 [ $ar2 -eq 0 ] || {
    321 	echo_i "ns2 $ar2 expected 0"
    322 	ret=1
    323 }
    324 [ $ar3 -eq 0 ] || {
    325 	echo_i "ns3 $ar3 expected 0"
    326 	ret=1
    327 }
    328 if [ $ret != 0 ]; then echo_i "failed"; fi
    329 status=`expr $status + $ret`
    330 
    331 echo_i "checking CLIENT_QUERY message counts"
    332 ret=0
    333 [ $cq1 -eq 0 ] || {
    334 	echo_i "ns1 $cq1 expected 0"
    335 	ret=1
    336 }
    337 [ $cq2 -eq 0 ] || {
    338 	echo_i "ns2 $cq2 expected 0"
    339 	ret=1
    340 }
    341 [ $cq3 -eq 1 ] || {
    342 	echo_i "ns3 $cq3 expected 1"
    343 	ret=1
    344 }
    345 if [ $ret != 0 ]; then echo_i "failed"; fi
    346 status=`expr $status + $ret`
    347 
    348 echo_i "checking CLIENT_RESPONSE message counts"
    349 ret=0
    350 [ $cr1 -eq 0 ] || {
    351 	echo_i "ns1 $cr1 expected 0"
    352 	ret=1
    353 }
    354 [ $cr2 -eq 0 ] || {
    355 	echo_i "ns2 $cr2 expected 0"
    356 	ret=1
    357 }
    358 [ $cr3 -eq 1 ] || {
    359 	echo_i "ns3 $cr3 expected 1"
    360 	ret=1
    361 }
    362 if [ $ret != 0 ]; then echo_i "failed"; fi
    363 status=`expr $status + $ret`
    364 
    365 echo_i "checking RESOLVER_QUERY message counts"
    366 ret=0
    367 [ $rq1 -eq 0 ] || {
    368 	echo_i "ns1 $rq1 expected 0"
    369 	ret=1
    370 }
    371 [ $rq2 -eq 0 ] || {
    372 	echo_i "ns2 $rq2 expected 0"
    373 	ret=1
    374 }
    375 [ $rq3 -eq 0 ] || {
    376 	echo_i "ns3 $rq3 expected 0"
    377 	ret=1
    378 }
    379 if [ $ret != 0 ]; then echo_i "failed"; fi
    380 status=`expr $status + $ret`
    381 
    382 echo_i "checking RESOLVER_RESPONSE message counts"
    383 ret=0
    384 [ $rr1 -eq 0 ] || {
    385 	echo_i "ns1 $rr1 expected 0"
    386 	ret=1
    387 }
    388 [ $rr2 -eq 0 ] || {
    389 	echo_i "ns2 $rr2 expected 0"
    390 	ret=1
    391 }
    392 [ $rr3 -eq 0 ] || {
    393 	echo_i "ns3 $rr3 expected 0"
    394 	ret=1
    395 }
    396 if [ $ret != 0 ]; then echo_i "failed"; fi
    397 status=`expr $status + $ret`
    398 
    399 HAS_PYYAML=0
    400 if [ -n "$PYTHON" ] ; then
    401 	$PYTHON -c "import yaml" 2> /dev/null && HAS_PYYAML=1
    402 fi
    403 
    404 if [ $HAS_PYYAML -ne 0 ] ; then
    405 	echo_i "checking dnstap-read YAML output"
    406 	ret=0
    407         {
    408 	  $PYTHON ydump.py "$DNSTAPREAD" "ns3/dnstap.out.save" > ydump.out || ret=1
    409         } | cat_i
    410 	if [ $ret != 0 ]; then echo_i "failed"; fi
    411 	status=`expr $status + $ret`
    412 fi
    413 
    414 echo_i "checking dnstap-read hex output"
    415 ret=0
    416 hex=`$DNSTAPREAD -x ns3/dnstap.out | tail -1`
    417 echo $hex | $WIRETEST > dnstap.hex
    418 grep 'status: NOERROR' dnstap.hex > /dev/null 2>&1 || ret=1
    419 grep 'ANSWER: 3, AUTHORITY: 1' dnstap.hex > /dev/null 2>&1 || ret=1
    420 if [ $ret != 0 ]; then echo_i "failed"; fi
    421 status=`expr $status + $ret`
    422 
    423 if [ -n "$FSTRM_CAPTURE" ] ; then
    424 	$DIG $DIGOPTS @10.53.0.4 a.example > dig.out
    425 
    426 	echo_i "checking unix socket message counts"
    427 	sleep 2
    428 	kill $fstrm_capture_pid
    429 	wait
    430 	udp4=`$DNSTAPREAD dnstap.out | grep "UDP " | wc -l`
    431 	tcp4=`$DNSTAPREAD dnstap.out | grep "TCP " | wc -l`
    432 	aq4=`$DNSTAPREAD dnstap.out | grep "AQ " | wc -l`
    433 	ar4=`$DNSTAPREAD dnstap.out | grep "AR " | wc -l`
    434 	cq4=`$DNSTAPREAD dnstap.out | grep "CQ " | wc -l`
    435 	cr4=`$DNSTAPREAD dnstap.out | grep "CR " | wc -l`
    436 	rq4=`$DNSTAPREAD dnstap.out | grep "RQ " | wc -l`
    437 	rr4=`$DNSTAPREAD dnstap.out | grep "RR " | wc -l`
    438 
    439 	echo_i "checking UDP message counts"
    440 	ret=0
    441 	[ $udp4 -eq 2 ] || {
    442 		echo_i "ns4 $udp4 expected 2"
    443 		ret=1
    444 	}
    445 	if [ $ret != 0 ]; then echo_i "failed"; fi
    446 	status=`expr $status + $ret`
    447 
    448 	echo_i "checking TCP message counts"
    449 	ret=0
    450 	[ $tcp4 -eq 0 ] || {
    451 		echo_i "ns4 $tcp4 expected 0"
    452 		ret=1
    453 	}
    454 	if [ $ret != 0 ]; then echo_i "failed"; fi
    455 	status=`expr $status + $ret`
    456 
    457 	echo_i "checking AUTH_QUERY message counts"
    458 	ret=0
    459 	[ $aq4 -eq 0 ] || {
    460 		echo_i "ns4 $aq4 expected 0"
    461 		ret=1
    462 	}
    463 	if [ $ret != 0 ]; then echo_i "failed"; fi
    464 	status=`expr $status + $ret`
    465 
    466 	echo_i "checking AUTH_RESPONSE message counts"
    467 	ret=0
    468 	[ $ar4 -eq 0 ] || {
    469 		echo_i "ns4 $ar4 expected 0"
    470 		ret=1
    471 	}
    472 	if [ $ret != 0 ]; then echo_i "failed"; fi
    473 	status=`expr $status + $ret`
    474 
    475 	echo_i "checking CLIENT_QUERY message counts"
    476 	ret=0
    477 	[ $cq4 -eq 1 ] || {
    478 		echo_i "ns4 $cq4 expected 1"
    479 		ret=1
    480 	}
    481 	if [ $ret != 0 ]; then echo_i "failed"; fi
    482 	status=`expr $status + $ret`
    483 
    484 	echo_i "checking CLIENT_RESPONSE message counts"
    485 	ret=0
    486 	[ $cr4 -eq 1 ] || {
    487 		echo_i "ns4 $cr4 expected 1"
    488 		ret=1
    489 	}
    490 	if [ $ret != 0 ]; then echo_i "failed"; fi
    491 	status=`expr $status + $ret`
    492 
    493 	echo_i "checking RESOLVER_QUERY message counts"
    494 	ret=0
    495 	[ $rq4 -eq 0 ] || {
    496 		echo_i "ns4 $rq4 expected 0"
    497 		ret=1
    498 	}
    499 	if [ $ret != 0 ]; then echo_i "failed"; fi
    500 	status=`expr $status + $ret`
    501 
    502 	echo_i "checking RESOLVER_RESPONSE message counts"
    503 	ret=0
    504 	[ $rr4 -eq 0 ] || {
    505 		echo_i "ns4 $rr4 expected 0"
    506 		ret=1
    507 	}
    508 	mv dnstap.out dnstap.out.save
    509 	$FSTRM_CAPTURE -t protobuf:dnstap.Dnstap -u ns4/dnstap.out \
    510 		-w dnstap.out > fstrm_capture.out 2>&1 &
    511 	fstrm_capture_pid=$!
    512 	$RNDCCMD -s 10.53.0.4 dnstap -reopen | sed 's/^/ns4 /' | cat_i
    513 	$DIG $DIGOPTS @10.53.0.4 a.example > dig.out
    514 
    515 	echo_i "checking reopened unix socket message counts"
    516 	sleep 2
    517 	kill $fstrm_capture_pid
    518 	wait
    519 	udp4=`$DNSTAPREAD dnstap.out | grep "UDP " | wc -l`
    520 	tcp4=`$DNSTAPREAD dnstap.out | grep "TCP " | wc -l`
    521 	aq4=`$DNSTAPREAD dnstap.out | grep "AQ " | wc -l`
    522 	ar4=`$DNSTAPREAD dnstap.out | grep "AR " | wc -l`
    523 	cq4=`$DNSTAPREAD dnstap.out | grep "CQ " | wc -l`
    524 	cr4=`$DNSTAPREAD dnstap.out | grep "CR " | wc -l`
    525 	rq4=`$DNSTAPREAD dnstap.out | grep "RQ " | wc -l`
    526 	rr4=`$DNSTAPREAD dnstap.out | grep "RR " | wc -l`
    527 
    528 	echo_i "checking UDP message counts"
    529 	ret=0
    530 	[ $udp4 -eq 2 ] || {
    531 		echo_i "ns4 $udp4 expected 2"
    532 		ret=1
    533 	}
    534 	if [ $ret != 0 ]; then echo_i "failed"; fi
    535 	status=`expr $status + $ret`
    536 
    537 	echo_i "checking TCP message counts"
    538 	ret=0
    539 	[ $tcp4 -eq 0 ] || {
    540 		echo_i "ns4 $tcp4 expected 0"
    541 		ret=1
    542 	}
    543 	if [ $ret != 0 ]; then echo_i "failed"; fi
    544 	status=`expr $status + $ret`
    545 
    546 	echo_i "checking AUTH_QUERY message counts"
    547 	ret=0
    548 	[ $aq4 -eq 0 ] || {
    549 		echo_i "ns4 $aq4 expected 0"
    550 		ret=1
    551 	}
    552 	if [ $ret != 0 ]; then echo_i "failed"; fi
    553 	status=`expr $status + $ret`
    554 
    555 	echo_i "checking AUTH_RESPONSE message counts"
    556 	ret=0
    557 	[ $ar4 -eq 0 ] || {
    558 		echo_i "ns4 $ar4 expected 0"
    559 		ret=1
    560 	}
    561 	if [ $ret != 0 ]; then echo_i "failed"; fi
    562 	status=`expr $status + $ret`
    563 
    564 	echo_i "checking CLIENT_QUERY message counts"
    565 	ret=0
    566 	[ $cq4 -eq 1 ] || {
    567 		echo_i "ns4 $cq4 expected 1"
    568 		ret=1
    569 	}
    570 	if [ $ret != 0 ]; then echo_i "failed"; fi
    571 	status=`expr $status + $ret`
    572 
    573 	echo_i "checking CLIENT_RESPONSE message counts"
    574 	ret=0
    575 	[ $cr4 -eq 1 ] || {
    576 		echo_i "ns4 $cr4 expected 1"
    577 		ret=1
    578 	}
    579 	if [ $ret != 0 ]; then echo_i "failed"; fi
    580 	status=`expr $status + $ret`
    581 
    582 	echo_i "checking RESOLVER_QUERY message counts"
    583 	ret=0
    584 	[ $rq4 -eq 0 ] || {
    585 		echo_i "ns4 $rq4 expected 0"
    586 		ret=1
    587 	}
    588 	if [ $ret != 0 ]; then echo_i "failed"; fi
    589 	status=`expr $status + $ret`
    590 
    591 	echo_i "checking RESOLVER_RESPONSE message counts"
    592 	ret=0
    593 	[ $rr4 -eq 0 ] || {
    594 		echo_i "ns4 $rr4 expected 0"
    595 		ret=1
    596 	}
    597 fi
    598 
    599 echo_i "exit status: $status"
    600 [ $status -eq 0 ] || exit 1
    601