Select AUTOSAR XML (ARXML) and Code Files for Polyspace Analysis
This topic describes a component-based approach to verifying AUTOSAR code with Polyspace. For an integration analysis approach, see Choose Between Component-Based and Integration Analysis of AUTOSAR Code with Polyspace.
If you run Polyspace® on an AUTOSAR project by providing only the ARXML and source root folder, you might run into setup errors.
A typical AUTOSAR root folder contains many extraneous files, for instance, files for testing and documentation. These files might have extensions such as
.arxml
or.c
, and Polyspace might incorrectly treat them as ARXML or source files and include them in the analysis.The implementation of some software components might be in progress and incomplete.
If you are familiar with the structure of your AUTOSAR project, you can exclude extraneous and incomplete files and folders from the analysis.
The polyspace-autosar
options that
support file selections are -select-arxml-files
and
-select-source-files
. Since the fully qualified names of AUTOSAR
behaviors and data types use similar separators as file paths, you can also specify
behaviors with -autosar-behavior
and data types with
-autosar-datatype
using the file selection syntax.
Adapt Linux find
Command to Select Files
The file selection syntax closely emulates the Linux®
find
command. You specify a root folder followed by file inclusions
and exclusions by using shell patterns or regular expressions.
For instance, to find all files with extension .arxml
in a folder
package
, you use the Linux command:
find package -name '*.arxml'
To specify all ARXML files in the folder package
, copy the part of
the command following find
. Provide the copied content as a string
argument to the option -select-arxml-files
of the
polyspace-autosar
command:
polyspace-autosar -select-arxml-files "package -name '*.arxml'"
find
options as a single string (within double quotes). During
analysis, these ARXML files are not copied over to a temporary folder but selected from
their respective locations.If you enter the option in an options file (that you later use with the polyspace-autosar
option
-options-file
), you do not need the double quotes around the
string. You can append the find
string to the
-select-arxml-files
option. For instance, you can enter this line
in the options file:
-select-arxml-files package -name '*.arxml'
File Selection Options
The following find
options are commonly required for file
selection. Use the i
format of the options for case-insensitive matching.
-name
,-iname
: Match file names with shell patterns.-path
,-ipath
: Match file paths with shell patterns.-regex
,-iregex
: Use regular expressions for matching instead of shell patterns.
Use -not
before an option to exclude files or folders.
To specify multiple patterns in a single string, simply place the patterns one after
another. For instance, to exclude immediate subfolders subpackage1
and subpackage2
from a root folder, use this syntax:
-not -path 'subpackage1/*' -not -path 'subpackage2/*'
For more information on:
Shell patterns, see Shell Pattern Matching.
find
options, see Finding Files.
File Selection Examples
Some common uses of the file selection options are:
To specify only the ARXML files beginning with
swc
in the subfoldersub_package_windowControl
within the root folderpackage
, use this syntax:polyspace-autosar -select-arxml-files "package -path 'sub_package_windowControl/*' -name 'swc*.arxml'"
To exclude ARXML files from the subfolder
test
at any level in the file structure within the root folderpackage
, use this syntax:polyspace-autosar -select-arxml-files "package -not -path '*/test/*' -name '*.arxml'"
To exclude ARXML files from the subfolder
test
and subfolderdocs
at any level in the file structure within the root folderpackage
, use this syntax:polyspace-autosar -select-arxml-files "package -not -path '*/test/*' -not -path '*/docs/*' -name '*.arxml'"
To include all ARXML files from the root folder
package
except those ARXML files containing the stringtest
, use this syntax:polyspace-autosar -select-arxml-files "package -name '*.arxml' -not -name '*test*.arxml'"
Likewise, you can include or exclude .c
and .h
files from analysis by using the -select-source-files
option. Unlike
-select-arxml-files
, this option selects .c
and .h
files by default. For instance, to exclude source files from
the subfolder test
at any level in the file structure within the root
folder package
, use this syntax:
polyspace-autosar -select-source-files "package -not -path '*/test/*'"
Note that with -select-arxml-files
earlier, you also had to specify
the additional pattern -name '*.arxml'
.
Root Folder Specification
If the root folder name contains spaces, enclose the folder name in double quotes.
Because the folder name with file inclusions and exclusions is already in double quotes,
you have to escape the additional quotes. For instance, if the root folder is
C:\sdbx\ARXML dir1
, to specify all ARXML files within this
folder, use the command:
polyspace-autosar -select-arxml-files "\"C:\sdbx\ARXML dir1\" -name '*.arxml'"
\"
.If you specify the option in an options file (that you later use with the polyspace-autosar
option
-options-file
), you do not need quotes around the
find
string and do not need to escape the additional double
quotes. Enter this line in the options file:
-select-arxml-files "C:\sdbx\ARXML dir1" -name '*.arxml'