polyspaceCodeProver
Run Polyspace Code Prover verification from MATLAB
For easier scripting, run Polyspace® analysis using a polyspace.Project
object.
Syntax
Description
polyspaceCodeProver
opens Polyspace
Code Prover™.
opens a Polyspace project file in Polyspace
Code Prover.status
= polyspaceCodeProver(projectFile
)
runs a verification on the Polyspace options object in MATLAB®.status
= polyspaceCodeProver(optsObject
)
Note
When you use a Polyspace options object to run an analysis, use only the Polyspace options object to specify options of the analysis. Using name-value arguments is not supported when the first argument is a Polyspace options object.
runs a verification on the Polyspace project file in MATLAB. If you have multiple modules or configurations, Polyspace runs the active configuration and active module. To see which module and configuration are active, open the project in the Polyspace interface and look for the bold, selected module and configuration. To change which module or configuration is active, before closing the Polyspace interface, select the module and configuration you want to verify. status
= polyspaceCodeProver(projectFile
,
'-nodesktop')
opens a Polyspace results file in Polyspace
Code Prover.status
= polyspaceCodeProver(resultsFile
)
opens a Polyspace results file from status
= polyspaceCodeProver('-results-dir',resultsFolder
)resultsFolder
in Polyspace
Code Prover.
displays all options that can be supplied to the status
= polyspaceCodeProver('-help')polyspaceCodeProver
command to run a Polyspace
Code Prover verification.
runs a Polyspace
Code Prover verification on the source files specified in status
= polyspaceCodeProver('-sources',sourceFiles
)sourceFiles
.
polyspaceCodeProver('-sources',
runs a Polyspace
Code Prover verification on the source files with additional options specified by one or more sourceFiles
,Name,Value
)Name,Value
pair arguments.
Note
Before you run Polyspace from MATLAB, you must link your Polyspace and MATLAB installations. See Integrate Polyspace with MATLAB and Simulink.
[
offloads the analysis to a remote cluster. Here,
status
, jobID
] = polyspaceCodeProver(___,'-batch','-scheduler',scheduler)scheduler
specifies the head node of
the cluster that manages the analysis submissions from
multiple clients. See also Manipulate Two Jobs in the Cluster.
Examples
Open Polyspace Projects from MATLAB
This example shows how to open a Polyspace project file with extension .psprj
from MATLAB. In this example, open the project file Code_Prover_Example.psprj
.
Assign the full project file path to a MATLAB variable prjFile
.
prjFile = fullfile(polyspaceroot, 'polyspace', 'examples', 'cxx', ... 'Code_Prover_Example', 'Code_Prover_Example.psprj');
Open the project.
polyspaceCodeProver(prjFile)
Open Polyspace Results from MATLAB
This example shows how to open a Polyspace results file from MATLAB. In this example, you open the results file from the folder
.polyspaceroot
\polyspace\examples\cxx\Code_Prover_Example\Module_1\CP_Result
Assign the full folder path to a MATLAB variable resFolder
.
resFolder = fullfile(polyspaceroot, 'polyspace', 'examples', ... 'cxx', 'Code_Prover_Example', 'Module_1', 'CP_Result');
Open the results.
polyspaceCodeProver('-results-dir',resFolder)
Run Polyspace Verification with Options Object
This example shows how to run a Polyspace verification in MATLAB using objects.
Create an options object and add the source file and include folder to the properties.
opts = polyspace.Options; opts.Sources = {fullfile(polyspaceroot, 'polyspace', 'examples',... 'cxx', 'Code_Prover_Example', 'sources', 'single_file_analysis.c')}; opts.EnvironmentSettings.IncludeFolders = {fullfile(polyspaceroot, 'polyspace', 'examples',... 'cxx', 'Code_Prover_Example', 'sources')}; opts.ResultsDir = fullfile(pwd,'results');
Run the verification and view the results.
polyspaceCodeProver(opts);
polyspaceCodeProver('-results-dir',opts.ResultsDir)
Run Polyspace Verification from MATLAB with DOS/UNIX Options
This example shows how to run a Polyspace verification in MATLAB using DOS/UNIX-style options.
Run the analysis and open the results.
sourceFiles = fullfile(polyspaceroot, 'polyspace', 'examples',... 'cxx', 'Code_Prover_Example', 'sources', 'single_file_analysis.c'); includeFolders = fullfile(polyspaceroot, 'polyspace', 'examples',... 'cxx', 'Code_Prover_Example', 'sources'); resultsDir = fullfile(pwd,'results'); polyspaceCodeProver('-sources',sourceFiles, ... '-I',includeFolders, ... '-results-dir',resultsDir,... '-main-generator'); polyspaceCodeProver('-results-dir',resultsDir);
Run Polyspace Verification with Coding Rules Checking
This example shows two different ways to customize a verification in MATLAB. You can customize as many additional options as you want by changing properties in an options object or by using Name-Value pairs. You specify checking of MISRA C™ 2012 coding rules, exclude headers from coding rule checking, and generate a main.
To create variables for source file path, include folder path, and results folder path that you can use for either analysis method.
sourceFileName = fullfile(polyspaceroot, 'polyspace','examples', 'cxx', 'Code_Prover_Example','sources','example.c'); includeFileName = fullfile(polyspaceroot, 'polyspace','examples', 'cxx', 'Code_Prover_Example','sources','include.h'); resFolder1 = fullfile('Polyspace_Results_1'); resFolder2 = fullfile('Polyspace_Results_2');
Verify coding rules with an options object.
opts = polyspace.Options('C'); opts.Sources = {sourceFileName}; opts.EnvironmentSettings.IncludeFolders = {includeFileName}; opts.ResultsDir = resFolder1; opts.CodingRulesCodeMetrics.MisraC3Subset = 'mandatory'; opts.CodingRulesCodeMetrics.EnableMisraC3 = true; opts.CodeProverVerification.EnableMain = true; opts.InputsStubbing.DoNotGenerateResultsFor = 'all-headers'; polyspaceCodeProver(opts); polyspaceCodeProver('-results-dir',resFolder1);
Verify coding rules with DOS/UNIX options.
polyspaceCodeProver('-sources',sourceFileName,... '-I',includeFileName, ... '-results-dir',resFolder2,... '-misra3','mandatory',... '-do-not-generate-results-for','all-headers',... '-main-generator'); polyspaceCodeProver('-results-dir',resFolder2);
Input Arguments
Output Arguments
Version History
Introduced in R2013b