272aa74423bf157b3d0fdd64c56f79aeeff55f82
[oweals/gnunet.git] / src / gns / test_gns_soa_lookup.sh
1 #!/bin/bash
2 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3
4 LOCATION=$(which gnunet-config)
5 if [ -z $LOCATION ]
6 then
7         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 
8         exit 1
9 fi
10
11 rm -r `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
12 TEST_DOMAIN="homepage.gnu"
13 # some public DNS resolver we can use
14 TEST_IP_GNS2DNS="184.172.157.218"
15 TEST_RECORD_NAME="homepage"
16 TEST_RECORD_GNS2DNS="gnunet.org"
17
18 if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS &> /dev/null
19 then
20   echo "Cannot reach DNS, skipping test"
21   exit 0
22 fi
23
24 gnunet-arm -s -c test_gns_lookup.conf
25 gnunet-identity -C testego -c test_gns_lookup.conf
26 gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf
27 RES_SOA=$(timeout 5 gnunet-gns --raw -z testego -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf)
28 gnunet-namestore -z testego -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf &> /dev/null
29 gnunet-identity -D testego -c test_gns_lookup.conf
30 gnunet-arm -e -c test_gns_lookup.conf
31
32 if [ "x$RES_SOA" != "x" ]
33 then
34   echo "PASS: Resolved SOA for $TEST_DOMAIN to $RES_SOA."
35   exit 0
36 else
37   echo "Failed to resolve to proper SOA for $TEST_DOMAIN, got no result."
38   exit 1
39 fi