![]() |
![]() |
![]() |
![]() |
![]() |
Getting Started
Unfortunately a test sequence description expressed in TTCN can not easily be executed as it is. This is 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 210 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 chapter 36, Adaptation of Generated Code. Figure 211 displays the anatomy of the final result.
Running the TTCN to C Compiler
The TTCN to C compiler can be activated either from the TTCN Browser, both as a quick button and a menu command, or from the Organizer when a TTCN test suite is selected.
Tools > Make
When you select Make, the TTCN Suite Make dialog is opened. The dialog contains two important toggle buttons, Analyze & Generate and Compile & Link.
Analyze & Generate
If Analyze & Generate is set, the Analyzer will first be called to analyze the test suite before any code is generated. If errors are found, these will be reported and no code will be written to file. The generation phase performed after the analysis phase will only generate code for the parts that need to be re-generated.
Directory for generated files
If code is generated, that code will reside in the directory specified in this field.
Makefile
If Compile & Link is set, the TTCN Suite will also take care of the making and linking of the generated code. At this point you have the possibility to specify how you want the code to be built. Either you can specify that the default generated makefile is to be used, or your own special makefile. This is done by setting the radio buttons in the field below the Makefile toggle button.
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.
Compile & Link
The compiler needs to know what files to link into the executable. Three different possibilities are at hand:
- You have not yet written an adaptor, but you want an empty template to allow compilation to go through successfully.
- You have already written an adaptor which you want to link into the executable.
- You want to link to a simulator kernel to allow you to simulate.
The TTCN to C compiler assumes the first case to be the default one. In this case the Generate empty adaptor files radio button is set. If you do not have adaptor files (adaptor.c and adaptor.h) in the target directory, these will be created, as empty templates, for you. If you already have generated and edited adaptor files these will of course not be overwritten.
If you already have your own compiled adaptor files elsewhere in the file system, these files, as object files, should be listed in the text field below the Use the object files dialog button. Observe that you should use absolute path names for the adaptor files to avoid problems for the makefile to find these files! An absolute path name is a path name that identifies a file uniquely from the root of the files system, for example /home/myhome/myadaptor.o.
Finally, if you want to generate code for simulation, the Use standard kernel radio button should be set with the option Simulation. This is the only available kernel at the moment so no other choice is valid here.
Make
If the Make button is pressed, the compiler will only generate code for the parts that really need to be re-generated.
Full Make
If the Full Make button is pressed, everything will be regenerated again.
When the generation phase is started, a new log window will be displayed where information about the compiler actions will be displayed.
TTCN to C Compiler Options
By pressing the TTCN to C Compiler Options button in the Make dialog, the dialog depicted in Figure 213 will be displayed.
- If the Generate debug information in code button is set, the compiler will generate extra code for tracing and debugging.
- If the Generate a local make options file button is set, the compiler will generate a file called makeopts in the target directory. This file is used to define settings used by the makefile. You have the flexibility to choose compiler and add extra information for the make process.
- If the Ignore bodies of test suite operations button is set, 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 button is not set, the test suite operators will be generated and included in the file tsop_gen.c.
- If the Allow old style encoders/decoders button is set, the compiler will generate two extra files that will allow you to use an adaptor written for the old code generator to be used with the new one.
- If the Generate, but do not write to file button is on, the compiler will not generate code. This is useful for users that only wish to generate code when they know no generation errors will occur.
- If the Do not report warnings button is set, the compiler will not inform you about warnings.
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.
Encoders
- By selecting one of the radio buttons None, Generate BER encoders/decoders or Generate PER encoders/decoders the compiler will either omit generation of encoders/decoders or generate extra code for BER or PER encoding and decoding support. See chapter 58, ASN.1 Encoding and De-coding in the SDL Suite, in the User´s Manual.
Encoders
- By selecting one of the radio buttons Suppress messages, Normal Messages or Verbose messages you can set the level of verbosity when the compiler generates code. The default value is Normal messages.
Files
You can also choose the names of the files you want to use. This is done in the fields in the lower part of the TTCN to C compiler options dialog.
- The optional Static file directory field should only be used by users that brutally want to change the behavior of the compiler by using their own static files. For "normal" users it is recommended that this field is not set.
- The Types file field determines the name of the file to which type definitions from your test suite are generated. The default value is types_gen.c.
- The Constraints file field determines the name of the file to which constraint definitions from your test suite are generated. The default value is constraints_gen.c.
- The Dynamic part file field determines the name of the file to which the dynamic part from your test suite is generated. The default value is dynamic_gen.c.
- The Log file field determines the name of the file to which messages about the generation are to be written. Default is standard out.
Running the TTCN to C Compiler from the Command Line
Please see "Running the TTCN to C Compiler from the Command Line" on page 1328 in chapter 32, The TTCN to C Compiler (in Windows).
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |