Change gnunet-config detection in gns tests
[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   LOCATION="gnunet-config"
8 fi
9 $LOCATION --version
10 if test $? != 0
11 then
12         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 
13         exit 77
14 fi
15
16 rm -r `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
17 TEST_DOMAIN="homepage.gnu"
18 # some public DNS resolver we can use
19 TEST_IP_GNS2DNS="184.172.157.218"
20 TEST_RECORD_NAME="homepage"
21 TEST_RECORD_GNS2DNS="gnunet.org"
22
23 if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS &> /dev/null
24 then
25   echo "Cannot reach DNS, skipping test"
26   exit 0
27 fi
28
29 gnunet-arm -s -c test_gns_lookup.conf
30 gnunet-identity -C testego -c test_gns_lookup.conf
31 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
32 RES_SOA=$(timeout 5 gnunet-gns --raw -z testego -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf)
33 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
34 gnunet-identity -D testego -c test_gns_lookup.conf
35 gnunet-arm -e -c test_gns_lookup.conf
36
37 if [ "x$RES_SOA" != "x" ]
38 then
39   echo "PASS: Resolved SOA for $TEST_DOMAIN to $RES_SOA."
40   exit 0
41 else
42   echo "Failed to resolve to proper SOA for $TEST_DOMAIN, got no result."
43   exit 1
44 fi