summaryrefslogtreecommitdiffstats
path: root/tests/unixForkEvent.test
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-08-22 07:09:21 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-08-22 07:09:21 (GMT)
commit2f5ec3509d4e78728930acdb71d70eec99124817 (patch)
tree4d0e3e6df74f68526a9dc07d56327e5c4cbab382 /tests/unixForkEvent.test
parent5703a8e2b37f931de4a54b10dc8dd269848da9bb (diff)
parent3f61f168eb9d98c28312cdea25b214827c3692f2 (diff)
downloadtcl-2f5ec3509d4e78728930acdb71d70eec99124817.zip
tcl-2f5ec3509d4e78728930acdb71d70eec99124817.tar.gz
tcl-2f5ec3509d4e78728930acdb71d70eec99124817.tar.bz2
merge trunk
Diffstat (limited to 'tests/unixForkEvent.test')
-rw-r--r--tests/unixForkEvent.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/unixForkEvent.test b/tests/unixForkEvent.test
new file mode 100644
index 0000000..120f362
--- /dev/null
+++ b/tests/unixForkEvent.test
@@ -0,0 +1,45 @@
+# This file contains a collection of tests for the procedures in the file
+# tclUnixNotify.c. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 1995-1997 Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+package require tcltest 2
+namespace import -force ::tcltest::*
+
+testConstraint testfork [llength [info commands testfork]]
+
+# Test if the notifier thread is well initialized in a forked interpreter
+# by Tcl_InitNotifier
+test unixforkevent-1.1 {fork and test writeable event} \
+ -constraints {testfork nonPortable} \
+ -body {
+ set myFolder [makeDirectory unixtestfork]
+ set pid [testfork]
+ if {$pid == 0} {
+ # we are the forked process
+ set result initialized
+ set h [open [file join $myFolder test.txt] w]
+ fileevent $h writable\
+ "set result writable;\
+ after cancel [after 1000 {set result timeout}]"
+ vwait result
+ close $h
+ makeFile $result result.txt $myFolder
+ exit
+ }
+ # we are the original process
+ while {![file readable [file join $myFolder result.txt]]} {}
+ viewFile result.txt $myFolder
+ } \
+ -result {writable} \
+ -cleanup {
+ catch { removeFolder $myFolder }
+ }
+
+::tcltest::cleanupTests
+return