Home

33 The TTCN to C Compiler (in Windows)

image

Contents

1. be Generate code for Borland compiler 1292 Telelogic Tau 4 5 User s Manual July 2003 Getting Started Switch Explanation u ve Generate code for Microsoft Visual compiler v Verbose w No warning mode z lt lines gt Aim at splitting generated file at lt lines gt number of 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 Example 206 You want to generate C code for the modular test suite mts itex which depends on modulel itex module2 itex module3 itex and module4 itex To do this enter tten2c mts itex modulel itex module2 itex module3 itex nunn module4 itex wu 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 TTCN Suite Getting Started July 2003 Telelogic Tau 4 5 User s Manual 1293 Chapter 33 The TTCN to C Compiler in Windows What Is Generated 1294 Figure 230 shows how ANSI C code is generated from a TTCN test suite The generated code alone is not executable as it needs the test sup
2. com mand line switches The usage is ttcn2c switches filename Example 205 To generate C code for example itex in the current directory with hard values and in silent mode use the command ttcn2c ms example itex July 2003 Telelogic Tau 4 5 User s Manual 1291 Chapter 33 The TTCN to C Compiler in Windows C Code Generator Parameters Switch Explanation a lt objs gt Link with objs as adaptor A lt ASN1files gt File containing filenames of ASN 1 module files b lt dir gt Search in lt dir gt for static files B Generate BER encoding decoding interface d Debug information in C code D Step through ETS execution e lt file gt Use file to be included in the make file f Forced mode always overwrite files g Ignore bodies of test suite operations See also Options on page 1289 h Help j lt file gt User file name for types k lt file gt Use file name for constraints l lt file gt Specify log file M file Enable MSC PR file tracing M msce Enable MSC Editor tracing o lt dir gt Specify output directory p lt file gt Use file name for behavior ee Generate PER encoding decoding interface r lt file gt Use file name to generate a makefile R Disable makefile generation s Silent mode do not display messages t Generate simulator See also Kernel on page 1290 s Generate targe stand alone kernel u
3. Chapter 33 The TTCN to C Compiler in Windows This chapter describes what the TTCN to C compiler is used for how to run it and the structure of the generated code When the TTCN to C compiler has translated TTCN into C code the code must be adapted with the system that is to be tested The adaption process is described in chapter 37 Adaptation of Generat ed Code Note ASN 1 support The TTCN to C compiler supports only a limited subset of ASN 1 See Support for External ASN 1 in the TTCN Suite on page 729 in chapter 14 The ASN 1 Utilities in the User s Manual for further details on the restrictions that apply Note Windows version This is the Windows version of the chapter The UNIX version is chapter 28 The TTCN to C Compiler on UNIX July 2003 Telelogic Tau 4 5 User s Manual 1285 Chapter 33 The TTCN to C Compiler in Windows Introduction to the TTCN to C Compiler When developing new systems or implementations of any kind the de veloping process is divided into well defined phases Most commonly the first phases involve some kind of specification and abstract design of the new system After a while the implementation phase is entered and finally when all parts are joined together the test phase is activated In any case when a system is tested we want to make sure that its be havior conforms to a set of well defined rules TTCN was developed for the specification of test sequences Unfortun
4. July 2003 Telelogic Tau 4 5 User s Manual 1289 Chapter 33 The TTCN to C Compiler in Windows 1290 Kernel To build a TTCN Exerciser select the option Target Stand alone simulator For more information about the TTCN Exerciser see chapter 35 The TTCN Exerciser Select Co 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 work ing directory By default the MSC file names will be on the form log_ lt TestCaseId gt _ lt SequenceNo gt mpr where lt TestCaselId gt is substituted by the test case name of the logged test case lt Se quenceNo gt 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 acti vate 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 MscSet Prefix 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
5. ately as very few systems interpret or compile pure TTCN we need to translate the TTCN nota tion into a language which can be compiled and executed In the case of the TTCN suite the TTCN to C compiler translates TTCN to ANSI C Even after the TTCN code has been translated there are a couple of things that need to be taken care of In this case we must adapt the gen erated code with the system it intends to test This chapter describes how the TTCN to C compiler is used The adaption process is described in Adaptation of Generated Code on page 1449 in chapter 37 Adap tation of Generated Code Getting Started 1286 Unfortunately a test sequence description expressed in TTCN cannot easily be executed as it is This because the test notation is not execut able and only few test environments interpret pure TTCN A different approach to create an executable test suite ETS is to translate the for mal test description into a language which can be compiled into an ex ecutable format The TTCN to C compiler translates TTCN into ANSI C which can be compiled by an ANSI C compiler Figure 230 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 equip ment et
6. c 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 Telelogic Tau 4 5 User s Manual July 2003 Getting Started TTCN to C compiler TTCN Runtime Behavior ANSI C Figure 230 Translating TTCN to ANSI C The adaption process is described in Adaptation of Generated Code on page 1449 in chapter 37 Adaptation of Generated Code Figure 231 displays the anatomy of the final result TTCN runtime behavior Test support functions Implementation Under Test Figure 231 The anatomy of an ETS July 2003 Telelogic Tau 4 5 User s Manual 1287 Chapter 33 The TTCN to C Compiler in Windows 1288 Running the TTCN to C Compiler To generate C code for the currently selected test document e Select Generate Code from the Build menu The shortcutis lt F8 gt This will open a dialog where you may change settings for code generation see Figure 232 You can also open this dialog by the menu choice Build gt Options or by the shortcut lt Alt F8 gt Note Observe that the TTCN to C compiler is unable to function correctly if the test suite is not fully verified correct This verification is ac complished by running the Analyzer tool on all the parts of the test suite Note that every active TTCN document has its own code generation set tings so in practice two or more TTCN documents can be edit
7. ed and or viewed at the same time in the TTCN suite and yet have individual set Telelogic Tau 4 5 User s Manual July 2003 Getting Started tings Multiple views on the same TTCN document does of course share the same settings TTCN Analyzer TTCN to C Compiler Settings x TTCN Analyzer Options TTCN to C Compiler Options Build Options m Options IV Ignore bodies of test suite operations r Encoders Decoders None X Kernel C Target Stand alone simulator C Co simulator User defined adaptor MSC Trace I Enable MSC PR file tracing I Enable MSC Editor tracing m Output Directory C Atten code Browse Figure 232 Options dialog for code generation Options e Ifthe 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 opera tions 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 includ ed in the file tsop_gen c Encoders Decoders e By selecting one of the alternatives None Generate BER encod ers 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 sup port see chapter 37 Adaptation of Generated Code
8. execut ed This mode assumes that an MSC Editor license is available and that Telelogic Tau 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 ac tivation of the appropriate calls Telelogic Tau 4 5 User s Manual July 2003 Getting Started 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 Telelogic Tau Public In terface libraries and include files that can be found in the installation of Telelogic Tau For more information see TTCN Test Logs in MSC Format on page 1295 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 gen eration will be displayed in the Log Manager You will receive informa tion 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 Running the TTCN to C Compiler from the Command Line You can start the TTCN to C compiler by executing ttcn2c with
9. he final phase to create an executable test suite The adaptation process is described in Adaptation of Generated Code on page 1449 in chapter 37 Adaptation of Generated Code Telelogic Tau 4 5 User s Manual July 2003 TTCN Test Logs in MSC Format TTCN Test Logs in MSC Format July 2003 The TTCN standard conformance log though it is a relatively complete logging format has a few drawbacks for some purposes e The conformance log is very detailed e The conformance log requires knowledge of TTCN and its seman tics e The conformance log is not always particularly easy to read In order to get a more high level view the log must either be filtered or another approach needs to be taken in this case the MSC log format The current version of the TTCN suite has support for an additional log ging mode to generate MSC PR standard conformant logs automati cally saved in files and also directly to the MSC Editor For limitations in the MSC logging see MSC Logging on page 57 in chapter 2 Release Notes in the Release Guide MSC Logging Applications There are several applications of MSC logging Here are some e Test reviews The MSC log format is very readable and can be used for reviewing test progress and for evaluating test results with requirements spec ifications e Test result recreation If an SDL model has been used to specify the system behavior a composed MSC log can be used t
10. o re create the test result by using the SDL Validator s Verify MSC feature This will allow a particu lar test behavior to be handed to system designers who can recreate the result on a workstation level e Test re engineering If MSC traces are being used to generate test cases the tests can be modified at the MSC level A modified MSC can be used to gener ate a new tests For instance a test written in TTCN generates an MSC At a review of the MSC logs a new scenario may be identi Telelogic Tau 4 5 User s Manual 1295 Chapter 33 The TTCN to C Compiler in Windows fied The MSC can be changed to reflect the new scenario and the MSC can be translated back to TTCN MSC Logging Modes There are three major modes of logging which can be toggled between the test cases It is not possible to change the logging mode in a running test case since that would cause an inconsistency in the MSC file The modes are e None No MSC logs are generated at all This mode improves performance somewhat compared to the other modes For best performance the MSC generation code can be entirely disabled For more informa tion see Compiling an ETS with MSC Generation on page 1297 e Composed MSC generation of externally visible events of the ETS This is suit able for test regeneration and for re viewing test results The perfor mance is better than Decomposed mode The generated MSC views the ETS as a set of PCOs that interac
11. ow for any of these combinations at code generation time For more information see MSC Generation Modifications on page 1298 Definitions that may be changed to customize the MSC generation Definitions Explanation MSC_DEFAULT_SYSTEM_NAME Name of IUT instance in composed mode Telelogic Tau 4 5 User s Manual 1297 Chapter 33 The TTCN to C Compiler in Windows 1298 Definitions Explanation MSC_MAX_VALUE_LEN Maximum length of an en coded message value MSC_NO_VALUE_LOGGING If defined no message val ues are displayed this may make the ETS more efficient and the MSC logs more read able when using complex messages MSC Generation Modifications Modifications to the MSC generation for running on an embedded en vironment include e The MscAppendPREvent function can be modified to transfer the PR events via any type of uni directional communications device It is recommended to create another definition similar to the MSC_MSCE_MODE or MSC_FILE_ MODE and complement the mscgen c file with these e Any place where MSC_FILE_MODE or MSC_MSCE_MODE is used should be having a new definition for the new logging mode Telelogic Tau 4 5 User s Manual July 2003
12. port functions module see Figure 231 In the case of the code generated from the compiler we also need a set of static functions which handle TTCN basics and other internal events Even if these functions are vital for the successful compilation and ex ecution of the generated code the user should not have to worry about this part These functions are gathered in a small set of static files which are compiled by the generated makefile and linked with the rest of the code The Code Files The generated makefile is the file containing a definition of how the code should be compiled and linked This will not be needed if you are compiling the generated code in a separate development environment The adaptor h and adaptor c files are the files that contain the ad aptation code If code is generated for the first time these files will be generated by the compiler with empty function templates for the user to implement On the other hand if these files are present in the target di rectory the user does not have to worry about getting them overwritten The _gen c h files contains the generated code from the TTCN test suite The asniende h file contains the encode and decode functions for the ASN 1 Types See chapter 59 ASN 1 Encoding and De coding in the SDL Suite in the User s Manual Only if ASN 1 support has been selected The Adaptation We are now ready to deal in greater detail with the adaptation phase which is t
13. t with a IUT The ETS is not visible as one particular instance Some relative timing information may be lost in this mode e Decomposed MSC generation of externally visible and internal events of the ETS This is the most detailed mode and it produces MSC events for almost all actions of the ETS The purpose of the MSCs that are gen erated is to visualize the internal events and configuration of the ETS and for test case debugging purposes MSC Instances Generated Entity Composed Decomposed Comment SUT Yes No PCO Yes Yes MTC No Yes PTC No Yes Dynamic 1296 Telelogic Tau 4 5 User s Manual July 2003 July 2003 TTCN Test Logs in MSC Format Events Logged Event Composed Decomposed Comment Final Verdict Yes Yes MSC Text Preliminary Verdict No Yes MSC Condi tion Create No Yes Done No Yes Send to PCO Yes Yes Send to CP No Yes Receive from PCO Yes Yes Receive from CP No Yes Implicit send No Yes Start Timer No Yes Cancel Timer No Yes Timeout Timer No Yes Implicit Cancel No Yes End of TC Implicit Receive No Yes End of TC Message Values Yes Yes Compiling an ETS with MSC Generation The ETS Generator can be compiled for a workstation or an embedded environment Some modifications need to be done for applying it in the embedded environment if it lacks a file system By default the tool will all

Download Pdf Manuals

image

Related Search

Related Contents

MIDI  Minka Lavery 4350-593 Instructions / Assembly    All right reserved  Istruzioni per l`uso  Z 06456 DE Gebrauchsanleitung EN Instruction manual FR Mode d  JVC UX-QD90B User's Manual  LEDP88020  Ion Selective Electrode (ISE) Operation Instructions  取扱説明書  

Copyright © All rights reserved.
Failed to retrieve file