-#!/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)
# permissive DNS resolver we will use for the test
DNS_RESOLVER="8.8.8.8"
-if ! nslookup gnunet.org $DNS_RESOLVER &> /dev/null
+if ! nslookup gnunet.org $DNS_RESOLVER > /dev/null 2>&1
then
echo "Cannot reach DNS, skipping test"
exit 77
fi
-rm -rf /tmp/test-gnunet-gns-peer-1/
+rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
TEST_IP_PLUS="127.0.0.1"
TEST_IP_DNS="131.159.74.67"
MY_EGO="myego"
TEST_DOMAIN_PLUS="www.$MY_EGO"
TEST_DOMAIN_DNS="www3.$MY_EGO"
-which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
+which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
gnunet-arm -s -c test_gns_lookup.conf
gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
gnunet-arm -e -c test_gns_lookup.conf
-rm -rf /tmp/test-gnunet-gns-peer-1/
+rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
-if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE" ]
+# make cmp case-insensitive by converting to lower case first
+RES_CNAME_RAW=`echo $RES_CNAME_RAW | tr [A-Z] [a-z]`
+TESTEGOZONE=`echo $TESTEGOZONE | tr [A-Z] [a-z]`
+if [ "$RES_CNAME_RAW" = "server.$TESTEGOZONE" ]
then
echo "PASS: CNAME resolution from GNS"
else
exit 1
fi
-if [ "$RES_CNAME" == "$TEST_IP_PLUS" ]
+if [ "$RES_CNAME" = "$TEST_IP_PLUS" ]
then
echo "PASS: IP resolution from GNS"
else
exit 1
fi
-if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ]
+if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ]
then
echo "PASS: IP resolution from DNS"
exit 0