Merge branch 'master' of git+ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / gns / test_gnunet_gns.sh
1 #!/bin/sh
2 # This file is in the public domain.
3 # test -z being correct was a false assumption here.
4 # I have no executable 'fooble', but this will
5 # return 1:
6 # if test -z "`which fooble`"; then echo 1; fi
7 # The command builtin might not work with busybox's ash
8 # but this works for now.
9 existence()
10 {
11     command -v "$1" >/dev/null 2>&1
12 }
13
14 LOCATION=`existence gnunet-config`
15 if test -z $LOCATION; then
16     LOCATION="gnunet-config"
17 fi
18 $LOCATION --version
19 if test $? != 0
20 then
21     echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 
22     exit 77
23 fi
24
25 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
26 ME=`whoami`
27 if [ "$ME" != "root" ]
28 then
29   echo "This test only works if run as root.  Skipping."
30   exit 77
31 fi
32 export PATH=".:$PATH"
33 gnunet-service-gns -c gns.conf &
34 sleep 1
35 LO=`nslookup alice.gnu | grep Address | tail -n1`
36 if [ "$LO" != "Address: 1.2.3.4" ]
37 then
38  echo "Fail: $LO"
39 fi
40 LO=`nslookup www.bob.gnu | grep Address | tail -n1`
41 if [ "$LO" != "Address: 4.5.6.7" ]
42 then
43   echo "Fail: $LO"
44 fi
45 # XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now.
46 kill `jobs -p`