ocpidev-test — manage an OpenCPI component unit test suite.
The test noun represents an OpenCPI component unit test suite, which
is a collection of test cases for testing all workers that implement the
a single component specification (OCS) across all available platforms for
which the workers have been built. The workers tested by the component
unit test suite can be written to different authoring models or languages or
can be different source code implementations of the same component
specification. As long as they implement the same component specification,
they can be tested with the same unit test suite.
A test case is a parameterized test that uses a defined set of inputs or generation scripts and a defined set of outputs or verification scripts using a defined matrix of property values. OpenCPI supplies a default test case that tests all parameter combinations as derived from all worker parameter/build configurations or all workers. A developer can supply runtime property settings with multiple values for each, resulting in the cross-product of subcases. The default test case has one generation script and one verification script, per port, parameterized by test subcase (specific test) property values.
A component unit test suite has five phases:
The ocpidev build operation performs the generate and build phases, while the
ocpidev run operation performs the prepare, execute, and verify phases.
A component unit test suite is described by an OpenCPI Test Suite Description (OTSD), which is an XML file that specifies the test cases and the defaults that apply to all test cases.
In a project, a component unit test suite resides in its own
directory named <component-name>.test within a component library.
Within the test suite directory are:
-test.xml)
generator.py)
verify.py)
view.sh)
The ocpidev create operation produces initial versions of these files that can then be edited as necessary to implement the test suite.
Running the build and generate phases creates two additional subdirectories:
gen/ subdirectory that contains the built test cases and a text file that describes them
applications/ subdirectory that contains OpenCPI Application Specification (OAS) files and scripts used by the OpenCPI test framework to execute the test cases
Running the prepare and execute phases creates an additional run/ subdirectory
that contains the results of the test case executions, such as output data
from each output port, final values of all properties, including volatile
properties, and a log file of the actual test execution.
Running ocpidev clean removes the application/, gen/ and run/ subdirectories.
The chapter "Unit Testing of Workers" in the OpenCPI Component Development Guide provides details on the OpenCPI Test Suite Description XML structure and syntax, test suite phase operations, and the development process for OpenCPI component unit test suites.
Verbs that can operate on a component unit test suite are:
build
clean
create
delete
run
Note that an asset’s name is implied by the directory you’re in when
you issue the ocpidev command. For a component unit test suite, this
means that you can perform operations (verbs) on the unit test
without having to specify its
name when you issue the ocpidev command from inside the
the component unit test suite’s directory.
The ocpidev tool can also operate on a plural tests noun.
The syntax is:
ocpidev [<options>] [run|show] tests
The verbs that can be performed on the tests noun are:
run
run options
for component unit test suites can be used.
show
show formatting options can
be used.
In addition to the options common to all OpenCPI tools (see opencpi(1)), the options described below can be specified for operations on component unit test suites. In the following descriptions, a plus sign (+) after the option indicates that it can be specified more than once on the command line.
Keywords for platforms supported by OpenCPI that can be specified in the <platform> argument to an option can be found in the tables of supported platforms in the OpenCPI User Guide.
Keywords for architectures supported by OpenCPI that can be specified
in the <target> argument include isim, modelsim,
xsim, zynq, zynq_ultra, zynq_ise, spartan3adsp.
-G <platform>, --only-platform=<platform>+
-Q <platform>, --exclude-platform=<platform>+
-S <spec>
ocpidev create operation
searches for a component spec whose name matches
the name of the test suite being created. Use the -S
option to specify a different component spec name to search for.
The operation searches for a component spec in the component
directory in the same library as the test suite, in the specs directory
in the same library as the test suite (for backward compatibility with
earlier OpenCPI releases), in the top-level specs directory in the
project, and in other projects, if the --depend (-D) option
was specified when the project containing the test suite was created.
-T <target>, --only-target=<target>+
-k, --keep
--hdl-rcc-platform=<platform>+
--rcc-platform <platform> is also not used),
the current development software platform is used as
the single RCC platform used for building.
--rcc-platform=<platform>+
--hdl-rcc-platform <platform>
is also not used), the current development software platform
is used as the single RCC platform used for building.
--hdl-platform=<hdl-platform>+
--hdl-target=<target>+
-G <platform>, --only-platform=<platform>+
-Q <platform>, --exclude-platform=<platform>+
-l <library>, --library=<library>
--accumulate-errors
--case=<test-case>+
--hdl-platform=<platform>+
--keep-simulations
--phase=<phase>+
prepare, execute, verify, and view.
The view phase is used to run only the view scripts for the unit test,
without other phases. The --view option can be used to add viewing along with other phases.
--rcc-platform=<platform>+
--remotes=<system>
OCPI_REMOTE_TEST_SYS variable. See the section
"Defining Remote Systems for Executing Tests"
in the OpenCPI Component Development Guide for more information.
--view
view.sh) at the conclusion of the
test suite’s execution.
--json
--local-scope
--simple
--table
--simple or --json are not used.
From the project’s components library, create a component
unit test suite for the mycomp component:
ocpidev create test mycomp
Inside the components library, create a component unit test
suite for the mycomp component that only runs on
the plutosdr HDL platform:
ocpidev create test mycomp -G plutosdr
Inside the components library, create a unit test suite for the mycomp
component that only runs on platforms that implement the zynq architecture:
ocpidev create test mycomp -T zynq
Inside the mycomp.test directory, build the component unit
test suite for the zed HDL platform and xilinx19_2_aarch32 RCC platform.
ocpidev build test --hdl-platform zed --rcc-platform xilinx19_2_aarch32
Inside the mycomp.test directory, clean the directory:
ocpidev clean test
Inside the components library in the current project, run
all phases of the component unit test suite for
the mycomp component, accumulating any errors and invoking
the viewer shell script (view.sh) to view the plotted test results:
ocpidev run test mycomp.test --accumulate_errors --view
Inside the assets project, run the view script only for the timestamper
component unit test suite in the util_comps library:
ocpidev run test timestamper.test -l util_comps --phase=view
Inside the components library in the current project, run
all the component unit test suites in the library:
ocpidev run tests
Display information about the component unit test suites in the current project:
ocpidev show tests --local-scope
Be aware that a view script (e.g., view.sh) invoked by the --view option
may be designed such that it runs a program in a background process to
produce a pop-up window that displays a plot or other data representation
for a test case. When a test suite has multiple test cases, multiple
display windows are created (one for each test case) and persist until
the user explicitly closes them. In this scenario, test suites with a
large number of test cases will result in a large number of background
processes simultaneously running display windows, which can significantly
degrade system performance. The workaround in this scenario is to refrain
from using the --view option.
See the main web site: https://www.opencpi.org
See the OpenCPI Component Development Guide: https://opencpi.gitlab.io/releases/latest/docs/OpenCPI_Component_Development_Guide.pdf