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'
21 echo "valgrind-thread testing started"
23 exeprefix='valgrind --error-exitcode=42'
27 --sanitizer-undefined)
28 echo "sanitizer-undefined testing started"
31 postfix='2>&1 | grep "runtime error:"'
35 echo "sanitizer-thread testing started"
38 postfix='2>&1 | grep "WARNING: ThreadSanitizer:"'
41 cat << EOF > tsan.supp
49 race:TranspositionTable::probe
50 race:TranspositionTable::hashfull
54 export TSAN_OPTIONS="suppressions=./tsan.supp"
58 echo "unknown testing started"
66 # simple command line testing
71 "go wtime 8000 btime 8000 winc 500 binc 500" \
72 "bench 128 $threads 10 default depth"
75 echo "$prefix $exeprefix ./stockfish $args $postfix"
76 eval "$prefix $exeprefix ./stockfish $args $postfix"
80 # more general testing, following an uci protocol exchange
83 spawn $exeprefix ./stockfish
88 send "setoption name Threads value $threads\n"
91 send "position startpos\n"
92 send "go nodes 1000\n"
95 send "position startpos moves e2e4 e7e6\n"
96 send "go nodes 1000\n"
99 send "position fen 5rk1/1K4p1/8/8/3B4/8/8/8 b - - 0 1\n"
106 # return error code of the spawned program, useful for valgrind
107 lassign [wait] pid spawnid os_error_flag value
114 echo "$prefix expect $exps $postfix"
115 eval "$prefix expect $exps $postfix"
123 echo "instrumented testing OK"