github.com/okex/exchain@v1.8.0/libs/tendermint/abci/tests/test_cli/test.sh (about)

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