You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.2 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  1. # so we can test other languages
  2. if [[ "$COUNTER_APP" == "" ]]; then
  3. COUNTER_APP="counter"
  4. fi
  5. echo "Testing counter app for: $COUNTER_APP"
  6. # run the counter app
  7. $COUNTER_APP &> /dev/null &
  8. PID=`echo $!`
  9. if [[ "$?" != 0 ]]; then
  10. echo "Error running tmsp app"
  11. echo $OUTPUT
  12. exit 1
  13. fi
  14. sleep 1
  15. OUTPUT=`(tmsp-cli batch) <<STDIN
  16. set_option serial on
  17. get_hash
  18. append_tx abc
  19. STDIN`
  20. if [[ "$?" != 0 ]]; then
  21. echo "Error running tmsp batch command"
  22. echo $OUTPUT
  23. exit 1
  24. fi
  25. # why can't we pick up the non-zero exit code here?
  26. # echo $?
  27. HASH1=`echo "$OUTPUT" | tail -n +2 | head -n 1`
  28. if [[ "${HASH1}" != "" ]]; then
  29. echo "Expected opening hash to be empty. Got $HASH1"
  30. exit 1
  31. fi
  32. OUTPUT=`(tmsp-cli batch) <<STDIN
  33. set_option serial on
  34. append_tx 0x00
  35. get_hash
  36. append_tx 0x01
  37. get_hash
  38. STDIN`
  39. if [[ "$?" != 0 ]]; then
  40. echo "Error running tmsp command"
  41. echo $OUTPUT
  42. exit 1
  43. fi
  44. HASH1=`echo "$OUTPUT" | tail -n +3 | head -n 1`
  45. HASH2=`echo "$OUTPUT" | tail -n +5 | head -n 1`
  46. if [[ "${HASH1:0:2}" != "01" ]]; then
  47. echo "Expected hash to lead with 01. Got $HASH1"
  48. exit 1
  49. fi
  50. if [[ "${HASH2:0:2}" != "02" ]]; then
  51. echo "Expected hash to lead with 02. Got $HASH2"
  52. exit 1
  53. fi
  54. echo "... Pass!"
  55. echo ""
  56. ps -p $PID > /dev/null
  57. if [[ "$?" == "0" ]]; then
  58. kill -9 $PID
  59. fi