5
variable gnuchessplayer
8
variable failed_test_cases
11
set ::n_pass [expr $::n_pass + 1]
15
proc fail {test_case_title} {
16
set ::n_fail [expr $::n_fail + 1]
17
lappend ::failed_test_cases $test_case_title
24
proc test_cleanup { } {
25
#send -i $::gnuchessplayer "quit"
26
#close $::gnuchessplayer
29
proc test_case {title steps} {
30
puts "---------------------------------------------------------------------"
32
if {[lindex $steps 0] == "xboard"} {
33
spawn ../../src/gnuchess -x; set ::gnuchessplayer $spawn_id
34
set steps [lreplace $steps 0 0]
36
spawn ../../src/gnuchess; set ::gnuchessplayer $spawn_id
39
puts -nonewline $title
41
if {[string first "I " $step] == 0} {
42
send -i $::gnuchessplayer "[string range $step 2 end]\n"
43
} elseif {[string first "O " $step] == 0} {
45
-i $::gnuchessplayer [string range $step 2 end] {}
46
timeout {set test_pass 0}
52
if {$test_pass == 1} {
65
############################################################################
66
# Test cases for individual commands
67
############################################################################
69
test_case "Name and version" [list "O GNU Chess 6.2"]
70
test_case "Invalid move" [list "I " "O Invalid move:" "O White" "I e5" "O Invalid move:" "O White"]
71
test_case "Command: ?" [list "I ?" "O White (1)"]
72
test_case "Command: accepted" [list "I accepted" "O White (1)"]
73
test_case "Command: activate" [list "I activate" "O currently not supported" "O White (1)"]
74
test_case "Command: analyze" [list "I analyze" "O White (1)" "O 1 +" "O 2 +"]
75
test_case "Command: bk" [list "I bk" "O %)" "O White (1)"]
76
test_case "Command: bk" [list "I bk" "O %)" "O White (1)"]
77
test_case "Command: black" [list "I black" "O currently not supported" "O White (1)"]
78
test_case "Command: white" [list "I white" "O currently not supported" "O White (1)"]
79
test_case "Command: book" [list "I book" "O Incorrect book option" "O White (1)"]
81
test_case "Command: depth 1" [list "I depth 1" "O Search to a depth of 1" "O White (1)"]
82
test_case "Command: depth 5" [list "I depth 5" "O Search to a depth of 5" "O White (1)"]
83
test_case "Command: easy" [list "I easy" "O White (1)"]
84
test_case "Command: hard" [list "I hard" "O White (1)"]
85
# TODO Add more complex cases for hard and post
86
test_case "Command: edit" [list "xboard" "I edit" "O not implemented"]
87
test_case "Command: edit" [list "I xboard" "I edit" "O not implemented"]
88
test_case "Command: epdload" [list "I epdload" "O Error reading file ''" "O White (1)"]
89
test_case "Command: epdload" [list "I epdload ./Polgar-Karpov.epd" \
100
test_case "Command: load" [list "I load ./Polgar-Karpov.epd" \
102
"O . . r . . n k ." \
103
"O . . . . q p p ." \
104
"O . . . . p . . ." \
105
"O p . . n N . P ." \
106
"O P p N P . . . ." \
107
"O . P r R . Q . ." \
108
"O . . . . . P . ." \
109
"O . . . . R . K ." \
111
test_case "Command: epdsave" [list "I epdsave" "O Invalid filename" "O White (1)"]
112
file delete -force ./tmp.epd
113
test_case "Command: epdsave" [list "I epdload ./Polgar-Karpov.epd" "O . . . . R . K ." "I depth 1" "I Kh1" "O . . . . R . . K" "O White (2)" "I epdsave ./tmp.epd" "O White (2)" "I epdload ./tmp.epd" "O . . . . R . . K"]
114
file delete -force ./tmp.epd
115
test_case "Command: save" [list "I load ./Polgar-Karpov.epd" "O . . . . R . K ." "I depth 1" "I Kh1" "O . . . . R . . K" "O White (2)" "I save ./tmp.epd" "O White (2)" "I epdload ./tmp.epd" "O . . . . R . . K"]
116
file delete -force ./tmp.epd
117
test_case "Command: exit" [list "I exit" "O "]
118
test_case "Command: force" [list "I force" "O White (1)" "I e4" "O . . . . P . . ." "O Black (1)"]
119
test_case "Command: manual" [list "I manual" "O White (1)" "I e4" "O . . . . P . . ." "O Black (1)"]
120
test_case "Command: go" [list "I go" "O Thinking..." "O Black (1)" "I go" "O Thinking..." "O White (2)"]
121
# TODO Add more complex cases for go
122
test_case "Command: graphic" [list "I graphic" "O Graphic mode is enabled." "O White (1)"]
123
test_case "Command: nographic" [list "I nographic" "O Graphic mode is disabled." "O White (1)"]
124
test_case "Command: hash" [list "I hash" "O Hashing is on." "O White (1)" "I hash off" "O Hashing is off." "O White (1)" "I hash" "O Hashing is off." "O White (1)" "I hash on" "O Hashing is on." "O White (1)"]
125
test_case "Command: help" [list "I help" "O List of commands: (help COMMAND to get more help)" "O White (1)" "I help help" "O help" "O Produces a help blurb corresponding to this list of commands." "O White (1)"]
126
# TODO FIX test_case "Command: hint" [list "I hint" "O Hint:" "O White (1)"]
127
test_case "Command: ics" [list "I ics" "O " "O White (1)"]
128
test_case "Command: pgnload" [list "I pgnload ./Polgar-Karpov.pgn" \
130
"O . . r . . n k ." \
131
"O . . . . q p p ." \
132
"O . . . . p . . ." \
133
"O p . . n N . P ." \
134
"O P p N P . . . ." \
135
"O . P r R . Q . ." \
136
"O . . . . . P . ." \
137
"O . . . . R . K ." \
139
file delete -force ./tmp.pgn
140
# TODO FIX test_case "Command: pgnsave" [list "I pgnload ./Polgar-Karpov.pgn" "O . . . . R . K ." "I depth 1" "I Kh1" "O . . . . R . . K" "O White (35)" "I pgnsave ./tmp.pgn" "O White (35)" "I pgnload ./tmp.pgn" "O . . . . R . . K"]
141
file delete -force ./tmp.pgn
142
test_case "Command: pgnreplay" [list "I pgnreplay ./Polgar-Karpov.pgn" \
144
"O . . r . . n k ." \
145
"O . . . . q p p ." \
146
"O . . . . p . . ." \
147
"O p . . n N . P ." \
148
"O P p N P . . . ." \
149
"O . P r R . Q . ." \
150
"O . . . . . P . ." \
151
"O . . . . R . K ." \
153
"O r n b q k b n r" \
154
"O p p p p p p p p" \
155
"O . . . . . . . ." \
156
"O . . . . . . . ." \
157
"O . . . . . . . ." \
158
"O . . . . . . . ." \
159
"O P P P P P P P P" \
160
"O R N B Q K B N R" \
164
"O r n b q k b n r" \
165
"O p p p p p p p p" \
166
"O . . . . . . . ." \
167
"O . . . . . . . ." \
168
"O . . . . . . . ." \
169
"O . . . . . . . ." \
170
"O P P P P P P P P" \
171
"O R N B Q K B N R" \
176
"O r n b q k b n r" \
177
"O p p p p p p p p" \
178
"O . . . . . . . ." \
179
"O . . . . . . . ." \
180
"O . . . . P . . ." \
181
"O . . . . . . . ." \
182
"O P P P P . P P P" \
183
"O R N B Q K B N R" \
188
"O r n b q k b n r" \
189
"O p p . p p p p p" \
190
"O . . p . . . . ." \
191
"O . . . . . . . ." \
192
"O . . . . P . . ." \
193
"O . . . . . . . ." \
194
"O P P P P . P P P" \
195
"O R N B Q K B N R" \
200
"O . . r . . n k ." \
201
"O . . . . q p p ." \
202
"O . . . . p . . ." \
203
"O p . . n N . P ." \
204
"O P p N P . . . ." \
205
"O . P r R . Q . ." \
206
"O . . . . . P . ." \
207
"O . . . . R . K ." \
212
"O . . r . . n k ." \
213
"O . . q . . p p ." \
214
"O . . . . p . . ." \
215
"O p . . n N . P ." \
216
"O P p N P . . . ." \
217
"O . P r R . Q . ." \
218
"O . . . . . P . ." \
219
"O . . . . R . K ." \
224
"O . . r . . n k ." \
225
"O . . q . . p p ." \
226
"O . . . . p . . ." \
227
"O p . . n N . p ." \
228
"O P p N P . . . P" \
229
"O . P r R . Q . ." \
230
"O . . . . . P . ." \
231
"O . . . . R . K ." \
233
test_case "Command: level" [list "I level 40 1 2" \
234
"O Time Control: 40 moves in 60.00 secs" \
235
"O Fischer increment of 2 seconds" \
237
test_case "Command: list & name & result" [list "I list ?" \
238
"O name - list known players alphabetically" \
239
"O score - list by GNU best result first" \
240
"O reverse - list by GNU worst result first" \
242
"I name Stuart" "I result" "I name Simon" "I result" \
243
"I list name" "O Simon" "O Stuart" "O White (1)"]
244
file delete -force ./log.000
245
file delete -force ./log.001
246
file delete -force ./game.000
247
file delete -force ./game.001
248
file delete -force ./players.dat
249
test_case "Command: memory" [list "I memory" "O Current HashSize is 256 MB" "O White (1)" \
250
"I memory 128" "O Current HashSize is 128 MB"]
251
# TODO FIX "I memory 128" "O Current HashSize is 128 MB" "O White (1)"]
252
test_case "Command: new" [list "I new" "O White (1)" "I depth 1" "I e4" "O White (2)" "I new" "O White (1)"]
253
# TODO FIX test_case "Command: post & nopost" [list "I post" "O 1 +" "O White (1)" "I nopost" "O White (1)"]
254
test_case "Command: post & nopost" [list "I depth 1" "I post" "O White (1)" "I e4" "O White (2)" "I nopost" "O White (2)"]
255
test_case "Command: null" [list "I null" "O Null-move heuristic is on." "O White (1)" "I null off" "O Null-move heuristic is off." "O White (1)" "I null" "O Null-move heuristic is off." "O White (1)" "I null on" "O Null-move heuristic is on." "O White (1)"]
256
test_case "Command: otim" [list "I otim 1" "O White (1)"]
257
test_case "Command: ping" [list "I ping" "O pong" "O White (1)"]
258
# TODO FIX test_case "Command: protover" [list "xboard" "I protover" "O feature"]
259
test_case "Command: quit" [list "I quit" "O "]
260
test_case "Command: random" [list "I random" "O currently not supported" "O White (1)"]
261
test_case "Command: rating" [list "I rating" "O my rating = 0, opponent rating = 0" "O White (1)"]
262
test_case "Command: rejected" [list "I rejected" "O "]
263
# FIX test_case "Command: remove" [list "I e4" \
264
#"O . . . . P . . ." \
265
#"O . . . . . . . ." \
266
#"O P P P P . P P P" \
267
#"O R N B Q K B N R" \
270
#"O . . . . . . . ." \
271
#"O . . . . . . . ." \
272
#"O P P P P . P P P" \
273
#"O R N B Q K B N R" \
275
test_case "Command: setboard" [list "I setboard 2r2nk1/4qpp1/4p3/p2nN1P1/PpNP4/1PrR1Q2/5P2/4R1K1 w - - bm 1; id 1;" "O White (1)" "I show board" \
277
"O . . r . . n k ." \
278
"O . . . . q p p ." \
279
"O . . . . p . . ." \
280
"O p . . n N . P ." \
281
"O P p N P . . . ." \
282
"O . P r R . Q . ." \
283
"O . . . . . P . ." \
284
"O . . . . R . K ." \
286
test_case "Command: show" [list \
289
"O r n b q k b n r" \
290
"O p p p p p p p p" \
291
"O . . . . . . . ." \
292
"O . . . . . . . ." \
293
"O . . . . . . . ." \
294
"O . . . . . . . ." \
295
"O P P P P P P P P" \
296
"O R N B Q K B N R" \
300
"O Opponent rating =" \
305
"O Na3" "O No. of moves generated =" \
307
"O No. of moves generated =" \
308
"I show noncapture" \
309
"O Na3" "O No. of moves generated =" \
311
"O No. of moves generated =" \
313
"O currently not supported" \
315
"O currently not supported" \
316
"I e4" "I show game" \
317
"O White Black" "O 1. e4" "O White (2)" \
319
"O currently not supported"]
320
test_case "Command: solve" [list "I depth 1" "I solve ./Polgar-Karpov.epd" "O Best move =" "O My move is :" "O Incorrect" "O Correct=" "O White (1)"]
321
test_case "Command: solveepd" [list "I depth 1" "I solveepd ./Polgar-Karpov.epd" "O Best move =" "O My move is :" "O Incorrect" "O Total=" "O White (1)"]
322
test_case "Command: st" [list "I st 1" "O White (1)"]
323
test_case "Command: switch" [list "I switch" "O currently not supported" "O White (1)"]
324
test_case "Command: test" [list "I test" "O currently not supported" "O White (1)"]
325
test_case "Command: time" [list "I time 1" "O White (1)"]
326
test_case "Command: undo" [list "I depth 1" "I e4" \
327
"O . . . . P . . ." \
328
"O . . . . . . . ." \
329
"O P P P P . P P P" \
330
"O R N B Q K B N R" \
333
"O . . . . P . . ." \
334
"O . . . . . . . ." \
335
"O P P P P . P P P" \
336
"O R N B Q K B N R" \
339
"O . . . . . . . ." \
340
"O . . . . . . . ." \
341
"O P P P P P P P P" \
342
"O R N B Q K B N R" \
344
test_case "Command: usage" [list "I usage" "O Usage:" "O Options:" "O bug-gnu-chess@gnu.org" "O White (1)"]
345
test_case "Command: usermove" [list "I usermove e4" "O White (2)"]
346
test_case "Command: variant" [list "I variant" "O White (1)"]
347
test_case "Command: version" [list "I version" "O GNU Chess 6" "O White (1)"]
348
test_case "Command: xboard" [list "I depth 1" "I e4" "O move" "I new" "I xboard off" "I e4" "O My move is :" "O White (2)" "I new" "O White (1)" "I xboard on" "I e4" "O move"]
351
puts "====================================================================="
352
puts "\nTests results:\n\tPASS: $::n_pass\n\tFAIL: $::n_fail"
353
if {$::n_fail == 0} {
357
foreach title $::failed_test_cases {
365
set failed_test_cases [list]