blob: fee45fd9a4f11f2c02358b104619724ece691346 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# This file contains a collection of tests for the procedures in the file
# tclEvent.c, which includes the "update", and "vwait" Tcl
# commands. 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]]
testConstraint threaded [expr {
([info exist tcl_platform(threaded)] && $tcl_platform(threaded))
&& $tcl_platform(os) ne "Darwin"
}]
# 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 {threaded 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
|