Version 0 of Stress testing

Updated 2002-04-24 16:22:19

Richard Suchenwirth - Robust software should withstand all kinds of mistreatment (calling with improper arguments) without ending up in core dump, segmentation or "general protection" faults. One way to test this property is made easy by Tcl's info commands that lists everything you could call - except for procedures from not yet sourced files, but these are a subset of [array names ::auto_index].

The following proc executes a stress test by calling (almost) all commands with varying nonsense arguments. Errors are expected (and caught), but execution of this proc should not result in a crash. If such dangerous commands are found, edit them into the taboo' list, which initially contains only exit and stresstest'' itself.

 proc stresstest {} {
    set taboo {exit stresstest}
    #-- add known troublemakers here until the script terminates
    lappend taboo

    foreach i [lsort [info commands]] {
        if {[lsearch $taboo $i]>=0} continue
        puts "*** $i"
        catch {$i} res
        puts $res
        puts "*** $i foo"
        catch {$i foo} res
        puts $res
        puts "*** $i foo bar"
        catch {$i foo bar} res
        puts $res
    }
 } 

Arts and crafts of Tcl-Tk programming