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 © 1995-1997 Sun Microsystems, Inc. 6# Copyright © 1998-1999 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 11if {"::tcltest" ni [namespace children]} { 12 package require tcltest 2.5 13 namespace import -force ::tcltest::* 14} 15 16testConstraint testfork [llength [info commands testfork]] 17 18# Test if the notifier thread is well initialized in a forked interpreter 19# by Tcl_InitNotifier 20test unixforkevent-1.1 {fork and test writeable event} \ 21 -constraints {testfork nonPortable} \ 22 -body { 23 set myFolder [makeDirectory unixtestfork] 24 set pid [testfork] 25 if {$pid == 0} { 26 # we are the forked process 27 set result initialized 28 set h [open [file join $myFolder test.txt] w] 29 fileevent $h writable\ 30 "set result writable;\ 31 after cancel [after 1000 {set result timeout}]" 32 vwait result 33 close $h 34 makeFile $result result.txt $myFolder 35 exit 36 } 37 # we are the original process 38 while {![file readable [file join $myFolder result.txt]]} {} 39 viewFile result.txt $myFolder 40 } \ 41 -result {writable} \ 42 -cleanup { 43 catch { removeFolder $myFolder } 44 } 45 46::tcltest::cleanupTests 47return 48