2 # check for errors under valgrind or sanitizers.
6 echo "instrumented testing failed on line $1"
9 trap 'error ${LINENO}' ERR
11 # define suitable post and prefixes for testing options
14 echo "valgrind testing started"
16 exeprefix='valgrind --error-exitcode=42'
20 --sanitizer-undefined)
21 echo "sanitizer testing started"
24 postfix='2>&1 | grep "runtime error:"'
28 echo "sanitizer testing started"
31 postfix='2>&1 | grep "WARNING: ThreadSanitizer:"'
34 cat << EOF > tsan.supp
42 race:TranspositionTable::probe
43 race:TranspositionTable::generation
44 race:TranspositionTable::hashfull
48 export TSAN_OPTIONS="suppressions=./tsan.supp"
52 echo "unknown testing started"
60 # simple command line testing
65 "go wtime 8000 btime 8000 winc 500 binc 500" \
66 "bench 128 $threads 10 default depth"
69 echo "$prefix $exeprefix ./stockfish $args $postfix"
70 eval "$prefix $exeprefix ./stockfish $args $postfix"
74 # more general testing, following an uci protocol exchange
77 spawn $exeprefix ./stockfish
82 send "setoption name Threads value $threads\n"
85 send "position startpos\n"
86 send "go nodes 1000\n"
89 send "position startpos moves e2e4 e7e6\n"
90 send "go nodes 1000\n"
93 send "position fen 5rk1/1K4p1/8/8/3B4/8/8/8 b - - 0 1\n"
100 # return error code of the spawned program, useful for valgrind
101 lassign [wait] pid spawnid os_error_flag value
108 echo "$prefix expect $exps $postfix"
109 eval "$prefix expect $exps $postfix"
117 echo "instrumented testing OK"