test_dht_tools.sh 1.4 KB

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