This topic explains how to review and customize project-level and file-level options, including build settings, custom compiler and linker options, and other settings.
Sections include:
Reviewing and Modifying Settings
The appropriate build settings must be configured in order for C/C++test to properly test your code. Additionally, Advanced Settings (instrumentation options) can be configured as needed.
To review and modify settings:
Right-click the Solution Explorer tree (a.k.a. "the project tree") node for the project or file whose settings you want to review and modify, then choose Parasoft>Properties from the shortcut menu. The Properties dialog will open.
- Expand the Parasoft> C/C++test category in the left pane.
- Select the category that represents the settings you want to review and/or change. Categories and available settings are described below. Build Settings must be reviewed and then modified as needed. Reviewing other settings is optional.
- Modify the options in the right pane.
- Click Apply, then OK.
Available Settings
Build Settings
Options source: Determines how options are set.
Use options from a build data file is recommended if you used
cpptestscan
to create a build data file, as described in, and if you prefer to manually manage regeneration and update the build data file.- Use options from a build system is recommended if 1) your project can be built from the command line, but you did not create a build data file or 2) if you created a build data file, but would prefer C/C++test to manage regeneration / update of the build data file.
Use options from the project is recommended for projects that were originally developed in Visual Studio.
Use options from the project is recommended for projects that were originally developed in Visual Studio.
The available controls depend on the Options source selected.
Note
If you decide to manually manage a build data file, integrating the mechanism for creating build data files into your build process is highly recommended. This is so that members of the development team can access and use your build data file, as well as helps you seamlessly generate or update it during regular build activities.
Managing Multiple C/C++test's Project Configurations
Multiple C/C++test Project Configurations can be used to manage tests for a range of different configurations. For example, you can configure a project for testing a host-compiler, cross-compiler, testing in Debug mode, testing in Release mode, etc.
You can also export current active properties to a file or import previously saved properties from a file:
- From right-click your project in the project explore and click Properties.
- Choose Parasoft> C/C++test and click Export or Import.
- Browse for the properties and click Save or Open.
Exporting a properties creates a file that's can also be used as an argument in the cpptestcli -settings
parameter. This allows you to easily switch between different project configurations when testing from the command line.
Use options from the project
To configure the appropriate settings:
- In the Configuration field, select the configuration that you want to use.
- If you want to refresh the list of available configurations, click Refresh.
- In the Compiler settings area, specify the compiler executable (for C and C++ sources), linker, and family.
- In the Options area, specify any test-specific or C/C++test-specific options compiler or linker options that you want to use.
When Visual C++ project file options change, C/C++test will automatically rescan the options and modify the project accordingly.
Use options from a build data file
To configure the appropriate settings:
- In the Build data file field, enter or browse to the location of the build data file that was previously created (as described in Using cpptestscan or cpptesttrace to Create a Build Data File).
- Using an absolute path could result in a non-portable project. We recommend that you use the following C/C++test variable to specify the path:
${resource_loc}
resolves to the path to the specific project resource. For instance,${resource_loc:/MyProject/linked_src_dir/source.cpp}
will be resolved intoC:\src\source.cpp
.
- Using an absolute path could result in a non-portable project. We recommend that you use the following C/C++test variable to specify the path:
- If you want C/C++test to clear previous options information each time the options are scanned, clear the Keep previously collected options (incremental build) check box. Otherwise, each build will be treated as an incremental build.
- If you have an incremental build, select the Delete build data file after processing checkbox if you want C/C++test to remove the build data file after C/C++test scans options from it. This will ensure that build data file does not grow infinitely when subsequent builds are performed.
- In the Compiler settings area, specify the compiler executable (for C and C++ sources), linker, and family. If your compiler is not listed, add a custom compiler definition for it (as described in Configuring Testing with the Cross Compiler).
- In the Options area, specify any test-specific or C/C++test-specific options compiler or linker options that you want to use, and that are not already specified in the Makefile. See Specifying Custom Compiler Settings and Linker Options for details.
When the options in the specified build data file change, C/C++test will automatically rescan the options and modify the project accordingly. If you want to force C/C++test to update options immediately (for example, if an external configuration file has changed), click the Reset cache button.
Use options from a build system
To configure the appropriate settings:
- In the Build command line field, review the options that C/C++test will use to run the build (e.g., execute make with the specified makefile) and collect project build options from that process.
- C/C++test replaces the compiler by reassigning values to the appropriate variables, as specified in the build command line.
- The C/C++test options scanner is represented by the
${CPPTEST_SCAN}
variable.
- If your build system uses compiler/linker variables that are different than the default ones provided with C/C++test, modify the build command line as needed.
- C/C++test will scan options for all files that will be processed with the options scanner. You should provide an appropriate command line to force execution of the compiler for all source files. Otherwise, some of the files won't be tested.
Here is a sample GNU build command line:
make -i -B objects CXX=${CPPTEST_SCAN} CC=${CPPTEST_SCAN}
This command line will build theobjects
make target with the flags-B
(make all targets unconditionally) and-i
(ignore errors). TheCXX
andCC
make variables will be substituted with${CPPTEST_SCAN}
. This command line will allow C/C++test to extract options for all source files that are normally compiled to build theobjects
target.- If your command line shell processes $ in a special way (e.g., in bash), remember to escape the $ sign with \ (a backslash); for example,
CXX=\${CPPTEST_SCAN}
- C/C++test will support any build process (using nmake, ant, or arbitrary build scripts) as long as it can replace the compiler and linker by reassigning the appropriate variables. Consult your build engineer for appropriate options.
Important note about the -B Switch
The build command line is preset to include the -B switch option (unconditionally make all targets). Only GNU Make 3.80+ supports this option.
If you are using an earlier make, clean the build before creating a project. Keep the -k switch.
If you are using a make that does not support -B, further modification of the command line is required. The default build command line used in the project properties does not have any targets. We recommend that you modify this command line with the target(s) used to build the code you want analyzed For example:
make -i CXX=\${CPPTEST_SCAN} ... all
(where all
is a target).
Also, add a clean step prior to the normal build target. For example:
make -i CXX={CPPTEST_SCAN} ... clean all
This would first make the clean target, then all
target. Although the make run from C/C++test will not actually build object files, the clean
step will actually clean them.
3. In the Build working directory field, specify the directory in which the build process should execute.
- Using an absolute path could result in a non-portable project. We recommend that you use the following C/C++test variables to specify the path:
${project_loc}
resolves to the absolute path to the Visual Studioproject location${resource_loc}
resolves to the path to the specific project resource. For instance,${resource_loc:/MyProject/linked_src_dir/source.cpp}
will be resolved intoC:\src\source.cpp
.
- Using an absolute path could result in a non-portable project. We recommend that you use the following C/C++test variables to specify the path:
4. In the Dependency file(s) field, specify the Makefile(s) to be checked for changes. Options will be automatically updated if the specified file(s) changes.
Using an absolute path could result in a non-portable project. We recommend that you use the following C/C++test variables to specify the path:
${project_loc}
resolves to the path to the Visual Studioproject location${resource_loc}
resolves to the path to the specific project resource. For instance,${resource_loc:/MyProject/linked_src_dir/source.cpp}
will be resolved intoC:\src\source.cpp.
5. In the Compiler settings area, specify the compiler executable (for C and C++ sources), linker, and family. If your compiler is not listed, add a custom compiler definition for it (as described in Configuring Testing with the Cross Compiler).
6. In the Options area, specify any test-specific C/C++test-specific options compiler or linker options that you want to use, and that are not already specified in the Makefile. See Specifying Custom Compiler Settings and Linker Options for details.
When the options in the specified dependency file(s) change, C/C++test will automatically rescan the options and modify the project accordingly.
Execution (File-Level Only)
Determines whether the selected source file is instrumented during test case execution.
In order to apply this setting to multiple files, select files in the project tree, then right-click the selection and choose Parasoft> C/C++test> Execution Settings. Note that the current setting will be applied uniformly to all selected files.
Other Settings
C/C++test Temporary Files
The C/C++test temporary files field controls where C/C++test keeps temporary data/files, such as instrumented sources, compiled objects, linked test executables, and automatically-generated header files. This setting controls {cpptest:testware_loc}
.
Since C/C++test can automatically re-generate these files as needed, they do not need to be shared across team members. Thus, these files should not be saved within the project or added to source control.
The temporary data can be deleted by clicking the Clear button. We recommend that you do not delete the temporary data between test runs; keeping this data can significantly improve performance.
For optimal performance, use a location on the local hard drive.
Advanced Options
This table allows you to specify various low-level and debug options; for a list of available options, see Advanced Instrumentation Configuration Options.
Source File Encoding
Determines if multibyte encoding should be used when processing source files. By default, C/C++test automatically activates support for multibyte characters based on the current system encoding (Auto mode). In order to manually control multibyte support, set the option value to On or Off.
Note that performance may be impacted by analyzing code with support for multibyte characters enabled.
Scope Settings
Allows you to specify project files that you do not want tested. See Testing a User-Defined Set of Resources for details.