error handling
[oweals/gnunet.git] / src / gns / test_dns2gns.sh
1 #!/bin/bash
2 # This file is in the public domain.
3 trap "gnunet-arm -e -c test_dns2gns.conf" INT
4 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
5
6 LOCATION=$(which gnunet-config)
7 if [ -z $LOCATION ]
8 then
9   LOCATION="gnunet-config"
10 fi
11 $LOCATION --version 1> /dev/null
12 if test $? != 0
13 then
14         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
15         exit 77
16 fi
17
18 rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME`
19 MY_EGO="localego"
20 TEST_IP="127.0.0.1"
21 TEST_IPV6="dead::beef"
22 LABEL="fnord"
23 TEST_DOMAIN="gnunet.org"
24
25 gnunet-arm -s -c test_dns2gns.conf
26 PKEY=`gnunet-identity -V -C $MY_EGO -c test_dns2gns.conf`
27 gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_dns2gns.conf
28 gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_dns2gns.conf
29
30 # FIXME resolution works but always returns all available records
31 # also, the records seem to be returned twice if using GNS
32
33 if nslookup -port=12000 $LABEL.$PKEY localhost && nslookup -port=12000 $LABEL.$MY_EGO localhost; then
34   echo "PASS: GNS records can be resolved using dns2gns bridge"
35 else
36   echo "FAIL: GNS records can't be resolved using dns2gns bridge"
37   rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME`
38   exit 1
39 fi
40
41 if nslookup -port=12000 gnunet.org localhost; then
42   echo "PASS: DNS records can be resolved using dns2gns bridge"
43 else
44   echo "FAIL: DNS records can't be resolved using dns2gns bridge"
45   rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME`
46   exit 1
47 fi
48 gnunet-arm -e -c test_dns2gns.conf
49
50 rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME`