Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • cpptestcli -data "c:\MyWorkspace" -resource "ProjectToTest" -config builtin://ShouldHaveRules -publish -settings acme_policy.settings

The reports will be sent to Parasoft DTP after each batch run.

cli Usage

The general procedure for testing from the command line is as follows:

...

  • -nobuildPrevents C/C++test from rebuilding the project before testing it. Use this option if the project is already built before the test run.
  • -failFails the build by returning a non-zero exit code if violations or setup problems are reported (see Command Line Exit Codes for details about exit codes returned if the process fails).
  • -publish - Publishes the report to DTP. You can enable sending reports to DTP in the GUI or in the command line mode; see Connecting to DTP.
  • -report %REPORT_FILE% - Generates an XML report to the given file %REPORT_FILE% and adds an HTML report (or one or more reports in other formats, if specified using the report.format option) with the same name (and a different extension) in the same directory.
    All of the following commands will produce an HTML report filename.html and an XML report filename.xml.
    • -report filename.xml
    • -report filename.htm
    • -report filename.html

    If the specified path ends with an ".html"/".htm"/".xml" extension, it will be treated as a path to the report file to generate. Otherwise, it will be treated as a path to a directory where reports should be generated.
    If the file name is explicitly specified in the command and a file with this name already exists in the specified location, the previous report will be overwritten. If your command doesn’t explicitly specify a file name, the existing report file will not be overwritten—the new file will be named repXXXX.html, where XXXX is a random number.
    If the -report option is not specified, reports will be generated with the default names "report.xml/html" in the current directory.

  • -dtp.autoconfig %PROJECT_NAME@BASE_URL% - Pulls settings stored on the DTP server (recommended for ease of maintenance — especially if you do not already have a locally stored settings file). 
    For example:
    -dtp.autoconfig Project1@https://dtp.company.com:8443

  • -encodepass <plainpassword> - Generates an encrypted version of a given password using AES 256-bit encryption. Prints the message 'Encrypted password: <encpass>' and terminates the cli application. 
    If your nightly process will send emails, you can use this option to encrypt the required passwords.

  • -showdetailsPrints detailed test progress information.

  • -showsettings - Prints the current settings and customizations along with the information where each of them is configured (e.g. in the settings.properties file). See Configuring Localsettings for the list of settings you can configure.
  • -appconsole stdout|% OUTPUT_FILE%Redirects C/C++test's console output to standard output or an %OUTPUT_FILE% file. 
    Examples:
    -appconsole stdout (console redirected to the standard output)
    -appconsole console.out (console redirected to console.out file)
  • -list-compilersPrints a list of valid compiler family values.   Should be used along with -data to specify a workspace.

  • -list-configs Prints a list of valid Test Configuration values.   Should be used along with -data to specify a workspace.

  • -bdf - Specifies the path to an existing build data file (.bdf) or another project definition file to collect the input scope. See Using cpptestscan or cpptesttrace to Create a Build Data File for information about creating build data files. The option also supports JSON formatted files generated by the CMake build system when running static analysis. Use of the -bdf option to specify a JSON file for unit test execution is not currently supported.  
  • -include %PATTERN%, -exclude %PATTERN% - Specifies files to be included/excluded during testing. 
    You must specify a file name or path after this option.
    Patterns specify file names, with the wildcards *and ? accepted, and the special wildcard ** used to specify one or more path name segments. Syntax for the patterns is similar to that of Ant filesets.
    Examples:
    -include **/Bank.cpp (test Bank.cpp files)

    -include **/ATM/Bank/*.cpp (test all .cpp files in folder ATM/Bank)

    -include c:/ATM/Bank/Bank.cpp (test only the c:/ATM/Bank/Bank.cpp file)

    -exclude **/internal/** (test everything except classes that have path with folder "internal")

    -exclude **/*Test.cpp (test everything, but files that end with Test.cpp)

    Additionally if a pattern is a file with a .lst extension, it is treated as a file with a list of patterns.
    For example, if you use -include c:/include.lst and include.lst contains the following (each line is treated as single pattern):
    **/Bank.cpp

    **/ATM/Bank/*.cpp

    c:/ATM/Bank/Bank.cpp

    then it has same effect as specifying:
    -include **/Bank.cpp -include **/ATM/Bank/*.cpp

    -include c:/ATM/Bank/Bank.cpp"

...

Options for Importing and Creating Projects

OptionPurposeNotes

-import %ECLIPSE_PROJECT%

Imports the specified Eclipse project(s) into the Eclipse workspace.

If %ECLIPSE_PROJECT% is a .project file, the selected project will be imported

If it is a directory, all Eclipse projects found in the selected directory and subdirectories will be imported.

Examples:

-import \".project\"

-import \"c:\\DevelRootDir\"

The -config option is not necessary while using -import. If the -config option is specified, then the workspace with the imported project(s) will be tested; otherwise, the project will be imported, but no testing will be performed.

-bdf <cpptestscan.bdf>

Creates C/C++test projects from build definition files (.bdf). 

To prepare a BDF, perform a build of the project with the cpptestscan utility as the prefix for the compiler / linker executable.

This option also supports JSON formatted files generated by the CMake build system when running static analysis. Using this option to specify a JSON file for unit test execution is not currently supported.

Example:

-bdf "cpptestscan.bdf"

See Creating a Project Using an Existing Build System for details. Options can be specified in the options file. See Settings (Options) Files for details.

The -config option is not necessary while using -import. If the -config option is specified, then the workspace with the imported project(s) will be tested; otherwise, the project will be imported, but no testing will be performed.

-gpj <.prj_root_file>

Creates C/C++test projects from Green Hills .gpj projects.

Green Hills .gpj project import options can be specified in the options file. See Settings (Options) Files for details.
The -config option is not necessary while using -import. If the -config option is specified, then the workspace with the imported project(s) will be tested; otherwise, the project will be imported, but no testing will be performed.

-hew %HEW_PROJECT%

Imports Highperformance Embedded Workshop projects. The following can be specified as %HEW_PROJECT%:
.hwp project file: The selected project will be imported.
.hws workspace file: All projects from the workspace will be imported.
directory: All .hwp projects found in the selected directory and subdirectories will be imported

The -config option is not necessary while using -import. If the -config option is specified, then the workspace with the imported project(s) will be tested; otherwise, the project will be imported, but no testing will be performed.

Examples:

-hew "MyProject.hwp"

-hew "MyWorkspace.hws"

-hew "c:\DevelRootDir"

-uv %KEILUV_PROJECT%

Imports Keil uVision projects. If %KEILUV_PROJECT% is:

.uvproj project file - the selected project will be imported

directory - all .uvproj projects found in selected directory and subdirectories

The -config option is not necessary while using -import. If the -config option is specified, then the workspace with the imported project(s) will be tested; otherwise, the project will be imported, but no testing will be performed.

Examples:

-uv "MyProject.uvproj"

-uv "c:\DevelRootDir"

Options for Testing Projects Available in the C/C++test for Eclipse Workbench

OptionPurposeNotes

-data %WORKSPACE_DIR%

Specifies the location of the Eclipse workspace directory to use.

Defaults to the current user’s dependent directory.

-resource %RESOURCE%

Specifies the path to the workspace resource %RESOURCE% to test.

Use multiple times to specify multiple resources.

Use quotes when the resource path contains spaces or other non-alphanumeric characters.

If %RESOURCE% is a .properties file, the value corresponding to com.parasoft.xtest.checkers.resources will be interpreted as a colon(:)-separated list of resources. Only one properties file can be specified in this way. If %RESOURCE% is a .lst file, each line will be treated as a resource. If no resources are specified on the command line, the complete workspace will be tested.

Team Project Set File (PSF) files are supported for SVN and other source control systems (depending on the Eclipse plugin capabilities installed).

Paths (even absolute ones) are relative to the workspace specified by the -data parameter.

Examples:

-resource "Acme Project"

-resource "/MyProject/src/com/acme/MyClassTest.java"

-resource "/MyProject/src/com/acme"

-resource testedprojects.properties


Note
titleNotes
  • To see a list of valid command line options, enter for cpptestcli -help.
  • cpptestcli automatically emails designated group managers and architects a report that lists all team/project errors and identifies which developer is responsible for each error. If no errors are reported, reports will be sent unless the options file contains the report.mail.on.error.only=true option.
  • If the appropriate prerequisites are met, cpptestcli automatically emails each developer a report that contains only the errors/results related to his or her work. If no errors are reported for a particular developer, a report will not be emailed to that developer.

...