diff options
Diffstat (limited to 'tests/cmdIL.test')
-rw-r--r-- | tests/cmdIL.test | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/tests/cmdIL.test b/tests/cmdIL.test index be4d2d6..05b5040 100644 --- a/tests/cmdIL.test +++ b/tests/cmdIL.test @@ -19,7 +19,8 @@ catch [list package require -exact Tcltest [info patchlevel]] # Used for constraining memory leak tests testConstraint memory [llength [info commands memory]] testConstraint testobj [llength [info commands testobj]] -testConstraint prlimit [expr {[testConstraint macOrUnix] && ![catch { exec prlimit -n }]}] +source [file join [file dirname [info script]] internals.tcl] +namespace import -force ::tcltest::internals::* test cmdIL-1.1 {Tcl_LsortObjCmd procedure} -returnCodes error -body { lsort @@ -520,39 +521,21 @@ test cmdIL-5.5 {lsort with list style index and sharing} -body { test cmdIL-5.6 {lsort with multiple list-style index options} { lsort -index {1 2 3} -index 0 {{a b} {c d} {b e}} } {{a b} {b e} {c d}} -test cmdIL-5.7 {lsort memory exhaustion} -constraints {prlimit} -body { - # test it in child process (with limited address space): - set pipe {} - if {[catch { - set pipe [open |[list [interpreter]] r+] - exec prlimit -p [pid $pipe] --as=80000000 - } msg]} { - catch {close $pipe} - tcltest::Skip "prlimit: error - [regsub {^\s*([^\n]*).*$} $msg {\1}]" +test cmdIL-5.7 {lsort memory exhaustion} -constraints {testWithLimit} -body { + # test it in child process (with limited address space) ca. 80MB extra memory + # on x64 system it would be not enough to sort 4M items (the half 2M only), + # warn and skip if no error (enough memory) or error by list creation: + testWithLimit \ + -warn-on-code 0 -warn-on-alloc-error 1 \ + -addmem [expr {$tcl_platform(pointerSize)*4000000 + $tcl_platform(pointerSize)*3*2000000}] \ + { + # create list and get length (avoid too long output in interactive shells): + llength [set l [lrepeat 4000000 ""]] + # test OOM: + llength [lsort $l] } - # if no error (enough memory), or error by list creation - add it as skipped test: - if {![catch { - chan configure $pipe -buffering line - puts $pipe { - # create list and get length (avoid too long output in interactive shells): - llength [set l [lrepeat 4000000 ""]] - # test OOM: - puts [llength [lsort $l]] - exit - } - set result [read $pipe] - close $pipe - set pipe {} - set result - } result] || [regexp {^(?:list creation failed|unable to (?:re)?alloc)} $result]} { - tcltest::Skip "prlimit: wrong AS-limit, result: $result" - } - set result # expecting error no memory by sort -} -cleanup { - if {$pipe ne ""} { catch { close $pipe } } - unset -nocomplain pipe line result -} -result {no enough memory to proccess sort of 4000000 items} +} -returnCodes 1 -result {no enough memory to proccess sort of 4000000 items} # Compiled version test cmdIL-6.1 {lassign command syntax} -returnCodes error -body { |