To convert a test from the Avalanche Commander GUI into a Tcl script, we can use the Avalanche Tcl Test Generator. This tool creates both a Tcl test configuration file (config.tcl) and a runtime executable file (test.tcl). These two files constitute one single test, and the test.tcl file is the entry point or controller of the test. Once we convert a test to a Tcl script, we can further edit the script, and import it back into the Commander GUI.
Select the test that needs to be converted to TCL.
Select File > Generate Tcl Test, or right-click the selected test, and then click Generate Tcl Test. The Tcl Test Generator window appears.
Select either Compact or Detailed scripts.
Compact: All the test configuration information is self-contained within the project file (.spf). The conversion process simply exports the GUI test configuration to generate the .spf file, with no configuration command calls (av::config) in the generated Tcl test configuration file (config.tcl). We can run the test in the usual manner using the runtime executable file (test.tcl), but we cannot change configuration settings, since the compact script is encapsulated/hidden within the .spf file.
Detailed: All the relevant test configuration information is included in the config.tcl file, using a configuration command call (av::config) for each and every test configuration entry. Thus, we can edit detailed scripts and change configuration settings for more granular control.
In the Spirent Tcl API Dir field, if the default installation directory is the location of the Tcl scripting API, leave this field as is. Otherwise, click the Browse button to locate and select the directory in which the Tcl scripting API is installed.
In the Tcl Test Output Dir field, if the default output directory is where we want to store the resulting Tcl test files, leave this field as is. Otherwise, click the Browse button to locate and select the directory in which we want to store the Tcl test files.
Select Portable Test if we want to generate a portable Tcl test. For example, we can generate a test in Windows, and then execute it on another operating system or computer. We must also set certain system environment variables on every computer on which we intend to run the test. See the Avalanche Automation Programmers' Reference for more information.
Select Include Defaults to include all configuration entries in the Tcl test configuration file. If we do not select this checkbox, the configuration entries that are set to their default values are omitted from the file.
Click the Generate Tcl Test button to start the conversion process. Informational messages and errors appear in the console (text area below the buttons). When the conversion process is complete, the directory and filename of the converted Tcl test configuration file and runtime executable file appear. The directory and filenames indicate the name of the converted test. Any errors appear in red text.
To save console messages, click Save Console button to locate a directory and specify a filename.
To remove all messages from the console, click Clear Console button.
Click Close button to close the Tcl Test Generator window.
NOTE: Only advanced tests can be converted to a Tcl script. To can convert a quick or EZ test into TCL, we need to first convert it to an advanced test.