test_gnunet_gns.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. LOCATION=`existence gnunet-config`
  14. if test -z $LOCATION; then
  15. LOCATION="gnunet-config"
  16. fi
  17. $LOCATION --version
  18. if test $? != 0
  19. then
  20. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  21. exit 77
  22. fi
  23. trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
  24. ME=`whoami`
  25. if [ "$ME" != "root" ]
  26. then
  27. echo "This test only works if run as root. Skipping."
  28. exit 77
  29. fi
  30. export PATH=".:$PATH"
  31. gnunet-service-gns -c gns.conf &
  32. sleep 1
  33. LO=`nslookup alice.gnu | grep Address | tail -n1`
  34. if [ "$LO" != "Address: 1.2.3.4" ]
  35. then
  36. echo "Fail: $LO"
  37. fi
  38. LO=`nslookup www.bob.gnu | grep Address | tail -n1`
  39. if [ "$LO" != "Address: 4.5.6.7" ]
  40. then
  41. echo "Fail: $LO"
  42. fi
  43. # XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now.
  44. kill `jobs -p`