-#!/bin/bash
+#!/bin/sh
+# This file is in the public domain.
trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
LOCATION=$(which gnunet-config)
XNS=ns.joker.com
-if ! nslookup gnunet.org a.$XNS &> /dev/null
+if ! nslookup gnunet.org a.$XNS > /dev/null 2>&1
then
echo "Cannot reach DNS, skipping test"
exit 77
# various names we will use for resolution
TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
+which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
+
gnunet-arm -s -c test_gns_lookup.conf
+OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org`
+echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping test"; exit 77; }
+echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping test"; exit 77; }
+
+
gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
# set IP address for DNS resolver for resolving in gnunet.org domain
gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf
gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf
-which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
echo "EGOs:"
gnunet-identity -d
rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
ret=0
-if [ "$RES_IP" == "$TEST_IP" ]
+if echo "$RES_IP" | grep "$TEST_IP" > /dev/null
then
echo "PASS: Resolved $TEST_DOMAIN to $RES_IP."
else
ret=1
fi
-if [ "$RES_IP6" == "$TEST_IP6" ]
+if [ "$RES_IP6" = "$TEST_IP6" ]
then
echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6."
else