C Source Code Parser - attolstartC

Purpose

When creating a new Component Testing test campaign for C, the C Source Code Parser creates a C test script template based on the analysis of the source code under test.

Syntax

attolstartC <source_file> <test_script> [{<-option>}]

attolstartC <source_file> -metrics [{<-option>}]

attolstartC @<option file >

where:

Description

The C Source Code Parser analyzes the source file to be tested in order to extract global variables and testable functions.

Each global variable is automatically declared as external, if this has not already been done at the beginning of the test script. Then, an environment is created to contain all these variables with default tests. This environment has the name of the file (without the extension).

For each function under test, the generator creates a SERVICE which contains the C declaration of the variables to use as parameters of the function.

Parameters passed by reference are declared according to the following rule:

It is sometimes necessary to modify this declaration if it is unsuitable for the tested function, where <type>* <param> can entail the following declarations:

File names can be related or absolute. Path names must not contain commas or non-alphanumeric characters.

If the generated file name does not have an extension, the C Source Code Parser automatically attaches .ptu or the extension specified by the ATTOLPTU environment variable. This name may be specified relatively, in relation to the current directory, or as an absolute path.

If the test script cannot be created, the C Source Code Parser issues a fatal error and stops.

If the test script already exists, the previous version is saved under the name <generated test script>_bck and a warning message is generated.

When the -metrics option is specified, the Source Code Parser produces static metrics for the specified source files. In this case, no other output is produced.

Options

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

If attolstartC is invoked without parameters, the binary returns a list of options. Some of those options are deprecated and listed only for legacy purposes.

Included Files

-insert

With this option the source file under test is included into the test script with an #include directive, ensuring that all the internal functions and variables (declared static) are visible to the test script. The C Source Code Parser adds the #include directive before the BEGIN instruction and after any #includes added by the -use option.

 

-use=<file used>{[,<file used>]}

This option gives the C Source Code Parser a list of header files to include in the test script before the BEGIN instruction. This avoids declaring variables or functions that have already been declared in a C header file of the application under test.

The C Source Code Parser adds the #include directive before the BEGIN instruction. Then, for each file, an environment is created, containing all variables with a default test. This environment has the name of the included file.

By default, no files are included in the test script.

Integrated Files

-integrate=<additional file>{[,<additional file>]}

This option provides a list of additional source files whose objects are integrated into the test program after linking.

The C Source Code Parser analyzes the additional files to extract any global variables that are visible from outside. For each global variable the Parser declares an external variable and creates a default test which is added to an environment named after the corresponding additional file.

By default, any symbols and types that could be exported from the source file under test are declared again in the test script.

Simulated Files

-simulate=<simulated file>{[,<simulated file>]}

This option gives the C Source Code Parser a list of source files to simulate upon execution of the test. List elements are separated by commas and may be specified relatively, in relation to the current directory, or as an absolute path.

The Parser analyzes the simulated files to extract the global variables and functions that are visible from outside. For each file, a DEFINE STUB block, which contains the simulation of the file's external global variables and functions, is generated.

By default, no simulation instructions are generated.

Static Metrics

-metrics=<output directory>

Generates static metrics for the specified source files. Resulting .met static metric files are produced in specified <output directory>. When the -metrics option is used, no other action is performed by the Source Code Parser.

 

-one_level_metrics

For use with the -metrics option only. When the -metrics option is used, by default, the calculation of static metrics is applied to the specified source files, and extended to any files included in those source files. Use the -one_level_metrics option to ignore included files when calculating static metrics.

 

-restrict_dir_metrics <directory>

For use with the -metrics option only. Use the the -restrict_dir_metrics option to calculate static metrics of the specified source files, extended to any files included in those source files but limited to those files located in the specified <directory>.

Other Options

-studio_log

This option is for internal usage only.

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

 

All messages are sent to the standard error output device.