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.

43 lines
875 B

8 years ago
7 years ago
  1. #! /bin/bash
  2. set -e
  3. # Get the root directory.
  4. export PATH="$GOBIN:$PATH"
  5. SOURCE="${BASH_SOURCE[0]}"
  6. while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
  7. DIR="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
  8. # Change into that dir because we expect that.
  9. cd "$DIR" || exit
  10. function testExample() {
  11. N=$1
  12. INPUT=$2
  13. APP="$3 $4"
  14. echo "Example $N: $APP"
  15. $APP &> /dev/null &
  16. sleep 2
  17. abci-cli --log_level=error --verbose batch < "$INPUT" > "${INPUT}.out.new"
  18. killall "$3"
  19. pre=$(shasum < "${INPUT}.out")
  20. post=$(shasum < "${INPUT}.out.new")
  21. if [[ "$pre" != "$post" ]]; then
  22. echo "You broke the tutorial"
  23. echo "Got:"
  24. cat "${INPUT}.out.new"
  25. echo "Expected:"
  26. cat "${INPUT}.out"
  27. exit 1
  28. fi
  29. rm "${INPUT}".out.new
  30. }
  31. testExample 1 tests/test_cli/ex1.abci abci-cli kvstore
  32. testExample 2 tests/test_cli/ex2.abci abci-cli counter
  33. echo ""
  34. echo "PASS"