[ Home | What's New | Contents | Overview | Contributors | Distribution | Examples | Documentation | Manual | Publications | Mailing List Archive | Problems ] | This page was last updated by Axel Belinfante on 2006-01-26 | |
TorX Test Tool Information | ||
Prev | Next |
To register a primer means: invoking PRIMER with two text strings, and two tcl commands. To register a guide means: invoking GUIDE with two text strings, and two tcl commands. To register a mutant means: invoking MUTANT with two text strings, and two tcl commands. The entry string will appear in the Primers, Guides respectively Mutants menu; the title string will appear in the Window Title when the primer, guide or mutant is selected (and thus: active). An entry string containing just the single word none is special: it will be the one that is initially selected (active). The setCommand will be invoked by xtorx(1) when the primer, guide or mutant is selected (chosen) by the user, and the unsetCommand when the primer, guide or mutant is deselected by the user. When xtorx(1) invokes setCommand and unsetCommand it extends them with two arguments: flagsVarName and configVarName. Both these arguments can be used to change the command that will be used to invoke torx(1). The flagsVarName argument can be used to insert options (flags) and the configVarName argument can be used to insert configuration files into the command line that will be used to invoke torx(1). How they can be used is shown in the examples, below.
In addition to manipulating the command line arguments of torx(1), the commands that are called by setCommand and unsetCommand can, as needed, change the environment in which torx(1) will be invoked, by creating and/or deleting files, and/or by setting and unsetting environment variables. Usually, the setCommand command will make a change in the environment, such that when torx(1) is invoked, the right mutant is activated, and the unsetCommand command will undo this change in the environment, such that a subsequent invocation of torx(1) will cause the ``default'' implementation to be activated, and such that a subsequent invocation of a setCommand command will activate its corresponding mutant.
The following example registers a single mutant. When the mutant is selected, the environment variable MUTANT is set to 1. Here setCommand and unsetCommand just contain a tcl command.
proc setMut {flagsvar configvar} { global env set env(MUTANT) 1 } proc unsetMut {flagsvar configvar} { global env set env(MUTANT) 0 } MUTANT mut1 mut1 setMut unsetMut
In the example below, setCommand and unsetCommand are more than just proc names: here the setCommand consists of a a string containing a command together with an additional argument. In this case the command mentioned in setCommand must of course handle this additional argument. The following example registers two mutants, mut1 and mut2, for which the environment variable MUTANT is set to 1 respectively 2. When no mutant is selected, environment variable MUTANT will not be set.
proc setMut {nr flagsvar configvar} { global env set env(MUTANT) $nr } proc unsetMut {flagsvar configvar} { global env catch {unset env(MUTANT)} } MUTANT mut1 mut1 "setMut 1" unsetMut MUTANT mut2 mut2 "setMut 2" unsetMut
Finally, we show how tcl commands can be used to register a number of mutants, and how the torxConfigVarName argument can be used to manipulate the torx(1) command line by adding an additional (mutant specific) configuration file.
proc setMut {nr flagsvar configvar} { global env upvar $flagsvar flags upvar $configvar config set env(MUTANT) $nr if {[file exists "myMutant.$nr.config"]} { set config "myMutant.$nr.config" } } proc unsetMut {nr flagsvar configvar} { global env upvar $flagsvar flags upvar $configvar config catch {unset env(MUTANT)} catch { unset config } } foreach m {0 1 2 3 4 5 6 7 8 9} { MUTANT mut$m Mut$m "setMut $m" "unsetMut $m" }
It is important to put catch around puts commands, because puts may fail when the window from which xtorx(1) was started is no longer there.
Currently xtorx(1) contains separate entries to load the primers, guides and mutants; these could be combined.
All primers, guides and mutants files are loaded in the same tcl name space, which means that a file opened later in xtorx(1) may redefine (override) routines defined in a file opened earlier - it is up to the user to avoid problems by choosing unique names.
If there are multiple entries named none in a menu, the last one will be the one that is selected initially.
Prev | Table of Contents | Next |
Appendix D: TorX Manual Pages: torx-primer(5) - interface to program that derives test primitives from | Appendix E: TorX Website Updates |