os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/stack.test
Update contrib.
1 # Tests that the stack size is big enough for the application.
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.
7 # Copyright (c) 1998-2000 Ajuba Solutions.
8 # Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 # RCS: @(#) $Id: stack.test,v 1.15.2.1 2004/05/03 18:01:36 kennykb Exp $
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16 package require tcltest 2
17 namespace import -force ::tcltest::*
20 # Note that a failure in this test results in a crash of the executable.
21 # In order to avoid that, we do a basic check of the current stacksize.
22 # This size can be changed with ulimit (ksh/bash/sh) or limit (csh/tcsh).
24 # This doesn't catch all cases, for example threads of lower stacksize
25 # can still squeak through. A core check is really needed. -- JH
27 if {[string equal $::tcl_platform(platform) "unix"]} {
28 if {[string equal $tcl_platform(osSystemName) "Symbian"]} {
29 # cannot dynamically set stack size in Symbian, and max stack size is 80K in Symbian
32 set stackSize [exec /bin/sh -c "ulimit -s"]
34 if {[string is integer $stackSize] && ($stackSize < 2400)} {
35 puts stderr "WARNING: the default application stacksize of $stackSize\
36 may cause Tcl to\ncrash due to stack overflow before the\
37 recursion limit is reached.\nA minimum stacksize of 2400\
38 kbytes is recommended.\nSkipping infinite recursion test."
39 ::tcltest::testConstraint minStack2400 0
41 ::tcltest::testConstraint minStack2400 1
44 ::tcltest::testConstraint minStack2400 1
47 test stack-1.1 {maxNestingDepth reached on infinite recursion} {minStack2400} {
48 proc recurse {} { return [recurse] }
52 } {too many nested evaluations (infinite loop?)}
54 test stack-2.1 {maxNestingDepth reached on infinite recursion} {minStack2400} {
55 # do this in a slave to not mess with parent
58 $slave eval { interp alias {} unknown {} notaknownproc }
59 set msg [$slave eval { catch {foo} msg ; set msg }]
62 } {too many nested evaluations (infinite loop?)}
64 # Make sure that there is enough stack to run regexp even if we're
65 # close to the recursion limit. [Bug 947070]
67 test stack-3.1 {enough room for regexp near recursion limit} \
68 -constraints { win } \
70 set ::limit [interp recursionlimit {} 10000]
73 if { [info level] < $max } {
74 set ::depth [info level]
80 list [catch { a 10001 }]
84 list [catch { a $::depth } result] \
85 $result [expr { $::depth2 - $::depth }]
87 interp recursionlimit {} $::limit
91 ::tcltest::cleanupTests