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.
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
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] != {}}]
33 # The next two tests will hang if threads are enabled because the notifier
34 # will not necessarily wait for ever in this case, so it does not generate
37 test unixNotfy-1.1 {Tcl_DeleteFileHandler} {unixOnly && !testthread} {
40 fileevent $f writable {set x 1}
43 list [catch {vwait x} msg] $msg
44 } {1 {can't wait for variable "x": would wait forever}}
45 test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly && !testthread} {
49 fileevent $f1 writable {set x 1}
50 fileevent $f2 writable {set y 1}
55 list [catch {vwait x} msg] $msg
56 } {1 {can't wait for variable "x": would wait forever}}
59 test unixNotfy-2.1 {Tcl_DeleteFileHandler} {unixOnly testthread} {
62 fileevent $f writable {set x 1}
65 testthread create "after 500
66 testthread send [testthread id] {set x ok}
71 test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly testthread} {
75 fileevent $f1 writable {set x 1}
76 fileevent $f2 writable {set y 1}
81 testthread create "after 500
82 testthread send [testthread id] {set x ok}
93 ::tcltest::cleanupTests