summaryrefslogtreecommitdiffstats
path: root/tests/unixForkEvent.test
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-07-23 09:54:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-07-23 09:54:05 (GMT)
commita16e39b06e99f4b423262bc6330d8574efecc94d (patch)
treed6544668243bc8a0c9398620b3e8fb008edcc88d /tests/unixForkEvent.test
parentc81da08d4a5ddf07bf70bab9be966473b2520644 (diff)
parent7a32d8f6e8b39e52c94b3a375a95bd3b6669c12e (diff)
downloadtcl-a16e39b06e99f4b423262bc6330d8574efecc94d.zip
tcl-a16e39b06e99f4b423262bc6330d8574efecc94d.tar.gz
tcl-a16e39b06e99f4b423262bc6330d8574efecc94d.tar.bz2
rebase
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..a0c3f19
--- /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 \
+ -body {
+ set folder [makeDirectory unixtestfork]
+ set pid [testfork]
+ if {$pid == 0} {
+ # we are the forked process
+ set result initialized
+ set h [open [file join $folder test.txt] w]
+ fileevent $h writable\
+ "set result writable;\
+ after cancel [after 1000 {set result timeout}]"
+ vwait result
+ close $h
+ makeFile $result result.txt $folder
+ exit
+ }
+ # we are the original process
+ while {![file readable [file join $folder result.txt]]} {}
+ viewFile result.txt $folder
+ } \
+ -result {writable} \
+ -cleanup {
+ catch { removeFolder $folder }
+ }
+
+::tcltest::cleanupTests
+return