Version 6 of Stress testing

Updated 2002-04-24 17:41:47

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 vwait}
    #-- add known troublemakers here until the script terminates
    lappend taboo

    #-- make sure all indexed commands are in view
    foreach i [array names ::auto_index] {
        puts "*** $i"
        catch {$i} res
        puts $res         
    }
    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
    }
    puts "successfully passed stress test"
 } 

A standard tclsh passes this test. It gets interesting if you have your own extensions, which may not be as robust as Tcl itself is...


This is an analogue to fuzz ([L1 ], Debian package [L2 ], citations [L3 ]). -- RS grins at how easy it is in Tcl to reinvent wheels (which still fit between thumb and index finger ;-)


Arts and crafts of Tcl-Tk programming