X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=tests%2Freprosearch.sh;fp=tests%2Freprosearch.sh;h=9fd847ff3a9c0a6dc72c50e0f4b2c3a92dc33b2a;hp=0000000000000000000000000000000000000000;hb=ba15781be8f80746b6daed6588191297f38737fa;hpb=d39ffbeea6ad54c90123a352d50b65c5bda1561b diff --git a/tests/reprosearch.sh b/tests/reprosearch.sh new file mode 100755 index 00000000..9fd847ff --- /dev/null +++ b/tests/reprosearch.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# verify reproducible search + +error() +{ + echo "reprosearch testing failed on line $1" + exit 1 +} +trap 'error ${LINENO}' ERR + +echo "reprosearch testing started" + +# repeat two short games, separated by ucinewgame. +# with go nodes $nodes they should result in exactly +# the same node count for each iteration. +cat << EOF > repeat.exp + set timeout 10 + spawn ./stockfish + lassign \$argv nodes + + send "uci\n" + expect "uciok" + + send "ucinewgame\n" + send "position startpos\n" + send "go nodes \$nodes\n" + expect "bestmove" + + send "position startpos moves e2e4 e7e6\n" + send "go nodes \$nodes\n" + expect "bestmove" + + send "ucinewgame\n" + send "position startpos\n" + send "go nodes \$nodes\n" + expect "bestmove" + + send "position startpos moves e2e4 e7e6\n" + send "go nodes \$nodes\n" + expect "bestmove" + + send "quit\n" + expect eof +EOF + +# to increase the likelyhood of finding a non-reproducible case, +# the allowed number of nodes are varied systematically +for i in `seq 1 20` +do + + nodes=$((100*3**i/2**i)) + echo "reprosearch testing with $nodes nodes" + + # each line should appear exactly an even number of times + expect repeat.exp $nodes 2>&1 | grep -o "nodes [0-9]*" | sort | uniq -c | awk '{if ($1%2!=0) exit(1)}' + +done + +rm repeat.exp + +echo "reprosearch testing OK"