C Test Script Compiler - attolpreproC

Purpose

The C Test Script Compiler tool pre-processes a .ptu test script and converts it into a native source code test harness.

Syntax

attolpreproC <test_script> <generated_file> [ <target_directory> ] {[ <-options> ]}

attolpreproC @<option_file>

where:

  1. <test_script> is a required parameter that specifies the name of the test program to be generated.

    <generated_file> is a required parameter that specifies the name of the test harness that is generated from the test script.

    <target_directory> is an optional parameter. It specifies the location where Component Testing for C will generate the trace file. By default, the trace file is generated in the workspace directory.

    <options> is a set of optional command line parameters as specified in the following section.

    <option_file> is the name of a plain-text file containing a list of options.

Description

Options can be in any order. They may be upper or lowercase and can be abbreviated to their shortest unambiguous number of characters.

Source File Under Test

-source= <source file>

This option specifies the name of the source file being tested, allowing the Test Script Compiler to:

  • Maintain the source file name in the table of correspondence files so that the Test Report Generator can display this name in the header of the results obtained file.

  • Establish the list of include files in the tested source file.

The name of the tested source file may be specified with a relative or absolute directory in a syntax recognized by the operating system, or, in UNIX, by an environment variable.

By default, the list of include files in the tested source file and the source file name are not displayed in the Results Obtained file.

Condition Definition

-define= <ident>[= <value>] {[, <ident>[= <value>]}

This option specifies conditions to be applied when the Test Script Compiler starts. These conditions allow you to define C symbols that apply conditions to the generation of any IF ... ELSE ... END IF blocks in the test script.

If the option is used with one of the conditions specified in the IF instruction, the IF ... ELSE block (if ELSE is present) or the ELSE ... END IF block (if ELSE is not present) is analyzed and generated. The ELSE ... END IF block is eliminated.

If the option is not used or if none of the conditions specified in the IF instruction are satisfied, the ELSE ... END IF block is analyzed and generated.

All symbols defined by this option are equivalent to the following line in C

-define <ident> [<value>]

By default, the ELSE ... END IF blocks are analyzed and generated.

Specifying Tests, Families, and Services

-test= <test>{[, <test>]} | -extest= <test>{[, <test>]}

This option specifies a list of tests to be executed.

Use -test to only generate the source code related to the specified tests, and -extest to specify the tests for which you do not want to generate source code.

Both -test and -extest cannot be used together.

By default, all tests are selected.

-family=<family>{, <family>} | -exfamily=<family>{, <family>}

Use -family to only generate the source code related to the specified families, and -exfamily to specify the families for which you do not want to generate source code.

Both -family and -exfamily cannot be used together.

By default, all families are selected.

-service=<service>{[, <service>]} | -exservice= <service>{[, <service>]}

Use -service to only generate the source code related to the specified services, and -exservice family to specify the services for which you do not want to generate source code.

Both -service and -exservice cannot be used together.

By default, all services are selected.

-STD_DEFINE= <TDP definition file>

This option allows you to specify a TDP definition file that enables compatibility with the compiler. Typically, this is <targetPath>/ana/atus_c.def

-RENAME= <stub rename file>

Use this option to stub methods that are located within the source code. <stub rename file> specifies the name of a generated file that contains the stub renaming options for the C/C++ Instrumentor. You can pass this filename as a parameter for the C/C++ Instrumentor (attolccp or attolcc4/attolcc1) with the syntax attolccp (or attolcc4)@ <stub rename file> .

Test Script Parsing

-fast | -nofast

The -fast option tells the C Test Script Compiler to analyze only those tests that you want to generate. This setting considerably speeds up the Test Script Compiler when you use the -service,-exservice,-family, -exfamily,-test, or -extest options.

The -fast option is selected by default.

If you want a full test script analysis, this option can be de-selected using the -nofast option.

-noanalyse

This option disables the native language parser.

By default, native language lines are analyzed. This option enables you to disable this parsing.

-noedit

This option limits unit test code generation to the initialization of variables, making it possible to generate tighter code for special purposes such as debugging. If you specify the -noedit option, you cannot generate a test report.

By default, code is generated normally.

-nopath

Use this option if you do not want to generate long pathnames on the open and close execution trace file call, and on the Target Deployment Port header file include directive. This can be useful, for example, to preserve memory on embedded targets.

By default, full pathnames are generated.

-nosimulation

This option determines the conditional generation related to simulation in the source file generated by the Test Script Compiler. Blocks delimited by the keywords SIMUL ... ELSE_SIMUL ... END SIMUL can be included in the test scripts.

See SIMUL blocks in the C Test Script Language Reference.

-restriction=ANSI | KR | NOEXCEPTION | NOIMAGE | NOPOS | SEPAR

This option lets you modify the behavior of test script parser.

  1. ANSI enables C native code to be analyzed according to the ANSI standard (C only).

    KR enables C native code to be analyzed according to the KERNIGHAN & RITCHIE version 2 standard (C only).

  1. noexception: tells the Test Script Compiler to skip EXCEPTION blocks when generating a test harness. This allows the use of compilers that do not implement exception handling. By default, EXCEPTION blocks are generated in the test program.

    noimage: initialization, expected, and obtained values display as integers instead of character strings. By default, reports are generated with IMAGE attributes.

    nopos: modifies the way enumerated variables are displayed in the test report by not generating any POS or IMAGE attributes. Initialization and expected values are displayed as they are written in the test script, whereas obtained values do not appear (although they are tested). Use this option to save memory on restricted target platforms. By default, reports are is generated with IMAGE attributes.

    separ: modifies the format of the generated test program. In place of a main procedure including a sub-procedure for each service, the C Test Script Compiler generates one separate procedure for each service. With this restriction, the Test Script Compiler generates several compilation units and avoids overflow errors on compilation. By default, code is generated normally.

Several -restriction options can be used on the same command line. The ANSI and KR parameters, however, cannot be used together.

Other options

-STUDIO_LOG

This option is for internal usage only.

-TARGET

This option is deprecated.

Using an Option File

@<parameter file>

This syntax allows the compiler to pass options to the preprocessor through a file. The parameter file name can be written in absolute or relative format.

The format of the file must follow these rules:

  1. One or more options can occur per line.

    Each option must follow the same syntax as the command line version, with the character that usually introduces the option being '-' under UNIX and '/' under Windows.

    You may not use both an option file and command line options.

By default, no file is taken into account.

If the option file is not found, a fatal error is generated and the preprocessor stops.

Examples

attolprepro C add.ptu Tadd.cpp -service=add -test=1,2,3 -family=nominal

attolprepro CPP @add.opt

In this case, the parameter file add.opt would contains:

add.ptu Tadd.cpp

-service=add

-test=1,2,3

-family=nominal

Return Codes

After execution, the program exits with the following return codes

Code Description
0 End of execution with no errors
3 End of execution with one or more warning messages
5 End of execution with one or more errors
7 End of execution because of fatal error
9 End of execution because of internal error

These codes help you decide on a course of action once the Test Script Compiler has finished test execution. For example, if the return code in the command file shows there have been incorrect tests, you can save certain files in order to analyze them later.

All messages are sent to the standard error output device.

Related Topics

C++ Test Script Compiler | System Testing Script Compiler