Add protocol tests
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 23 Apr 2020 22:48:10 +0000 (00:48 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 23 Apr 2020 22:48:10 +0000 (00:48 +0200)
.travis.yml
tests/protocol.sh [new file with mode: 0755]

index 88943ec..4957eac 100644 (file)
@@ -61,6 +61,7 @@ script:
 
   #
   # Check perft and reproducible search
+  - ../tests/protocol.sh
   - ../tests/perft.sh
   - ../tests/reprosearch.sh
   #
diff --git a/tests/protocol.sh b/tests/protocol.sh
new file mode 100755 (executable)
index 0000000..8b54a1c
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+# verify protocol implementations
+
+error()
+{
+  echo "protocol testing failed on line $1"
+  exit 1
+}
+trap 'error ${LINENO}' ERR
+
+echo "protocol testing started"
+
+cat << EOF > uci.exp
+   set timeout 5
+   spawn ./stockfish
+   send "uci\\n"
+   expect "default chess"
+   expect "uciok"
+   send "usi\\n"
+   expect "default shogi"
+   expect "usiok"
+   send "ucci\\n"
+   expect "option UCI_Variant"
+   expect "default xiangqi"
+   expect "ucciok"
+   send "quit\\n"
+   expect eof
+EOF
+
+cat << EOF > xboard.exp
+   set timeout 5
+   spawn ./stockfish
+   send "xboard\\n"
+   send "protover 2\\n"
+   expect "feature done=1"
+   send "ping\\n"
+   expect "pong"
+   send "ping\\n"
+   expect "pong"
+   send "quit\\n"
+   expect eof
+EOF
+
+for exp in uci.exp xboard.exp
+do
+  expect $exp > /dev/null
+  rm $exp
+done
+
+echo "protocol testing OK"