主要内容

polyspace.project.OwnedTestConfiguration Class

Namespace: polyspace.project

(Python) Testing and profiling configurations attached to specific project

Since R2024a

Description

The properties of the polyspace.project.OwnedTestConfiguration class contain the testing and profiling configuration options attached to a specific Polyspace® Platform project. These object properties correspond to the options related to code profiling in Polyspace Test™. See Code Profiling in Polyspace Platform User Interface.

To create modular projects, where project components like configurations and graphical tests are saved in separate files, consider using external configurations. An external configuration is a build, static analysis, or testing and profiling configuration that is saved in a separate .pscfg file that is referenced by the project. To work with external testing and profiling configurations in the Polyspace Python® API see polyspace.project.TestConfigurationRef and polyspace.project.TestConfiguration. For more information about project structure, see Modularize Project by Using External Configurations, Test References, and External Stub Files.

Creation

Description

Create Testing and Profiling Configuration

testConfig = proj.TestConfigurations.create(configName) creates a new polyspace.project.OwnedTestConfiguration object with the Name property set to configName and all other properties set to their default values. The resulting testConfig object is attached to the polyspace.project.Project object proj.

Load Testing and Profiling Configuration

testConfig = proj.TestConfigurations[configName] loads the existing polyspace.project.OwnedTestConfiguration object with the Name property set to configName from the polyspace.project.Project object proj.

Create Copy of Testing and Profiling Configuration

testConfig = proj.TestConfigurations.createFrom(existingConfigObj) creates a new polyspace.project.OwnedTestConfiguration object by copying an existing owned test configuration existingConfigObj and attaches this copied object to the polyspace.project.Project object proj. To assign a unique name to testConfig, Polyspace uses the Name property of existingConfigObj and appends the next available numeric suffix.

testConfig = proj.TestConfigurations.createFrom(existingConfigObj, configName) creates a new polyspace.project.OwnedTestConfiguration object by copying an existing owned test configuration existingConfigObj and attaches this copied object to the polyspace.project.Project object proj. Use the configName argument to set the Name property of the resulting object.

testConfig = proj.TestConfigurations.createFrom(existingConfigFile) creates a new polyspace.project.OwnedTestConfiguration object by copying the testing and profiling configuration defined in the file existingConfigFile.pscfg and attaches this object to the polyspace.project.Project object proj.

testConfig = proj.TestConfigurations.createFrom(existingConfigFile, configName) creates a new polyspace.project.OwnedTestConfiguration object by copying the testing and profiling configuration saved in the file existingConfigFile.pscfg and attaches this object to the polyspace.project.Project object proj. Use the configName argument to set the Name property of the resulting object.

Convert Testing and Profiling Configuration

testConfig = proj.TestConfigurations.moveAsOwned(existingConfigRefObj) converts the testing and profiling configuration that the project proj references through existingConfigRefObj to a polyspace.project.OwnedTestConfiguration object and removes existingConfigRefObj from the project.

Input Arguments

expand all

Name of the testing and profiling configuration, specified as a string. This argument sets the Name property of the object.

Example: "My Test Configuration"

Existing owned testing and profiling configuration to make a copy of, specified as a polyspace.project.OwnedTestConfiguration object.

Example: proj.TestConfigurations[2]

Absolute or relative path to an existing .pscfg file, specified as a string. Relative paths are considered relative to the location of the .psprjx project file.

Example: "myTestConfig.pscfg"

The existing referenced test configuration that you want to convert to a polyspace.project.OwnedTestConfiguration object, specified as a polyspace.project.TestConfigurationRef object.

Example: proj.TestConfigurationRefs[0]

Properties

expand all

Name of the testing and profiling configuration, specified as a string.

Optional description of the test configuration. Use this property to provide information about the test configuration.

Example: "Test configuration for MCDC"

Enable this property to reduce the amount of memory Polyspace uses to run the test executable. Set this property to True if you have a large test executable that requires more memory than available.

See also Enable compact mode for coverage calculation (-compact).

Example: testConf.CoverageOptions.Compact=True

Level of code coverage metric calculation. The number of code coverage metrics calculated increases in this order: STATEMENT, DECISION, CONDITION_DECISION, MCDC.

For more information on which metrics are calculated, see Coverage metrics (-cov-metric-level).

Example: testConf.CoverageOptions.Level=testConf.CoverageOptions.Level.MCDC

Enable relational boundary coverage calculations. Polyspace Test determines the number of boundaries for all relational operations in your code and then calculate the percentage of tested boundaries out the total number of boundaries. For example, the relational operation between integers var1 > var2 has three boundaries and can be tested with these values:

  • var1 == var2

  • var1 == var2 + 1

  • var1 == var2 - 1

See also Enable relational boundary coverage (-cov-relbound) and Relational Boundary Coverage.

Example: testConf.CoverageOptions.RelationalBoundary=True

Value of absolute tolerance of floating-point relational operation. Use this value to tune the tolerance when calculating the relational boundary coverage for a floating-point or fixed-point relational operation.

See also Absolute tolerance (-cov-relbound-abs-tol).

Example: testConf.CoverageOptions.RelationalBoundaryAbsTol=1e-6

Value of relative tolerance of floating-point relational operation. Use this value to tune the tolerance when calculating the relational boundary coverage for a floating-point or fixed-point relational operation.

See also Relative tolerance (-cov-relbound-rel-tol).

Example: testConf.CoverageOptions.RelationalBoundaryRelTol=0.001

Specify additional options that cannot be specified in the existing options.

To modify this property, use these methods:

  • append(option) — Add an option to this property.

  • pop(optionIdx) — Remove the option with index optionIdx. If you do not specify an index, the last option in the list is removed.

  • clear() — Remove all options associated with this property.

See also Additional options.

Example: testConf.ProfilingOptions.ExtraOptions.append("-fail-if-error")

Example: testConf.ProfilingOptions.ExtraOptions.pop(0)

Specify path of source files that Polyspace Test ignores when instrumenting your source code for code coverage and execution profiling calculations.

To modify this property, use these methods:

  • append(filePath) — Add the path of a file to ignore.

  • pop(filePathIdx) — Remove the file path with index filePathIdx. If you do not specify an index, the last file path in the list is removed.

  • clear() — Remove all file paths associated with this property.

See also Files to ignore (-ignore-file).

Example: testConf.ProfilingOptions.FileToIgnore.append("/path/to/file.c")

Example: testConf.ProfilingOptions.FileToIgnore.pop(0)

Specify path of folders that Polyspace Test ignores when instrumenting your source code for code coverage and execution profiling calculations.

To modify this property, use these methods:

  • append(folderPath) — Add the path of a folder to ignore.

  • pop(folderPathIdx) — Remove the folder path with index folderPathIdx. If you do not specify an index, the last folder path in the list is removed.

  • clear() — Remove all folder paths associated with this property.

See also Folders to ignore (-ignore-dir).

Example: testConf.ProfilingOptions.FoldersToIgnore.append("/path/to/folder")

Example: testConf.ProfilingOptions.FoldersToIgnore.pop(0)

Specify path of folders that Polyspace Test parses for source files to instrument. Use this option to limit the code profiling to only the source files in the specified folders.

To modify this property, use these methods:

  • append(folderPath) — Add the path of a folder to profile.

  • pop(folderPathIdx) — Remove the folder path with index folderPathIdx. If you do not specify an index, the last folder path in the list is removed.

  • clear() — Remove all folder paths associated with this property.

See also Folders to profile (-limit-instrumentation-to).

Example: testConf.ProfilingOptions.FoldersToProfile.append("/path/to/folder")

Example: testConf.ProfilingOptions.FoldersToProfile.pop(0)

Specify function calls to exclude from source code instrumentation. For each function call that you specify, Polyspace instruments the body of the function but not calls to that function. Use the fully qualified name of functions that are part of a namespace, for example foo::bar::calculate().

Use this option to exclude functions such as third-party or legacy functions from your profiling calculations.

See also Function Call to ignore (-ignore-fcn-call).

Example: testConf.ProfilingOptions.FunCallToIgnore.add("foo")

Example: testConf.ProfilingOptions.FunCallToIgnore.remove("foo")

Specify functions to exclude from source code instrumentation. Use the fully qualified name of functions that are part of a namespace, for example foo::bar::calculate().

Use this option to skip profiling specific functions in your code base such as third-party API or legacy functions.

See also Functions to ignore (-ignore-fcn).

Example: testConf.ProfilingOptions.FunToIgnore.add("main")

Example: testConf.ProfilingOptions.FunToIgnore.remove("main")

Methods

expand all

Version History

Introduced in R2024a

expand all