| 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 (c) 1991-1993 The Regents of the University of California. |
| 8 |
# Copyright (c) 1994-1997 Sun Microsystems, Inc. |
| 9 |
# Copyright (c) 1998-1999 by 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 |
|
| 14 |
if {"::tcltest" ni [namespace children]} { |
| 15 |
package require tcltest 2.5 |
| 16 |
namespace import -force ::tcltest::* |
| 17 |
} |
| 18 |
|
| 19 |
foreach {fin_on_exit testname} {0 {normal, quick exit} 1 {full-finalized exit}} { |
| 20 |
test exit-1.[expr {$fin_on_exit+1}] $testname -setup { |
| 21 |
set tout [expr {1000 + [::tcl::pkgconfig get mem_debug] * 5000}] |
| 22 |
set tout [after $tout [list set done "Exit hangs (timeout) !!!"]] |
| 23 |
set f {} |
| 24 |
} -body { |
| 25 |
set f [open [list | [interpreter] << "set ::env(TCL_FINALIZE_ON_EXIT) $fin_on_exit; exit"] r] |
| 26 |
fileevent $f readable [namespace code {after cancel $tout; set done OK}] |
| 27 |
vwait done |
| 28 |
if {$done eq "OK"} { |
| 29 |
if {[catch {close $f} err]} { |
| 30 |
set done "Exit misbehaves: $err" |
| 31 |
} |
| 32 |
} |
| 33 |
set done |
| 34 |
} -cleanup { |
| 35 |
after cancel $tout |
| 36 |
if {$f ne {}} { catch { close $f } } |
| 37 |
unset -nocomplain fin_on_exit testname done f |
| 38 |
} -result OK |
| 39 |
} |
| 40 |
|
| 41 |
# cleanup |
| 42 |
::tcltest::cleanupTests |
| 43 |
return |