OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / tests / unixForkEvent.test
1 # This file contains a collection of tests for the procedures in the file
2 # tclUnixNotify.c.  Sourcing this file into Tcl runs the tests and
3 # generates output for errors.  No output means no errors were found.
4 #
5 # Copyright (c) 1995-1997 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
7 #
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
11 package require tcltest 2.5
12 namespace import -force ::tcltest::*
13
14 testConstraint testfork [llength [info commands testfork]]
15
16 # Test if the notifier thread is well initialized in a forked interpreter
17 # by Tcl_InitNotifier
18 test unixforkevent-1.1 {fork and test writeable event} \
19     -constraints {testfork nonPortable} \
20     -body {
21         set myFolder [makeDirectory unixtestfork]
22         set pid [testfork]
23         if {$pid == 0} {
24             # we are the forked process
25             set result initialized
26             set h [open [file join $myFolder test.txt] w]
27             fileevent $h writable\
28                     "set result writable;\
29                     after cancel [after 1000 {set result timeout}]"
30             vwait result
31             close $h
32             makeFile $result result.txt $myFolder
33             exit
34         }
35         # we are the original process
36         while {![file readable [file join $myFolder result.txt]]} {}
37         viewFile result.txt $myFolder
38     } \
39     -result {writable} \
40     -cleanup {
41         catch { removeFolder $myFolder }
42     }
43
44 ::tcltest::cleanupTests
45 return