Browse Source

doc: overhaul sample criteria and expectations

overhaul sample criteria and what we expect in a sample, especially
overhaul the twister part and what should be provided for good test
coverage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
pull/77806/head
Anas Nashif 10 months ago committed by Carles Cufí
parent
commit
ef49f031dc
  1. 66
      samples/sample_definition_and_criteria.rst

66
samples/sample_definition_and_criteria.rst

@ -11,11 +11,13 @@ more features, subsystems, or modules. This includes kernel services, drivers, p
Samples should be limited in scope and should focus only on demonstrating non-trivial or Samples should be limited in scope and should focus only on demonstrating non-trivial or
essential aspects of the subsystem(s) or module(s) being highlighted. essential aspects of the subsystem(s) or module(s) being highlighted.
Samples are recommended when submitting new features; however, they are not mandatory.
Sample Criteria Sample Criteria
=============== ===============
1. Samples must not be used as a testcase. 1. Samples must not be used to test features or verify platforms
++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* The primary purpose of a sample is to provide a reference to the user. * The primary purpose of a sample is to provide a reference to the user.
* Samples must not use Zephyr's testing framework. * Samples must not use Zephyr's testing framework.
@ -25,7 +27,13 @@ Sample Criteria
* If a sample can provide output that can be verified, then output should be evaluated against * If a sample can provide output that can be verified, then output should be evaluated against
expected value to have some level of testing for the sample itself. expected value to have some level of testing for the sample itself.
Refer to :ref:`twister_script` for more details. Refer to :ref:`twister_script` for more details.
* Samples are optional.
* Although being able to run a sample successfully does verify the
functionality is working as expected, this should not replace dedicated and
comprehensive tests with full coverage to be submitted into the
:zephyr_file:`tests/` folder. In a sample, the only thing you test is
buildability and, in some cases, if a sample is performing as expected, i.e. you
are testing the sample, not the subsystem it builds on top.
2. Twister should be able to build every sample. 2. Twister should be able to build every sample.
++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++
@ -39,36 +47,42 @@ Sample Criteria
sample.kernel.cond_var: sample.kernel.cond_var:
integration_platforms: integration_platforms:
- native_sim - native_sim
tags: kernel condition_variables tags:
- kernel
- condition_variables
harness: console harness: console
harness_config: harness_config:
type: one_line type: one_line
regex: regex:
- ".*Waited and joined with 3 threads" - ".*Waited and joined with 3 threads"
**Guidelines for Samples:** * Do not mark the test as build only. A sample should be able to build *and*
* Minimize the use of ``platform_allow`` and architecture filters. run on the documented platforms. Use the ``harness`` option to skip the
* Do not mark the test as build only unless necessary. execution. Twister only attempts to flash and execute the build binary if
* Any test case-specific configuration options are added using ``extra_args`` or the harness is set to ``ztest`` or ``console``.
``extra_configs`` options in the YAML file. The `prj.conf` file should have the in-common * The default configuration for the sample must be in the :file:`prj.conf`
configuration options. file and should be operational on all supported platforms. Do not rely on the
* The sample itself can be evaluated using multiple configurations in the sample's YAML file. ``extra_args`` or ``extra_configs`` options in the YAML file to build the
For example, the sample is used to run with different logging modes using multiple scenarios sample.
in ``samples/subsys/logging/syst``. * The tests should verify the default configuration of the sample and any
* Sample output can be validated leveraging the ``harness_config`` regex option, optional features documented in the sample's README file. Sample should
wherever applicable. never be used to test functionality of the subsystem or module the sample
belongs to.
3. Samples should target multiple platforms and architectures. * Any documented configuration options related to the sample and its
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ operation can be verified using ``extra_args`` or
* Minimize the use of ``platform_allow`` and architecture filters as it limits the scope ``extra_configs`` options in the YAML file. The :file:`prj.conf` file should have the
of testing to the mentioned platforms and architectures. base configuration options.
Reference: :ref:`twister_script` * Sample output can be validated by leveraging the ``harness_config`` regex option,
wherever applicable.
* Use ``platform_allow`` to limit test to the platforms the sample was actually
verified on. Those platforms should be listed in the sample's README file.
* Make use of ``integration_platforms`` to limit the scope when there are timing or * Make use of ``integration_platforms`` to limit the scope when there are timing or
resource constraints. resource constraints. Ideally, one platform should be enough to verify the
sample when changes are submitted to the Zephyr tree via a pull-request.
* Make the sample as generic as possible. Avoid making a sample platform specific unless it is * Make the sample as generic as possible. Avoid making a sample platform specific unless it is
for particular hardware. for particular hardware.
4. A sample should provide sufficient coverage of a subsystem, feature, or module. 3. A sample should provide sufficient coverage of a subsystem, feature, or module.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**DO's:** **DO's:**
* Cover the most common and important use cases of the functionality. * Cover the most common and important use cases of the functionality.
@ -78,17 +92,17 @@ Sample Criteria
* Samples must not test the negative or edge case behaviors. * Samples must not test the negative or edge case behaviors.
* Must not be unit tests. * Must not be unit tests.
5. Samples must be documented. 4. Samples must be documented.
++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++
* Samples must have a ``README.rst`` file in the samples folder. * Samples must have a ``README.rst`` file in the samples folder.
Example: ``samples/subsys/foo/README.rst``. clearly explaining the purpose of the sample, its Example: ``samples/subsys/foo/README.rst``. clearly explaining the purpose of the sample, its
HW requirements, and the expected sample output, if applicable. hardware requirements, and the expected sample output, if applicable.
* Ensure that the ``README.rst`` file is accessible in the sample hierarchy starting at * Ensure that the ``README.rst`` file is accessible in the sample hierarchy starting at
``samples/index.rst``. ``samples/index.rst``.
**README Template:** **README Template:**
* Overview, if applicable. * Overview, if applicable.
* SW/HW requirements * Software/Hardware requirements
* Building & Running instructions * Building & Running instructions
* Sample output, if applicable. * Sample output, if applicable.

Loading…
Cancel
Save