Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/Stockfish
Path: blob/master/tests/signature.sh
376 views
1
#!/bin/bash
2
# obtain and optionally verify Bench / signature
3
# if no reference is given, the output is deliberately limited to just the signature
4
5
STDOUT_FILE=$(mktemp)
6
STDERR_FILE=$(mktemp)
7
8
error()
9
{
10
echo "running bench for signature failed on line $1"
11
echo "===== STDOUT ====="
12
cat "$STDOUT_FILE"
13
echo "===== STDERR ====="
14
cat "$STDERR_FILE"
15
rm -f "$STDOUT_FILE" "$STDERR_FILE"
16
exit 1
17
}
18
trap 'error ${LINENO}' ERR
19
20
# obtain
21
eval "$WINE_PATH ./stockfish bench" > "$STDOUT_FILE" 2> "$STDERR_FILE" || error ${LINENO}
22
signature=$(grep "Nodes searched : " "$STDERR_FILE" | awk '{print $4}')
23
24
rm -f "$STDOUT_FILE" "$STDERR_FILE"
25
26
if [ $# -gt 0 ]; then
27
# compare to given reference
28
if [ "$1" != "$signature" ]; then
29
if [ -z "$signature" ]; then
30
echo "No signature obtained from bench. Code crashed or assert triggered ?"
31
else
32
echo "signature mismatch: reference $1 obtained: $signature ."
33
fi
34
exit 1
35
else
36
echo "signature OK: $signature"
37
fi
38
else
39
# just report signature
40
echo $signature
41
fi
42