diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | tests/unixNotfy.test | 49 |
2 files changed, 44 insertions, 8 deletions
@@ -1,5 +1,8 @@ 1999-04-06 <stanton@scriptics.com> + * tests/unixNotfy.test: Fixed hang in tests when built with thread + support. + * tests/httpold.test: Fixed broken test that didn't wait long enough for events to arrive. diff --git a/tests/unixNotfy.test b/tests/unixNotfy.test index 0d27d28..932db6d 100644 --- a/tests/unixNotfy.test +++ b/tests/unixNotfy.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: unixNotfy.test,v 1.1.2.7 1999/04/02 18:59:07 hershey Exp $ +# RCS: @(#) $Id: unixNotfy.test,v 1.1.2.8 1999/04/07 01:29:27 stanton Exp $ # The tests should not be run if you have a notifier which is unable to # detect infinite vwaits, as the tests below will hang. The presence of @@ -20,13 +20,14 @@ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] } -if {[lsearch [info commands testthread] testthread] == -1} { - puts "skipping: tests require the testthread command..." - ::tcltest::cleanupTests - return -} +set ::tcltest::testConfig(testthread) \ + [expr {[info commands testthread] != {}}] + +# The next two tests will hang if threads are enabled because the notifier +# will not necessarily wait for ever in this case, so it does not generate +# an error. -test unixNotfy-1.1 {Tcl_DeleteFileHandler} {unixOnly} { +test unixNotfy-1.1 {Tcl_DeleteFileHandler} {unixOnly && !testthread} { catch {vwait x} set f [open foo w] fileevent $f writable {set x 1} @@ -34,7 +35,7 @@ test unixNotfy-1.1 {Tcl_DeleteFileHandler} {unixOnly} { close $f list [catch {vwait x} msg] $msg } {1 {can't wait for variable "x": would wait forever}} -test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly} { +test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly && !testthread} { catch {vwait x} set f1 [open foo w] set f2 [open foo2 w] @@ -47,6 +48,38 @@ test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly} { list [catch {vwait x} msg] $msg } {1 {can't wait for variable "x": would wait forever}} + +test unixNotfy-2.1 {Tcl_DeleteFileHandler} {unixOnly testthread} { + update + set f [open foo w] + fileevent $f writable {set x 1} + vwait x + close $f + testthread create "after 500 + testthread send [testthread id] {set x ok} + testthread exit" + vwait x + set x +} {ok} +test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly testthread} { + update + set f1 [open foo w] + set f2 [open foo2 w] + fileevent $f1 writable {set x 1} + fileevent $f2 writable {set y 1} + vwait x + close $f1 + vwait y + close $f2 + testthread create "after 500 + testthread send [testthread id] {set x ok} + testthread exit" + vwait x + set x +} {ok} + + + # cleanup file delete foo file delete foo2 |