fixing compiler warnings
[oweals/gnunet.git] / src / dns / test_gnunet_dns.sh
1 #!/bin/bash
2
3 ME=`whoami`
4 if [ "$ME" != "root" ]
5 then
6   echo "This test only works if run as root.  Skipping."
7   exit 77
8 fi
9 if ! which sudo > /dev/null 
10 then
11   echo "This test requires sudo.  Skipping."
12   exit 77
13 fi
14 if [ ! -x `which sudo` ]
15 then
16   echo "This test requires sudo.  Skipping."
17   exit 77
18 fi
19 if ! which nslookup > /dev/null
20 then 
21   echo "This test requires nslookup.  Skipping."
22   exit 77
23 fi
24 if [ ! -x `which nslookup` ]
25 then
26   echo "This test requires nslookup.  Skipping."
27   exit 77
28 fi
29 if ! iptables -t mangle --list &> /dev/null
30 then
31   echo "This test requires iptables with 'mangle' support. Skipping."
32   exit 77
33 fi
34
35 export PATH=".:$PATH"
36 gnunet-service-dns -c dns.conf &
37 gnunet-dns-redirector -c dns.conf -4 127.0.0.1 &
38 sleep 1
39 # need to run 'nslookup' as 'nobody', as gnunet-service-dns runs as root
40 # and thus 'root' is excepted from DNS interception!
41 LO=`sudo -u nobody nslookup gnunet.org | grep Address | tail -n1`
42 if [ "$LO" != "Address: 127.0.0.1" ]
43 then
44  echo "Fail: got address $LO, wanted 127.0.0.1"
45  ret=1
46 else
47  echo "Test run, with success."
48  ret=0
49 fi
50 kill `jobs -p`
51 exit $ret