![]() |
![]() |
![]() |
![]() |
![]() |
Getting Started
Unfortunately, a test sequence description expressed in TTCN cannot easily be executed as it is. This, because the test notation is not executable and only few test environments interpret pure TTCN. A different approach to create an executable test suite (ETS), is to translate the formal test description into a language which can be compiled into an executable format.
The TTCN to C compiler translates TTCN into ANSI-C which can be compiled by an ANSI-C compiler. Figure 231 depicts the first step in the process of creating an ETS using the TTCN to C compiler.
The generated code, called the TTCN runtime behavior, is only one of the two major modules of an ETS.
The second module which is needed includes test support functions which are dependent on the protocol used, the host machine, test equipment, etc. For this reason, it is up to the user to write this second module and in such way adapt the TTCN runtime behavior to the system he/she wants to test.
The adaption process is described in "Adaptation of Generated Code" on page 1491 in chapter 36, Adaptation of Generated Code. Figure 232 displays the anatomy of the final result.
Running the TTCN to C Compiler
To generate C code for the currently selected test document:
- Select Generate Code from the Build menu.
- The shortcut is <F8>.
- This will open a dialog where you may change settings for code generation (see Figure 233).
- You can also open this dialog by the menu choice Build > Options or by the shortcut <Alt+F8>.
Note that every active TTCN document has its own code generation settings, so in practice, two or more TTCN documents can be edited and/or viewed at the same time in the TTCN Suite, and yet have individual settings. (Multiple views on the same TTCN document does of course share the same settings.)
The TTCN to C compiler runs in background. The Progress Bar at the bottom of the TTCN Suite window shows the TTCN to C compiler completion. During the code generation it is possible browse the already opened TTCN documents. It is not allowed to edit, save, close or open any of the TTCN documents during analysis. The analysis may be canceled by pressing the break
button on the toolbar or by the menu choice Build > Break.
Options
- If the Ignore bodies of test suite operations option is checked, the compiler will ignore to generate code for test suite operations. This is useful if you already have a file with your own test suite operations that only need to be linked to the rest of the code. If the option is not checked, the test suite operators will be generated and included in the file tsop_gen.c.
Encoders/Decoders
- By selecting one of the alternatives None, Generate BER encoders/decoders or Generate PER encoders/decoders in the drop down list the compiler will either omit generation of encoders/decoders or generate extra code for BER or PER encoding and decoding support, see chapter 36, Adaptation of Generated Code.
Kernel
- To build a TTCN Exerciser, select the option Target/Stand-alone simulator. For more information about the TTCN Exerciser, see chapter 34, The TTCN Exerciser.
- Select Integrated-simulator if you want to execute a test suite together with a simulated SDL system.
- To build a user-defined adaptor, select User-defined adaptor.
MSC Trace
- Enable MSC/PR file tracing
- Generates MSC/PR format files that are saved in the current working directory. By default, the MSC file names will be on the form log_<TestCaseId>_<SequenceNo>.mpr, where <TestCaseId> is substituted by the test case name of the logged test case. <SequenceNo> is an integer that is started by 0000 and increased by one if there is already a version n in the working directory.
- The preprocessor constant MSC_FILE_MODE should be defined at compile-time of mscgen.c to get this mode. The constant GENMSC should be defined for compiling globalvar.c to activate appropriate calls.
- If the file cannot be created, a new attempt will be done at the start of the next test case. No file log will be created.
- The function MscSetPrefix can be used to change the path and prefix of generated files at runtime.
- Enable MSC Editor tracing
- Creates a new diagram in the MSC Editor when a new test case is started and then appends and displays the events as they are executed. This mode assumes that an MSC Editor license is available and that TTCN Suite is running at the host where the ETS is running and provides run-time MSC logging.
- The preprocessor constant MSC_MSCE_MODE should be defined at compile-time of genmsc.c to get this mode. The constant GENMSC should be defined for compiling globalvar.c for activation of the appropriate calls.
- If the creation of events in the MSC Editor fails, it will be retried at the next event, possibly creating an inconsistent MSC.
- This mode may also require access to the Public Interface libraries and include files that can be found in the installation.
For more information, see "TTCN Test Logs in MSC Format" on page 1333.
Output Directory
The final thing you have to do is to set the output directory.
OK
When you have set the options, click OK to start the generation of code. When the generation phase is started, information about the code generation will be displayed in the Log Manager. You will receive information about what parts that were generated and also some statistics about the amount of tables traversed during the generation phase.
If code is being generated for a large test suite, the status bar will show the progress.
Save
If you would like to store the option settings for future usage, press the Save button. The options settings is then saved in a file with the same name as the current test suite's filename (with extension) and with an additional '.ini' extension. For example will the options for 'foo.itex' be saved in a file named 'foo.itex.ini', for a test suite named 'foo.mp' the options will be in the file 'foo.mp.ini'. The options file is placed in the same folder as the test suite file.
The options file is automatically searched and the options settings are loaded when a TTCN Suite browser window is opened (on Windows), or when the TTCN Suite Make dialog is opened (on UNIX).
Build Options
Makefile Type
Choose one of the known make types, corresponding to your compiler, for the generated makefile.
Custom adaptor objects
This text field allows you to specify additional object files to be linked to ETS.
Make command
The Run Make check box controls if the make command is to be invoked directly after the code generation (provided it has completed successfully). The text field allows a manual change of the invoked make command if this is desired.
Log Options
There are two options in the Build Options tab for log management. These options are also related to a compilation flag, SHOWSIGNALPARAMETERS, which is generated in the makefile.
Verbose Log
The Verbose Log switches the logging between the default mode, which prints the result of the Make process as it goes along, and the Verbose mode, where all possible information is presented. The Verbose log is primarily intended for debugging.
The Verbose log contains the following information in addition to the default log:
- signal parameters, with an attempt to restore all names (for signal, fields, parameters, choices, etc.), even when these names are lost (which is the case when the user construct the signals directly in the adaptor). The default log can be made to show this if the Compilation flag /DSHOWSIGNALPARAMETERS is set.
- matching processes are presented Verbose. Each field shows how it was matched, using the indentation level for nested fields.
Show Executable Path
When Show Executable Path is selected, the lines in the ETS log will be prefixed by the path for the executing Test Case and Test Steps, like the following example:
Test Case:[line number] Step_no:[line number] ... Test Step_nCompilation flag /DSHOWSIGNALPARAMETERS
The flag SHOWSIGNALPARAMETERS is generated in the Makefile even when the log is not Verbose. With this compilation flag the default log will also contain the complete contents of all signals, just like when log is set to Verbose. When this is not desired, this flag can easily be removed from the Makefile.
Additional Compiler Options and Additional Linker Options
Here it is possible to specify any compiler and linker options that will be added into the generated Makefile.
Running the TTCN to C Compiler from the Command Line
You can start the TTCN to C compiler by executing ttcn2c with command line switches. The usage is ttcn2c [switches] filename.
To generate C code for example.itex in the current directory, with hard values and in silent mode, use the command:
ttcn2c -ms example.itexC Code Generator Parameters
-a <objs> -A <ASN1files> -b <dir> -B -C <options> -d -D -e <file> -f -FDefinitions of encountered ASN.1 references should be retrieved. See "Retrieve ASN.1 Definitions" on page 1197 in chapter 26, Analyzing TTCN Documents (on UNIX)
-gIgnore bodies of test suite operations
See also "Options" on page 1323.
-h -i <defined flag> -I <flags file> -j <file> -k <file> -l <file> -L <options> -M file -M msce -o <dir> -p <file> -P -r <file> -R -s -tSee also "Kernel" on page 1324.
-T -u vc -w -z <lines>Generating C Code for Modular Test Suites
Generating C code for modular test suites from the command line, may be a bit tricky. Please see the example below for an explanation of how to proceed.
You want to generate C code for the modular test suite mts.itex, which depends on module1.itex, module2.itex, module3.itex and module4.itex. To do this enter:
ttcn2c """mts.itex""""""module1.itex""""""module2.itex""""""module3.itex" """""module4.itex"""Note that there are six quotation marks between the file names.
This will generate code for the entire modular test suite.
It is also possible to use MP documents in the same manner.
For a description of file naming, see "Files in the TTCN Suite" on page 24 in chapter 2, Introduction to the TTCN Suite (in Windows), in the Getting Started.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |