os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/winPipe.test
Update contrib.
4 # This file contains a collection of tests for tclWinPipe.c
6 # Sourcing this file into Tcl runs the tests and generates output for
7 # errors. No output means no errors were found.
9 # Copyright (c) 1996 Sun Microsystems, Inc.
10 # Copyright (c) 1998-1999 by Scriptics Corporation.
12 # See the file "license.terms" for information on usage and redistribution
13 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 # RCS: @(#) $Id: winPipe.test,v 1.22.2.4 2005/04/20 00:14:54 hobbs Exp $
17 package require tcltest
18 namespace import -force ::tcltest::*
19 unset -nocomplain path
21 testConstraint exec [llength [info commands exec]]
23 set bindir [file join [pwd] [file dirname [info nameofexecutable]]]
24 set cat32 [file join $bindir cat32.exe]
26 set ::tcltest::testConstraints(cat32) [file exists $cat32]
28 if {[catch {puts console1 ""}]} {
29 set ::tcltest::testConstraints(AllocConsole) 1
31 set ::tcltest::testConstraints(.console) 1
34 set big bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n
42 set path(little) [makeFile {} little]
43 set f [open $path(little) w]
44 puts -nonewline $f "little"
47 set path(big) [makeFile {} big]
48 set f [open $path(big) w]
49 puts -nonewline $f $big
52 proc contents {file} {
59 set path(more) [makeFile {
60 while {[eof stdin] == 0} {
61 puts -nonewline [read stdin]
65 set path(stdout) [makeFile {} stdout]
66 set path(stderr) [makeFile {} stderr]
68 test winpipe-1.1 {32 bit comprehensive tests: from little file} {pcOnly exec cat32} {
69 exec $cat32 < $path(little) > $path(stdout) 2> $path(stderr)
70 list [contents $path(stdout)] [contents $path(stderr)]
72 test winpipe-1.2 {32 bit comprehensive tests: from big file} {pcOnly exec cat32} {
73 exec $cat32 < $path(big) > $path(stdout) 2> $path(stderr)
74 list [contents $path(stdout)] [contents $path(stderr)]
76 test winpipe-1.3 {32 bit comprehensive tests: a little from pipe} {pcOnly nt exec cat32} {
77 exec [interpreter] more < little | $cat32 > $path(stdout) 2> $path(stderr)
78 list [contents $path(stdout)] [contents $path(stderr)]
80 test winpipe-1.4 {32 bit comprehensive tests: a lot from pipe} {pcOnly nt exec cat32} {
81 exec [interpreter] more < big | $cat32 > $path(stdout) 2> $path(stderr)
82 list [contents $path(stdout)] [contents $path(stderr)]
84 test winpipe-1.5 {32 bit comprehensive tests: a lot from pipe} {pcOnly 95 exec cat32} {
85 exec command /c type big |& $cat32 > $path(stdout) 2> $path(stderr)
86 list [contents $path(stdout)] [contents $path(stderr)]
88 test winpipe-1.6 {32 bit comprehensive tests: from console} \
89 {pcOnly cat32 AllocConsole} {
90 # would block waiting for human input
92 test winpipe-1.7 {32 bit comprehensive tests: from NUL} {pcOnly exec cat32} {
93 exec $cat32 < nul > $path(stdout) 2> $path(stderr)
94 list [contents $path(stdout)] [contents $path(stderr)]
96 test winpipe-1.8 {32 bit comprehensive tests: from socket} {pcOnly cat32} {
99 test winpipe-1.9 {32 bit comprehensive tests: from nowhere} \
100 {pcOnly exec cat32 .console} {
101 exec $cat32 > $path(stdout) 2> $path(stderr)
102 list [contents $path(stdout)] [contents $path(stderr)]
104 test winpipe-1.10 {32 bit comprehensive tests: from file handle} \
105 {pcOnly exec cat32} {
106 set f [open $path(little) r]
107 exec $cat32 <@$f > $path(stdout) 2> $path(stderr)
109 list [contents $path(stdout)] [contents $path(stderr)]
111 test winpipe-1.11 {32 bit comprehensive tests: read from application} \
112 {pcOnly exec cat32} {
113 set f [open "|[list $cat32] < $path(little)" r]
118 test winpipe-1.12 {32 bit comprehensive tests: a little to file} \
119 {pcOnly exec cat32} {
120 exec $cat32 < $path(little) > $path(stdout) 2> $path(stderr)
121 list [contents $path(stdout)] [contents $path(stderr)]
123 test winpipe-1.13 {32 bit comprehensive tests: a lot to file} \
124 {pcOnly exec cat32} {
125 exec $cat32 < $path(big) > $path(stdout) 2> $path(stderr)
126 list [contents $path(stdout)] [contents $path(stderr)]
128 test winpipe-1.14 {32 bit comprehensive tests: a little to pipe} \
129 {pcOnly exec stdio cat32} {
130 exec $cat32 < $path(little) | [interpreter] $path(more) > $path(stdout) 2> $path(stderr)
131 list [contents $path(stdout)] [contents $path(stderr)]
133 test winpipe-1.15 {32 bit comprehensive tests: a lot to pipe} \
134 {pcOnly exec stdio cat32} {
135 exec $cat32 < $path(big) | [interpreter] $path(more) > $path(stdout) 2> $path(stderr)
136 list [contents $path(stdout)] [contents $path(stderr)]
138 test winpipe-1.16 {32 bit comprehensive tests: to console} {pcOnly exec cat32} {
139 catch {exec $cat32 << "You should see this\n" >@stdout} msg
142 test winpipe-1.17 {32 bit comprehensive tests: to NUL} {pcOnly exec cat32} {
143 # some apps hang when sending a large amount to NUL. $cat32 isn't one.
144 catch {exec $cat32 < $path(big) > nul} msg
147 test winpipe-1.18 {32 bit comprehensive tests: to nowhere} \
148 {pcOnly exec cat32 .console} {
149 exec $cat32 < $path(big) >&@stdout
151 test winpipe-1.19 {32 bit comprehensive tests: to file handle} {pcOnly exec cat32} {
152 set f1 [open $path(stdout) w]
153 set f2 [open $path(stderr) w]
154 exec $cat32 < $path(little) >@$f1 2>@$f2
157 list [contents $path(stdout)] [contents $path(stderr)]
159 test winpipe-1.20 {32 bit comprehensive tests: write to application} \
160 {pcOnly exec cat32} {
161 set f [open |[list $cat32 >$path(stdout)] w]
162 puts -nonewline $f "foo"
164 list [contents $path(stdout)] $msg
166 test winpipe-1.21 {32 bit comprehensive tests: read/write application} \
167 {pcOnly exec cat32} {
168 set f [open "|[list $cat32]" r+]
175 } "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
176 test winpipe-1.22 {Checking command.com for Win95/98 hanging} {pcOnly 95 exec} {
177 exec command.com /c dir /b
182 test winpipe-4.1 {Tcl_WaitPid} {pcOnly nt exec cat32} {
183 proc readResults {f} {
190 set result "$result$line"
194 set f [open "|[list $cat32] < big 2> $path(stderr)" r]
195 fconfigure $f -buffering none -blocking 0
196 fileevent $f readable "readResults $f"
200 list $result $x [contents $path(stderr)]
201 } "{$big} 1 stderr32"
202 test winpipe-4.2 {Tcl_WaitPid: return of exception codes, SIGFPE} {pcOnly exec} {
203 set f [open "|[tcltest::interpreter]" w+]
205 puts $f "testexcept float_underflow"
206 set status [catch {close $f}]
207 list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2]
209 test winpipe-4.3 {Tcl_WaitPid: return of exception codes, SIGSEGV} {pcOnly exec} {
210 set f [open "|[tcltest::interpreter]" w+]
212 puts $f "testexcept access_violation"
213 set status [catch {close $f}]
214 list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2]
216 test winpipe-4.4 {Tcl_WaitPid: return of exception codes, SIGILL} {pcOnly exec} {
217 set f [open "|[tcltest::interpreter]" w+]
219 puts $f "testexcept illegal_instruction"
220 set status [catch {close $f}]
221 list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2]
223 test winpipe-4.5 {Tcl_WaitPid: return of exception codes, SIGINT} {pcOnly exec} {
224 set f [open "|[tcltest::interpreter]" w+]
226 puts $f "testexcept ctrl+c"
227 set status [catch {close $f}]
228 list $status [expr {$pid == [lindex $::errorCode 1]}] [lindex $::errorCode 2]
231 set path(nothing) [makeFile {} nothing]
232 close [open $path(nothing) w]
234 catch {set env_tmp $env(TMP)}
235 catch {set env_temp $env(TEMP)}
240 test winpipe-5.1 {TclpCreateTempFile: cleanup temp files} {pcOnly exec} {
242 set existing [glob -nocomplain c:/tcl*.tmp]
243 exec [interpreter] < nothing
244 foreach p [glob -nocomplain c:/tcl*.tmp] {
245 if {[lsearch $existing $p] == -1} {
251 test winpipe-5.2 {TclpCreateTempFile: TMP and TEMP not defined} {pcOnly exec} {
256 exec [interpreter] < nothing
261 test winpipe-5.3 {TclpCreateTempFile: TMP specifies non-existent directory} \
265 exec [interpreter] < nothing
269 test winpipe-5.4 {TclpCreateTempFile: TEMP specifies non-existent directory} \
275 exec [interpreter] < nothing
281 test winpipe-6.1 {PipeSetupProc & PipeCheckProc: read threads} \
282 {pcOnly exec cat32} {
283 set f [open "|[list $cat32]" r+]
284 fconfigure $f -blocking 0
285 fileevent $f writable { set x writable }
288 fileevent $f writable {}
289 fileevent $f readable { lappend x readable }
290 after 100 { lappend x timeout }
296 after 100 { lappend x timeout }
298 fconfigure $f -blocking 1
299 lappend x [catch {close $f} msg] $msg
300 } {writable timeout readable {foobar
301 } timeout 1 stderr32}
302 test winpipe-6.2 {PipeSetupProc & PipeCheckProc: write threads} \
303 {pcOnly exec cat32} {
304 set f [open "|[list $cat32]" r+]
305 fconfigure $f -blocking 0
306 fileevent $f writable { set x writable }
309 puts -nonewline $f $big$big$big$big
311 after 100 { lappend x timeout }
313 lappend x [catch {close $f} msg] $msg
314 } {writable timeout 0 {}}
316 set path(echoArgs.tcl) [makeFile {
317 puts "[list $argv0 $argv]"
320 ### validate the raw output of BuildCommandLine().
322 test winpipe-7.1 {BuildCommandLine: null arguments} {pcOnly exec} {
323 exec $env(COMSPEC) /c echo foo "" bar
325 test winpipe-7.2 {BuildCommandLine: null arguments} {pcOnly exec} {
326 exec $env(COMSPEC) /c echo foo {} bar
328 test winpipe-7.3 {BuildCommandLine: dbl quote quoting #1} {pcOnly exec} {
329 exec $env(COMSPEC) /c echo foo {"} bar
331 test winpipe-7.4 {BuildCommandLine: dbl quote quoting #2} {pcOnly exec} {
332 exec $env(COMSPEC) /c echo foo {""} bar
334 test winpipe-7.5 {BuildCommandLine: dbl quote quoting #3} {pcOnly exec} {
335 exec $env(COMSPEC) /c echo foo {" } bar
337 test winpipe-7.6 {BuildCommandLine: dbl quote quoting #4} {pcOnly exec} {
338 exec $env(COMSPEC) /c echo foo {a="b"} bar
340 test winpipe-7.7 {BuildCommandLine: dbl quote quoting #5} {pcOnly exec} {
341 exec $env(COMSPEC) /c echo foo {a = "b"} bar
342 } {foo "a = \"b\"" bar}
343 test winpipe-7.8 {BuildCommandLine: dbl quote quoting #6} {pcOnly exec} {
344 exec $env(COMSPEC) /c echo {"hello"} {""hello""} {"""hello"""} {"\"hello\""} {he llo} {he " llo}
345 } {\"hello\" \"\"hello\"\" \"\"\"hello\"\"\" \"\\\"hello\\\"\" "he llo" "he \" llo"}
346 test winpipe-7.9 {BuildCommandLine: N backslashes followed a quote rule #1} {pcOnly exec} {
347 exec $env(COMSPEC) /c echo foo \\ bar
349 test winpipe-7.10 {BuildCommandLine: N backslashes followed a quote rule #2} {pcOnly exec} {
350 exec $env(COMSPEC) /c echo foo \\\\ bar
352 test winpipe-7.11 {BuildCommandLine: N backslashes followed a quote rule #3} {pcOnly exec} {
353 exec $env(COMSPEC) /c echo foo \\\ \\ bar
355 test winpipe-7.12 {BuildCommandLine: N backslashes followed a quote rule #4} {pcOnly exec} {
356 exec $env(COMSPEC) /c echo foo \\\ \\\\ bar
358 test winpipe-7.13 {BuildCommandLine: N backslashes followed a quote rule #5} {pcOnly exec} {
359 exec $env(COMSPEC) /c echo foo \\\ \\\\\\ bar
360 } {foo "\ \\\\\\" bar}
361 test winpipe-7.14 {BuildCommandLine: N backslashes followed a quote rule #6} {pcOnly exec} {
362 exec $env(COMSPEC) /c echo foo \\\ \\\" bar
364 test winpipe-7.15 {BuildCommandLine: N backslashes followed a quote rule #7} {pcOnly exec} {
365 exec $env(COMSPEC) /c echo foo \\\ \\\\\" bar
366 } {foo "\ \\\\\"" bar}
367 test winpipe-7.16 {BuildCommandLine: N backslashes followed a quote rule #8} {pcOnly exec} {
368 exec $env(COMSPEC) /c echo foo \\\ \\\\\\\" bar
369 } {foo "\ \\\\\\\"" bar}
370 test winpipe-7.17 {BuildCommandLine: special chars #4} {pcOnly exec} {
371 exec $env(COMSPEC) /c echo foo \{ bar
373 test winpipe-7.18 {BuildCommandLine: special chars #5} {pcOnly exec} {
374 exec $env(COMSPEC) /c echo foo \} bar
377 ### validate the pass-thru from BuildCommandLine() to the crt's parse_cmdline().
379 test winpipe-8.1 {BuildCommandLine/parse_cmdline pass-thru: null arguments} {pcOnly exec} {
380 exec [interpreter] $path(echoArgs.tcl) foo "" bar
381 } [list $path(echoArgs.tcl) [list foo {} bar]]
382 test winpipe-8.2 {BuildCommandLine/parse_cmdline pass-thru: null arguments} {pcOnly exec} {
383 exec [interpreter] $path(echoArgs.tcl) foo {} bar
384 } [list $path(echoArgs.tcl) [list foo {} bar]]
385 test winpipe-8.3 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #1} {pcOnly exec} {
386 exec [interpreter] $path(echoArgs.tcl) foo {"} bar
387 } [list $path(echoArgs.tcl) [list foo {"} bar]]
388 test winpipe-8.4 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #2} {pcOnly exec} {
389 exec [interpreter] $path(echoArgs.tcl) foo {""} bar
390 } [list $path(echoArgs.tcl) [list foo {""} bar]]
391 test winpipe-8.5 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #3} {pcOnly exec} {
392 exec [interpreter] $path(echoArgs.tcl) foo {" } bar
393 } [list $path(echoArgs.tcl) [list foo {" } bar]]
394 test winpipe-8.6 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #4} {pcOnly exec} {
395 exec [interpreter] $path(echoArgs.tcl) foo {a="b"} bar
396 } [list $path(echoArgs.tcl) [list foo {a="b"} bar]]
397 test winpipe-8.7 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #5} {pcOnly exec} {
398 exec [interpreter] $path(echoArgs.tcl) foo {a = "b"} bar
399 } [list $path(echoArgs.tcl) [list foo {a = "b"} bar]]
400 test winpipe-8.8 {BuildCommandLine/parse_cmdline pass-thru: dbl quote quoting #6} {pcOnly exec} {
401 exec [interpreter] $path(echoArgs.tcl) {"hello"} {""hello""} {"""hello"""} {"\"hello\""} {he llo} {he " llo}
402 } [list $path(echoArgs.tcl) [list {"hello"} {""hello""} {"""hello"""} {"\"hello\""} {he llo} {he " llo}]]
403 test winpipe-8.9 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #1} {pcOnly exec} {
404 exec [interpreter] $path(echoArgs.tcl) foo \\ bar
405 } [list $path(echoArgs.tcl) [list foo \\ bar]]
406 test winpipe-8.10 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #2} {pcOnly exec} {
407 exec [interpreter] $path(echoArgs.tcl) foo \\\\ bar
408 } [list $path(echoArgs.tcl) [list foo \\\\ bar]]
409 test winpipe-8.11 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #3} {pcOnly exec} {
410 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\ bar
411 } [list $path(echoArgs.tcl) [list foo \\\ \\ bar]]
412 test winpipe-8.12 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #4} {pcOnly exec} {
413 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\ bar
414 } [list $path(echoArgs.tcl) [list foo \\\ \\\\ bar]]
415 test winpipe-8.13 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #5} {pcOnly exec} {
416 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\\ bar
417 } [list $path(echoArgs.tcl) [list foo \\\ \\\\\\ bar]]
418 test winpipe-8.14 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #6} {pcOnly exec} {
419 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\" bar
420 } [list $path(echoArgs.tcl) [list foo \\\ \\\" bar]]
421 test winpipe-8.15 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #7} {pcOnly exec} {
422 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\" bar
423 } [list $path(echoArgs.tcl) [list foo \\\ \\\\\" bar]]
424 test winpipe-8.16 {BuildCommandLine/parse_cmdline pass-thru: N backslashes followed a quote rule #8} {pcOnly exec} {
425 exec [interpreter] $path(echoArgs.tcl) foo \\\ \\\\\\\" bar
426 } [list $path(echoArgs.tcl) [list foo \\\ \\\\\\\" bar]]
427 test winpipe-8.17 {BuildCommandLine/parse_cmdline pass-thru: special chars #1} {pcOnly exec} {
428 exec [interpreter] $path(echoArgs.tcl) foo \{ bar
429 } [list $path(echoArgs.tcl) [list foo \{ bar]]
430 test winpipe-8.18 {BuildCommandLine/parse_cmdline pass-thru: special chars #2} {pcOnly exec} {
431 exec [interpreter] $path(echoArgs.tcl) foo \} bar
432 } [list $path(echoArgs.tcl) [list foo \} bar]]
433 test winpipe-8.19 {ensure parse_cmdline isn't doing wildcard replacement} {pcOnly exec} {
434 exec [interpreter] $path(echoArgs.tcl) foo * makefile.?c bar
435 } [list $path(echoArgs.tcl) [list foo * makefile.?c bar]]
437 # restore old values for env(TMP) and env(TEMP)
439 if {[catch {set env(TMP) $env_tmp}]} {
442 if {[catch {set env(TEMP) $env_temp}]} {
447 file delete big little stdout stderr nothing echoArgs.tcl
448 ::tcltest::cleanupTests