g_lock: Fix uninitalized variable reads
[Samba.git] / testprogs / blackbox / test_net_ads_dns_async.sh
blobb993ab260bb170889fd8ae24d1b24f18b896b0e9
1 #!/bin/sh
2 # Blackbox tests for net ads dns async
3 # Copyright (C) 2020 Jeremy Allison <jra@samba.org>
5 if [ $# -lt 2 ]; then
6 cat <<EOF
7 Usage: test_net_ads_dns_async.sh SERVER REALM
8 EOF
9 exit 1;
12 SERVER=$1
13 REALM=$2
14 shift 2
15 failed=0
17 samba4bindir="$BINDIR"
18 net_tool="$samba4bindir/net"
20 . `dirname $0`/subunit.sh
22 # Test looking up SERVER.REALM on server give the
23 # same IP via async and non-async DNS.
24 echo "Starting ..."
26 test_async_dns() {
27 cmd_sync='dig @$SERVER +short -t a $SERVER.$REALM'
28 eval echo "$cmd_sync"
29 ipv4_sync=$(eval $cmd_sync)
30 if [ -z "$ipv4_sync" ]; then
31 return 1
33 cmd_sync='dig @$SERVER +short -t aaaa $SERVER.$REALM'
34 eval echo "$cmd_sync"
35 ipv6_sync=$(eval $cmd_sync)
36 if [ -z "$ipv6_sync" ]; then
37 return 1
41 # Do the async request. This prints out info like:
43 # Async A record lookup - got 1 names for addc.ADDOM.SAMBA.EXAMPLE.COM
44 # hostname[0] = addc.ADDOM.SAMBA.EXAMPLE.COM, IPv4addr = 10.53.57.30
45 # Async AAAA record lookup - got 1 names for addc.ADDOM.SAMBA.EXAMPLE.COM
46 # hostname[0] = addc.ADDOM.SAMBA.EXAMPLE.COM, IPv6addr = fd00::5357:5f1e
48 # So we must grep and sed to extract the matching IPv4 address
50 cmd_async='$net_tool ads dns async $SERVER.$REALM'
51 eval echo "$cmd_async"
52 out_async=$(eval $cmd_async)
54 # Drop everything but the IPv4 address.
55 ipv4_async=`echo "$out_async" | grep IPv4addr | sed -e 's/^.*IPv4addr = //'`
56 ipv6_async=`echo "$out_async" | grep IPv6addr | sed -e 's/^.*IPv6addr = //'`
58 if [ -z "$ipv4_async" -o -z "$ipv6_async" ]; then
59 return 1
61 if [ "$ipv4_sync" != "$ipv4_async" ]; then
62 echo "DNS lookup mismatch. Sync $ipv4_sync, async $ipv4_async"
63 echo "DNS commands output. out1=$ipv4_sync, out2=$out_async"
64 return 1
66 if [ "$ipv6_sync" != "$ipv6_async" ]; then
67 echo "DNS lookup mismatch. Sync $ipv6_sync, async $ipv6_async"
68 echo "DNS commands output. out1=$ipv6_sync, out2=$out_async"
69 return 1
71 return 0
74 testit "Check async and non async DNS lookups match " test_async_dns || failed=`expr $failed + 1`
76 exit $failed