test: shellcheck

This commit is contained in:
Ethan Buchman 2017-02-20 18:51:00 -05:00
parent 2b1b8da58d
commit 1fa6e7f3b1
5 changed files with 29 additions and 29 deletions

View File

@ -1,5 +1,5 @@
#! /bin/bash #! /bin/bash
cd $GOPATH/src/github.com/tendermint/tendermint cd "$GOPATH/src/github.com/tendermint/tendermint"
bash ./test/persist/test_failure_indices.sh bash ./test/persist/test_failure_indices.sh

View File

@ -3,7 +3,7 @@
export TMROOT=$HOME/.tendermint_persist export TMROOT=$HOME/.tendermint_persist
rm -rf $TMROOT rm -rf "$TMROOT"
tendermint init tendermint init
TM_CMD="tendermint node --log_level=debug" # &> tendermint_${name}.log" TM_CMD="tendermint node --log_level=debug" # &> tendermint_${name}.log"
@ -40,9 +40,9 @@ function start_procs(){
} }
function kill_procs(){ function kill_procs(){
kill -9 $PID_DUMMY $PID_TENDERMINT kill -9 "$PID_DUMMY" "$PID_TENDERMINT"
wait $PID_DUMMY wait "$PID_DUMMY"
wait $PID_TENDERMINT wait "$PID_TENDERMINT"
} }
@ -59,10 +59,10 @@ function send_txs(){
# send a bunch of txs over a few blocks # send a bunch of txs over a few blocks
echo "Node is up, sending txs" echo "Node is up, sending txs"
for i in `seq 1 5`; do for i in $(seq 1 5); do
for j in `seq 1 100`; do for _ in $(seq 1 100); do
tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` tx=$(head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"')
curl -s $addr/broadcast_tx_async?tx=0x$tx &> /dev/null curl -s "$addr/broadcast_tx_async?tx=0x$tx" &> /dev/null
done done
sleep 1 sleep 1
done done
@ -70,33 +70,33 @@ function send_txs(){
failsStart=0 failsStart=0
fails=`grep -r "fail.Fail" --include \*.go . | wc -l` fails=$(grep -r "fail.Fail" --include \*.go . | wc -l)
failsEnd=$(($fails-1)) failsEnd=$((fails-1))
for failIndex in `seq $failsStart $failsEnd`; do for failIndex in $(seq $failsStart $failsEnd); do
echo "" echo ""
echo "* Test FailIndex $failIndex" echo "* Test FailIndex $failIndex"
# test failure at failIndex # test failure at failIndex
send_txs & send_txs &
start_procs 1 $failIndex start_procs 1 "$failIndex"
# tendermint should fail when it hits the fail index # tendermint should fail when it hits the fail index
kill -9 $PID_DUMMY kill -9 "$PID_DUMMY"
wait $PID_DUMMY wait "$PID_DUMMY"
start_procs 2 start_procs 2
# wait for node to handshake and make a new block # wait for node to handshake and make a new block
addr="localhost:46657" addr="localhost:46657"
curl -s $addr/status > /dev/null curl -s "$addr/status" > /dev/null
ERR=$? ERR=$?
i=0 i=0
while [ "$ERR" != 0 ]; do while [ "$ERR" != 0 ]; do
sleep 1 sleep 1
curl -s $addr/status > /dev/null curl -s "$addr/status" > /dev/null
ERR=$? ERR=$?
i=$(($i + 1)) i=$((i + 1))
if [[ $i == 10 ]]; then if [[ $i == 10 ]]; then
echo "Timed out waiting for tendermint to start" echo "Timed out waiting for tendermint to start"
exit 1 exit 1
@ -104,11 +104,11 @@ for failIndex in `seq $failsStart $failsEnd`; do
done done
# wait for a new block # wait for a new block
h1=`curl -s $addr/status | jq .result[1].latest_block_height` h1=$(curl -s $addr/status | jq .result[1].latest_block_height)
h2=$h1 h2=$h1
while [ "$h2" == "$h1" ]; do while [ "$h2" == "$h1" ]; do
sleep 1 sleep 1
h2=`curl -s $addr/status | jq .result[1].latest_block_height` h2=$(curl -s $addr/status | jq .result[1].latest_block_height)
done done
kill_procs kill_procs

View File

@ -1,9 +1,9 @@
#! /bin/bash #! /bin/bash
set -e set -e
echo `pwd` pwd
BRANCH=`git rev-parse --abbrev-ref HEAD` BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH" echo "Current branch: $BRANCH"
bash test/test_cover.sh bash test/test_cover.sh

View File

@ -5,7 +5,7 @@ PKGS=$(go list github.com/tendermint/tendermint/... | grep -v /vendor/)
set -e set -e
echo "mode: atomic" > coverage.txt echo "mode: atomic" > coverage.txt
for pkg in ${PKGS[@]}; do for pkg in ${PKGS[@]}; do
go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic $pkg go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic "$pkg"
if [ -f profile.out ]; then if [ -f profile.out ]; then
tail -n +2 profile.out >> coverage.txt; tail -n +2 profile.out >> coverage.txt;
rm profile.out rm profile.out

View File

@ -18,30 +18,30 @@ LIBS_MAKE_TEST=(go-rpc go-wire abci)
for lib in "${LIBS_GO_TEST[@]}"; do for lib in "${LIBS_GO_TEST[@]}"; do
# checkout vendored version of lib # checkout vendored version of lib
bash scripts/glide/checkout.sh $GLIDE $lib bash scripts/glide/checkout.sh "$GLIDE" "$lib"
echo "Testing $lib ..." echo "Testing $lib ..."
go test -v --race github.com/tendermint/$lib/... go test -v --race "github.com/tendermint/$lib/..."
if [[ "$?" != 0 ]]; then if [[ "$?" != 0 ]]; then
echo "FAIL" echo "FAIL"
exit 1 exit 1
fi fi
done done
DIR=`pwd` DIR=$(pwd)
for lib in "${LIBS_MAKE_TEST[@]}"; do for lib in "${LIBS_MAKE_TEST[@]}"; do
# checkout vendored version of lib # checkout vendored version of lib
bash scripts/glide/checkout.sh $GLIDE $lib bash scripts/glide/checkout.sh "$GLIDE" "$lib"
echo "Testing $lib ..." echo "Testing $lib ..."
cd $GOPATH/src/github.com/tendermint/$lib cd "$GOPATH/src/github.com/tendermint/$lib"
make test make test
if [[ "$?" != 0 ]]; then if [[ "$?" != 0 ]]; then
echo "FAIL" echo "FAIL"
exit 1 exit 1
fi fi
cd $DIR cd "$DIR"
done done
echo "" echo ""