Skip to content

Commit f3dddd0

Browse files
committed
docs: addition markers
1 parent 5a5bce0 commit f3dddd0

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

docs/usages/markers.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
##################
2+
Addition Markers
3+
##################
4+
5+
``pytest-embedded`` provides additional markers to enhance testing functionality.
6+
7+
*****************
8+
``skip_if_soc``
9+
*****************
10+
11+
The ``skip_if_soc`` marker allows you to skip tests based on the ``soc_caps`` (system-on-chip capabilities) of a target device. These capabilities are defined in the ``esp-idf``. For example, for the ESP32, you can reference them in the ``soc_caps.h`` file: `soc_caps.h <https://github.com/espressif/esp-idf/blob/master/components/soc/esp32/include/soc/soc_caps.h>`_.
12+
13+
Use Case
14+
========
15+
16+
Imagine you have multiple targets, such as ``[esp32, esp32c3, ..., esp32s4]``. However, you may want to skip tests for chips that do not support specific features.
17+
18+
The ``skip_if_soc`` marker simplifies this by allowing you to define conditions based on the ``soc_caps`` property of your chip. This enables dynamic filtering of targets without the need for manual target-specific logic.
19+
20+
Examples
21+
========
22+
23+
Common Usage
24+
------------
25+
26+
Here’s an example of how you can use ``skip_if_soc`` with different conditions:
27+
28+
#. **Condition 1**. A boolean expression such as: ``SOC_ULP_SUPPORTED != 1 and SOC_UART_NUM != 3`` This skips tests for chips that:
29+
30+
- Do not support the ``low power mode`` feature (``SOC_ULP_SUPPORTED != 1``).
31+
- **And** have a UART number that is not equal to 3 (``SOC_UART_NUM != 3``).
32+
33+
#. **Condition 2**. A boolean expression such as: ``SOC_ULP_SUPPORTED != 1 or SOC_UART_NUM != 3`` This skips tests for chips that:
34+
35+
- Either do not support the ``low power mode`` feature (``SOC_ULP_SUPPORTED != 1``).
36+
- **Or** have a UART number that is not equal to 3 (``SOC_UART_NUM != 3``).
37+
38+
Replace ``{condition_xxx}`` and ``{targets}`` with your values.
39+
40+
.. code:: python
41+
42+
@pytest.mark.skip_if_soc("{condition_one}")
43+
@pytest.mark.parametrize("target", "{targets}", indirect=True)
44+
def test_template_first_condition():
45+
pass
46+
47+
48+
@pytest.mark.skip_if_soc("{condition_two}")
49+
@pytest.mark.parametrize("target", "{targets}", indirect=True)
50+
def test_template_second_condition():
51+
pass
52+
53+
Supported Targets
54+
-----------------
55+
56+
The ``esp_bool_parser`` library provides the ``SUPPORTED_TARGETS`` constant, which contains a list of all supported chips. You can use this constant to dynamically filter targets based on your conditions.
57+
58+
.. code:: python
59+
60+
import pytest
61+
from esp_bool_parser.constants import SUPPORTED_TARGETS
62+
63+
64+
@pytest.mark.skip_if_soc("{condition}")
65+
@pytest.mark.parametrize("target", SUPPORTED_TARGETS, indirect=True)
66+
def test_template():
67+
pass

0 commit comments

Comments
 (0)