Skip to content

Commit dbebf8a

Browse files
better coverage
1 parent 51e8d0d commit dbebf8a

File tree

2 files changed

+90
-33
lines changed

2 files changed

+90
-33
lines changed

Tools/build/common

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ulimit -s unlimited
22

3-
if [ -n "${COMMON_BUILD}" ]; then
3+
if [ -n "${COMMON_BUILD:-}" ]; then
44
echo "Common tools already loaded"
55

66
else
@@ -56,7 +56,7 @@ else
5656
fi
5757
n="-fopenmp-simd"
5858
d="-DDEBUG_TOOL"
59-
if [ -n "$EMBEDDEDNNUEPATH" ]; then
59+
if [ -n "${EMBEDDEDNNUEPATH:-}" ]; then
6060
if [ "$EMBEDDEDNNUEPATH" != "none" ]; then
6161
echo "With forced embedded net $EMBEDDEDNNUEPATH"
6262
d="$d -DEMBEDDEDNNUEPATH=$EMBEDDEDNNUEPATH -DFORCEEMBEDDEDNNUE"
@@ -68,27 +68,27 @@ else
6868
d="$d -DEMBEDDEDNNUEPATH=$dir/Tourney/nn.bin -DFORCEEMBEDDEDNNUE"
6969
fi
7070

71-
if [ -n "$1" ]; then
71+
if [ -n "${1:-}" ]; then
7272
e=$1
7373
shift
7474
fi
7575

76-
if [ -n "$1" ] ; then
76+
if [ -n "${1:-}" ] ; then
7777
v=$1
7878
shift
7979
fi
8080

81-
if [ -n "$1" ] ; then
81+
if [ -n "${1:-}" ] ; then
8282
t=$1
8383
shift
8484
fi
8585

86-
if [ -n "$1" ] ; then
86+
if [ -n "${1:-}" ] ; then
8787
n=$1
8888
shift
8989
fi
9090

91-
if [ -n "$1" ] ; then
91+
if [ -n "${1:-}" ] ; then
9292
d=$1
9393
shift
9494
fi
@@ -97,6 +97,8 @@ else
9797
export v
9898
export t
9999
export d
100+
CXX=${CXX:-g++}
101+
CC=${CC:-gcc}
100102
export CXX
101103
export CC
102104

Tools/build/docov

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/bash
22
ulimit -s unlimited
3+
set -u
34

45
export CXX=g++
56
export CC=gcc
67

7-
if [ -n "$EVALFILE" ];then
8-
export EMBEDDEDNNUEPATH=$EVALFILE
8+
if [ -n "${EVALFILE:-}" ]; then
9+
export EMBEDDEDNNUEPATH="$EVALFILE"
910
else
1011
export EMBEDDEDNNUENAME=nyctophobic_narwhal.bin
1112
fi
@@ -44,26 +45,59 @@ $CXX $STANDARDSOURCE -ISource -ISource/nnue $OPT -lpthread -DDEBUG_TOOL -o cover
4445

4546
cd coverage-dir
4647

47-
./minic.cov -analyze "shirov" 25 -minOutputLevel 0
48-
./minic.cov -analyze "fine70" 25 -minOutputLevel 0 -syzygyPath /mnt/BK1/tablebase.sesse.net/syzygy/6/
49-
./minic.cov -perft "start" 6 -minOutputLevel 0
48+
COV_PROFILE=${COV_PROFILE:-quick}
49+
COV_FAIL_ON_ERROR=${COV_FAIL_ON_ERROR:-0}
50+
SYZYGY_PATH=${SYZYGY_PATH:-/mnt/BK2/tablebase.sesse.net/syzygy/6/}
51+
52+
coverage_errors=0
53+
54+
run_cov() {
55+
local label="$1"
56+
shift
57+
echo "[coverage] $label"
58+
if ! "$@"; then
59+
echo "[coverage] command failed: $label"
60+
coverage_errors=$((coverage_errors + 1))
61+
fi
62+
}
63+
64+
run_cov_stdin() {
65+
local label="$1"
66+
local input="$2"
67+
shift 2
68+
echo "[coverage] $label"
69+
if ! printf "%s\n" "$input" | "$@"; then
70+
echo "[coverage] command failed: $label"
71+
coverage_errors=$((coverage_errors + 1))
72+
fi
73+
}
74+
75+
run_cov "analyze shirov" ./minic.cov -analyze "shirov" 25 -minOutputLevel 0
76+
if [ -d "$SYZYGY_PATH" ]; then
77+
run_cov "analyze fine70 with syzygy" ./minic.cov -analyze "fine70" 25 -minOutputLevel 0 -syzygyPath "$SYZYGY_PATH"
78+
run_cov "probe syzygy" ./minic.cov -probe "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1" -minOutputLevel 0 -syzygyPath "$SYZYGY_PATH"
79+
else
80+
run_cov "analyze fine70" ./minic.cov -analyze "fine70" 25 -minOutputLevel 0
81+
fi
82+
run_cov "perft start" ./minic.cov -perft "start" 6 -minOutputLevel 0
5083
#./minic.cov -evalSpeed Book_and_Test/Tuning/lichess-new-labeled.epd
51-
./minic.cov bench 10 -minOutputLevel 0
52-
./minic.cov -selfplay 5 1 -minOutputLevel 0
53-
./minic.cov -perft_test -minOutputLevel 0
54-
./minic.cov -see_test -minOutputLevel 0
55-
./minic.cov -spsa -minOutputLevel 0
56-
./minic.cov -timeTest 1000 0 20 0 -minOutputLevel 0
57-
./minic.cov -qsearch "start" -minOutputLevel 0
58-
./minic.cov -eval "start" -minOutputLevel 0
59-
./minic.cov -evalHCE "start" -minOutputLevel 0
60-
./minic.cov -gen "start" -minOutputLevel 0
61-
./minic.cov -testmove "start" -minOutputLevel 0
62-
./minic.cov -see "start" e2e4 0 -minOutputLevel 0
63-
./minic.cov -attacked "start" 28 -minOutputLevel 0
64-
./minic.cov -cov "start" 12 -minOutputLevel 0
65-
./minic.cov -kpk "8/8/8/8/8/8/4k1P1/6K1 w - - 0 1" -minOutputLevel 0
66-
./minic.cov -uci -minOutputLevel 0 <<EOF
84+
run_cov "bench" ./minic.cov bench 10 -minOutputLevel 0
85+
run_cov "selfplay" ./minic.cov -selfplay 5 1 -minOutputLevel 0
86+
run_cov "perft_test" ./minic.cov -perft_test -minOutputLevel 0
87+
run_cov "see_test" ./minic.cov -see_test -minOutputLevel 0
88+
run_cov "spsa" ./minic.cov -spsa -minOutputLevel 0
89+
run_cov "timeTest" ./minic.cov -timeTest 1000 0 20 0 -minOutputLevel 0
90+
run_cov "qsearch" ./minic.cov -qsearch "start" -minOutputLevel 0
91+
run_cov "eval NNUE" ./minic.cov -eval "start" -minOutputLevel 0
92+
run_cov "eval HCE" ./minic.cov -evalHCE "start" -minOutputLevel 0
93+
run_cov "gen" ./minic.cov -gen "start" -minOutputLevel 0
94+
run_cov "testmove" ./minic.cov -testmove "start" -minOutputLevel 0
95+
run_cov "see" ./minic.cov -see "start" e2e4 0 -minOutputLevel 0
96+
run_cov "attacked" ./minic.cov -attacked "start" 28 -minOutputLevel 0
97+
run_cov "cov" ./minic.cov -cov "start" 12 -minOutputLevel 0
98+
run_cov "kpk" ./minic.cov -kpk "8/8/8/8/8/8/4k1P1/6K1 w - - 0 1" -minOutputLevel 0
99+
100+
uci_script=$(cat <<'EOF'
67101
uci
68102
ucinewgame
69103
isready
@@ -110,8 +144,10 @@ wait
110144
isready
111145
quit
112146
EOF
147+
)
148+
run_cov_stdin "uci protocol" "$uci_script" ./minic.cov -uci -minOutputLevel 0
113149

114-
./minic.cov -xboard -minOutputLevel 0 <<EOF
150+
xboard_script=$(cat <<'EOF'
115151
xboard
116152
protover 2
117153
post
@@ -139,21 +175,40 @@ go
139175
wait
140176
quit
141177
EOF
178+
)
179+
run_cov_stdin "xboard protocol" "$xboard_script" ./minic.cov -xboard -minOutputLevel 0
180+
181+
if ./minic.cov --help_test -minOutputLevel 0 >/dev/null 2>&1; then
182+
run_cov "testsuite arasan_sym" ./minic.cov arasan_sym -minOutputLevel 0
183+
fi
184+
185+
if [ "$COV_PROFILE" = "full" ]; then
186+
run_cov "benchBig" ./minic.cov benchBig 8 -minOutputLevel 0
187+
run_cov "perft_test_long" ./minic.cov -perft_test_long -minOutputLevel 0
188+
run_cov "perft_test_long_fischer" ./minic.cov -perft_test_long_fischer -minOutputLevel 0
189+
fi
142190

143191
for file in *.gcno; do
144-
gcov -p $file
192+
run_cov "gcov $file" gcov -p $file
145193
done
146194

147195
echo "Checking protocol coverage artifacts ..."
148196
ls -1 minic.cov-uci.gcda minic.cov-xboard.gcda
149197

150-
lcov -d "$(pwd)" -b "$(readlink -f ../)" -c -o rapport.info --no-external --ignore-errors negative
151-
genhtml -o rapport -t "coverage" rapport.info
152-
lcov -l rapport.info
198+
run_cov "lcov capture" lcov -d "$(pwd)" -b "$(readlink -f ../)" -c -o rapport.info --no-external --ignore-errors negative
199+
run_cov "genhtml" genhtml -o rapport -t "coverage" rapport.info
200+
run_cov "lcov list" lcov -l rapport.info
153201

154202
#rm -f *.gcno
155203
#rm -f *.gcda
156204

157205
ls
158206

207+
if [ "$coverage_errors" -ne 0 ]; then
208+
echo "Coverage run completed with $coverage_errors failing command(s)."
209+
if [ "$COV_FAIL_ON_ERROR" = "1" ]; then
210+
exit 1
211+
fi
212+
fi
213+
159214
cd ..

0 commit comments

Comments
 (0)