aboutsummaryrefslogtreecommitdiffstats
path: root/eth/test/run.sh
blob: 5229af0353002ceb2edaf2700a46ad903bf9b928 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# bash run.sh (testid0 testid1 ...)
# runs tests tests/testid0.sh tests/testid1.sh ...
# without arguments, it runs all tests

. tests/common.sh

TESTS=

if [ "$#" -eq 0 ]; then
  for NAME in tests/??.sh; do
    i=`basename $NAME .sh`
    TESTS="$TESTS $i"
  done
else
  TESTS=$@
fi

ETH=../../ethereum
DIR="/tmp/eth.test/nodes"
TIMEOUT=10

mkdir -p $DIR/js

echo "running tests $TESTS"
for NAME in $TESTS; do
  PIDS=
  CHAIN="tests/$NAME.chain"
  JSFILE="$DIR/js/$NAME.js"
  CHAIN_TEST="$DIR/$NAME/chain"

  echo "RUN: test $NAME"
  cat tests/common.js > $JSFILE
  . tests/$NAME.sh
  sleep $TIMEOUT
  echo "timeout after $TIMEOUT seconds: killing $PIDS"
  kill $PIDS
  if [ -r "$CHAIN" ]; then
    if diff $CHAIN $CHAIN_TEST >/dev/null ; then
      echo "chain ok: $CHAIN=$CHAIN_TEST"
    else
      echo "FAIL: chains differ: expected $CHAIN ; got $CHAIN_TEST"
      continue
    fi
  fi
  ERRORS=$DIR/errors
  if [ -r "$ERRORS" ]; then
    echo "FAIL: "
    cat $ERRORS
  else
    echo PASS
  fi
done