os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/unixNotfy.test
First public contribution.
1 # This file contains tests for tclUnixNotfy.c.
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1997 by Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 # RCS: @(#) $Id: unixNotfy.test,v 1.11.2.4 2005/05/14 20:52:31 das Exp $
15 # The tests should not be run if you have a notifier which is unable to
16 # detect infinite vwaits, as the tests below will hang. The presence of
17 # the "testthread" command indicates that this is the case.
19 if {[lsearch [namespace children] ::tcltest] == -1} {
20 package require tcltest 2
21 namespace import -force ::tcltest::*
24 if {[info exists tk_version]} {
25 puts "When run in a Tk shell, these tests run hang. Skipping tests ..."
26 ::tcltest::cleanupTests
30 set ::tcltest::testConstraints(testthread) \
31 [expr {[info commands testthread] != {}}]
32 # Darwin always uses a threaded notifier
33 testConstraint unthreaded [expr {
34 (![info exist tcl_platform(threaded)] || !$tcl_platform(threaded))
35 && $tcl_platform(os) ne "Darwin"
38 # The next two tests will hang if threads are enabled because the notifier
39 # will not necessarily wait for ever in this case, so it does not generate
42 test unixNotfy-1.1 {Tcl_DeleteFileHandler} \
43 -constraints {unixOnly && unthreaded} \
46 set f [open [makeFile "" foo] w]
47 fileevent $f writable {set x 1}
50 list [catch {vwait x} msg] $msg
52 -result {1 {can't wait for variable "x": would wait forever}} \
55 catch { removeFile foo }
58 test unixNotfy-1.2 {Tcl_DeleteFileHandler} \
59 -constraints {unixOnly && unthreaded} \
62 set f1 [open [makeFile "" foo] w]
63 set f2 [open [makeFile "" foo2] w]
64 fileevent $f1 writable {set x 1}
65 fileevent $f2 writable {set y 1}
70 list [catch {vwait x} msg] $msg
72 -result {1 {can't wait for variable "x": would wait forever}} \
76 catch { removeFile foo }
77 catch { removeFile foo2 }
80 test unixNotfy-2.1 {Tcl_DeleteFileHandler} \
81 -constraints {unixOnly testthread} \
84 set f [open [makeFile "" foo] w]
85 fileevent $f writable {set x 1}
88 testthread create "testthread send [testthread id] {set x ok}"
96 catch { removeFile foo }
99 test unixNotfy-2.2 {Tcl_DeleteFileHandler} \
100 -constraints {unixOnly testthread} \
103 set f1 [open [makeFile "" foo] w]
104 set f2 [open [makeFile "" foo2] w]
105 fileevent $f1 writable {set x 1}
106 fileevent $f2 writable {set y 1}
111 testthread create "testthread send [testthread id] {set x ok}"
120 catch { removeFile foo }
121 catch { removeFile foo2 }
125 ::tcltest::cleanupTests