test_dht_tools.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. # This file is in the public domain.
  3. out=`mktemp /tmp/test-gnunet-dht-logXXXXXXXX`
  4. tempcfg=`mktemp /tmp/test-dht-tools.XXXXXXXX`
  5. checkout="check.out"
  6. armexe="gnunet-arm -c $tempcfg "
  7. putexe="gnunet-dht-put -c $tempcfg "
  8. getexe="gnunet-dht-get -c $tempcfg "
  9. peerinfo="gnunet-peerinfo -c $tempcfg -sq"
  10. stop_arm()
  11. {
  12. if ! $armexe $DEBUG -e -d > $out ; then
  13. echo "FAIL: error running $armexe"
  14. echo "Command output was:"
  15. cat $out
  16. rm -f $out $tempcfg
  17. exit 1
  18. fi
  19. rm -f $out $tempcfg
  20. }
  21. cp test_dht_tools.conf $tempcfg
  22. echo -n "TEST: Starting ARM..."
  23. if ! $armexe $DEBUG -s > $out ; then
  24. echo "FAIL: error running $armexe"
  25. echo "Command output was:"
  26. cat $out
  27. stop_arm
  28. exit 1
  29. fi
  30. echo "PASS"
  31. echo -n "TEST: Testing put..."
  32. if ! $putexe -k testkey -d testdata -t 8 > $out ; then
  33. echo "FAIL: error running $putexe"
  34. echo "Command output was:"
  35. cat $out
  36. stop_arm
  37. exit 1
  38. fi
  39. echo "PASS"
  40. echo -n "TEST: Testing get..."
  41. echo "Result 0, type 8:" > $checkout
  42. echo "testdata" >> $checkout
  43. if ! $getexe -k testkey -T 100ms -t 8 > $out ; then
  44. echo "FAIL: error running $putexe"
  45. echo "Command output was:"
  46. cat $out
  47. stop_arm
  48. exit 1
  49. fi
  50. if ! diff --strip-trailing-cr -q $out $checkout ; then
  51. echo "FAIL: $out and $checkout differ:"
  52. diff --strip-trailing-cr $out $checkout
  53. stop_arm
  54. exit 1
  55. fi
  56. echo "PASS"
  57. stop_arm