NAMESTORE/JSON: fix parsing exp and flags
[oweals/gnunet.git] / src / namestore / test_namestore_lookup.sh
index 7a7e9e2c57869393e3179ebdca015433c8c58f72..1c96e102af35e6c70498b01a86ad93d944791abf 100755 (executable)
@@ -1,33 +1,28 @@
 #!/bin/bash
 CONFIGURATION="test_namestore_api.conf"
 trap "gnunet-arm -e -c $CONFIGURATION" SIGINT
-rm -rf `gnunet-config -c $CONFIGURATION -s PATHS -o SERVICEHOME`
-TEST_DOMAIN_PLUS="www.gnu"
-TEST_DOMAIN_DNS="www3.gnu"
+
+LOCATION=$(which gnunet-config)
+if [ -z $LOCATION ]
+then
+  LOCATION="gnunet-config"
+fi
+$LOCATION --version 1> /dev/null
+if test $? != 0
+then
+       echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
+       exit 77
+fi
+
+rm -rf `$LOCATION -c $CONFIGURATION -s PATHS -o GNUNET_HOME`
 TEST_IP_PLUS="127.0.0.1"
-TEST_IP_DNS="131.159.74.67"
-TEST_RECORD_CNAME_SERVER="server"
-TEST_RECORD_CNAME_PLUS="server.+"
-TEST_RECORD_CNAME_DNS="gnunet.org"
-TEST_RECORD_NAME_SERVER="server"
-TEST_RECORD_NAME_PLUS="www"
 TEST_RECORD_NAME_DNS="www3"
 which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
 
-function start_peer
-{
-       gnunet-arm -s -c $CONFIGURATION
-       gnunet-identity -C testego -c $CONFIGURATION    
-}
-
-function stop_peer
-{
-       gnunet-identity -D testego -c $CONFIGURATION
-       gnunet-arm -e -c $CONFIGURATION
-}
+# start peer
+gnunet-arm -s -c $CONFIGURATION
+gnunet-identity -C testego -c $CONFIGURATION
 
-
-start_peer
 # Create a public record
 gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_DNS -t A -V $TEST_IP_PLUS -e never -c $CONFIGURATION
 NAMESTORE_RES=$?
@@ -46,20 +41,22 @@ for LINE in $OUTPUT ;
        if echo "$LINE" | grep -q "$TEST_IP_PLUS"; then
                FOUND_IP=true;
                #echo $FOUND_IP
-       fi      
- done
-stop_peer
+       fi
+done
+# stop peer
+gnunet-identity -D testego -c $CONFIGURATION
+gnunet-arm -e -c $CONFIGURATION
 
 
-if [ $FOUND_NAME == true -a $FOUND_IP == true ]
+if [ $FOUND_NAME = true -a $FOUND_IP = true ]
 then
   echo "PASS: Lookup name in namestore"
   exit 0
-elif [ $FOUND_NAME == false ]
+elif [ $FOUND_NAME = false ]
 then
   echo "FAIL: Lookup name in namestore: name not returned"
   exit 1
-elif [ $FOUND_IP == false ]
+elif [ $FOUND_IP = false ]
 then
   echo "FAIL: Lookup name in namestore: IP not returned"
   exit 1