remove 'illegal' (non-reentrant) log logic from signal handler
[oweals/gnunet.git] / src / gns / test_gns_soa_lookup.sh
1 #!/bin/sh
2 # This file is in the public domain.
3 trap "gnunet-arm -e -c test_gns_lookup.conf" INT
4
5 LOCATION=$(which gnunet-config)
6 if [ -z $LOCATION ]
7 then
8   LOCATION="gnunet-config"
9 fi
10 $LOCATION --version 1> /dev/null
11 if test $? != 0
12 then
13         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14         exit 77
15 fi
16
17 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
18
19 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
20 MY_EGO="myego"
21 TEST_DOMAIN="homepage.$MY_EGO"
22 # some public DNS resolver we can use
23 #TEST_IP_GNS2DNS="184.172.157.218" # This one seems currently down.
24 TEST_IP_GNS2DNS="8.8.8.8"
25 TEST_RECORD_NAME="homepage"
26 TEST_RECORD_GNS2DNS="gnunet.org"
27
28 if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS > /dev/null 2>&1
29 then
30   echo "Cannot reach DNS, skipping test"
31   exit 77
32 fi
33
34 gnunet-arm -s -c test_gns_lookup.conf
35 gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
36 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf
37 RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf`
38 gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf > /dev/null 2>&1
39 gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
40 gnunet-arm -e -c test_gns_lookup.conf
41 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
42
43 if [ "x$RES_SOA" != "x" ]
44 then
45   echo "PASS: Resolved SOA for $TEST_DOMAIN to $RES_SOA."
46   exit 0
47 else
48   echo "Failed to resolve to proper SOA for $TEST_DOMAIN, got no result."
49   exit 1
50 fi