|
1 | 1 | #!/bin/bash |
2 | 2 | ulimit -s unlimited |
| 3 | +set -u |
3 | 4 |
|
4 | 5 | export CXX=g++ |
5 | 6 | export CC=gcc |
6 | 7 |
|
7 | | -if [ -n "$EVALFILE" ];then |
8 | | - export EMBEDDEDNNUEPATH=$EVALFILE |
| 8 | +if [ -n "${EVALFILE:-}" ]; then |
| 9 | + export EMBEDDEDNNUEPATH="$EVALFILE" |
9 | 10 | else |
10 | 11 | export EMBEDDEDNNUENAME=nyctophobic_narwhal.bin |
11 | 12 | fi |
@@ -44,26 +45,59 @@ $CXX $STANDARDSOURCE -ISource -ISource/nnue $OPT -lpthread -DDEBUG_TOOL -o cover |
44 | 45 |
|
45 | 46 | cd coverage-dir |
46 | 47 |
|
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 |
50 | 83 | #./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' |
67 | 101 | uci |
68 | 102 | ucinewgame |
69 | 103 | isready |
@@ -110,8 +144,10 @@ wait |
110 | 144 | isready |
111 | 145 | quit |
112 | 146 | EOF |
| 147 | +) |
| 148 | +run_cov_stdin "uci protocol" "$uci_script" ./minic.cov -uci -minOutputLevel 0 |
113 | 149 |
|
114 | | -./minic.cov -xboard -minOutputLevel 0 <<EOF |
| 150 | +xboard_script=$(cat <<'EOF' |
115 | 151 | xboard |
116 | 152 | protover 2 |
117 | 153 | post |
|
139 | 175 | wait |
140 | 176 | quit |
141 | 177 | 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 |
142 | 190 |
|
143 | 191 | for file in *.gcno; do |
144 | | - gcov -p $file |
| 192 | + run_cov "gcov $file" gcov -p $file |
145 | 193 | done |
146 | 194 |
|
147 | 195 | echo "Checking protocol coverage artifacts ..." |
148 | 196 | ls -1 minic.cov-uci.gcda minic.cov-xboard.gcda |
149 | 197 |
|
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 |
153 | 201 |
|
154 | 202 | #rm -f *.gcno |
155 | 203 | #rm -f *.gcda |
156 | 204 |
|
157 | 205 | ls |
158 | 206 |
|
| 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 | + |
159 | 214 | cd .. |
0 commit comments