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.

42 lines
848 B

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