1# Commands covered: exit, emphasis on finalization hangs 2# 3# This file contains a collection of tests for one or more of the Tcl 4# built-in commands. Sourcing this file into Tcl runs the tests and 5# generates output for errors. No output means no errors were found. 6# 7# Copyright © 1991-1993 The Regents of the University of California. 8# Copyright © 1994-1997 Sun Microsystems, Inc. 9# Copyright © 1998-1999 Scriptics Corporation. 10# 11# See the file "license.terms" for information on usage and redistribution 12# of this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 14if {"::tcltest" ni [namespace children]} { 15 package require tcltest 2.5 16 namespace import -force ::tcltest::* 17} 18 19test exit-1.1 {normal, quick exit} { 20 set f [open "|[interpreter] << \"exec [interpreter] << {set ::env(TCL_FINALIZE_ON_EXIT) 0;exit}\"" r] 21 set aft [after 1000 {set done "Quick exit hangs !!!"}] 22 fileevent $f readable {after cancel $aft;set done OK} 23 vwait done 24 if {$done != "OK"} { 25 fconfigure $f -blocking 0 26 close $f 27 } else { 28 if {[catch {close $f} err]} { 29 set done "Quick exit misbehaves: $err" 30 } 31 } 32 set done 33} OK 34 35test exit-1.2 {full-finalized exit} { 36 set f [open "|[interpreter] << \"exec [interpreter] << {set ::env(TCL_FINALIZE_ON_EXIT) 1;exit}\"" r] 37 set aft [after 1000 {set done "Full-finalized exit hangs !!!"}] 38 fileevent $f readable {after cancel $aft;set done OK} 39 vwait done 40 if {$done != "OK"} { 41 fconfigure $f -blocking 0 42 close $f 43 } else { 44 if {[catch {close $f} err]} { 45 set done "Full-finalized exit misbehaves: $err" 46 } 47 } 48 set done 49} OK 50 51 52# cleanup 53::tcltest::cleanupTests 54return 55