Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ function run_test {
fi

if [ $platform == "wokwi" ]; then
extra_args=("--target" "$target" "--embedded-services" "arduino,wokwi" "--wokwi-timeout=$wokwi_timeout")
if [[ -f "$sketchdir/scenario.yaml" ]]; then
extra_args+=("--wokwi-scenario" "$sketchdir/scenario.yaml")
fi
extra_args=("--target" "$target" "--embedded-services" "arduino,wokwi")
if [[ -f "$sketchdir/diagram.$target.json" ]]; then
extra_args+=("--wokwi-diagram" "$sketchdir/diagram.$target.json")
fi
Expand Down Expand Up @@ -137,7 +134,6 @@ SCRIPTS_DIR="./.github/scripts"
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"

platform="hardware"
wokwi_timeout=60000
chunk_run=0
options=0
erase=0
Expand All @@ -156,7 +152,6 @@ while [ -n "$1" ]; do
;;
-W )
shift
wokwi_timeout=$1
if [[ -z $WOKWI_CLI_TOKEN ]]; then
echo "Wokwi CLI token is not set"
exit 1
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/tests_wokwi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
permissions:
contents: read

env:
WOKWI_TIMEOUT: 600000 # Milliseconds

jobs:
get-artifacts:
name: Get required artifacts
Expand Down Expand Up @@ -271,10 +268,6 @@ jobs:
pip install -U pip
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi

- name: Install Wokwi CLI
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: curl -L https://wokwi.com/ci/install.sh | sh

- name: Wokwi CI Server
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: wokwi/wokwi-ci-server-action@a6fabb5a49e080158c7a1d121ea5b789536a82c3 # v1
Expand All @@ -294,7 +287,7 @@ jobs:
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
run: |
bash .github/scripts/tests_run.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }} -i 0 -m 1 -W ${{ env.WOKWI_TIMEOUT }}
bash .github/scripts/tests_run.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }} -i 0 -m 1 -W

- name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
Expand Down
5 changes: 2 additions & 3 deletions docs/en/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ After the test is finished, you can check the output in the terminal and the gen
Additionally, for performance tests, you can check the generated JSON file in the same folder.

You can also run the tests in `Wokwi <https://docs.wokwi.com/>`_ or `Espressif's QEMU <https://github.com/espressif/esp-toolchain-docs/tree/main/qemu>`_
by using the ``-W <timeout_in_ms>`` and ``-Q`` flags respectively. You will need to have the Wokwi and/or QEMU installed in your system
by using the ``-W`` and ``-Q`` flags respectively. You will need to have the Wokwi and/or QEMU installed in your system
and set the ``WOKWI_CLI_TOKEN`` and/or ``QEMU_PATH`` environment variables. The ``WOKWI_CLI_TOKEN`` is the CI token that can be obtained from the
`Wokwi website <https://wokwi.com/dashboard/ci>`_ and the ``QEMU_PATH`` is the path to the QEMU binary.

For example, to run the ``uart`` test using Wokwi, you would run:

.. code-block:: bash

WOKWI_CLI_TOKEN=<your_wokwi_token> ./.github/scripts/tests_run.sh -s uart -t esp32c3 -W <timeout_in_ms>
WOKWI_CLI_TOKEN=<your_wokwi_token> ./.github/scripts/tests_run.sh -s uart -t esp32c3 -W

And to run the ``uart`` test using QEMU, you would run:

Expand All @@ -398,7 +398,6 @@ A test suite contains the following files:
* ``<test_name>.ino``: The sketch that will be tested. Required.
* ``ci.json``: The file that specifies how the test suite will be run in the CI system. Optional.
* ``diagram.<target>.json``: The diagram file that specifies the connections between the components in Wokwi. Optional.
* ``scenario.yaml``: The scenario file that specifies how Wokwi will interact with the components. Optional.
* Any other files that are needed for the test suite.

You can read more about the test python API in the `pytest-embedded documentation <https://docs.espressif.com/projects/pytest-embedded/en/latest/usages/expecting.html>`_.
Expand Down
13 changes: 8 additions & 5 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cryptography==44.0.1
--only-binary cryptography
pytest-cov==5.0.0
pytest-embedded-serial-esp==1.12.0
pytest-embedded-arduino==1.12.0
pytest-embedded-wokwi==1.12.0
pytest-embedded-qemu==1.12.0
esptool==4.8.1

# Temporary dependencies until the Wokwi client and Pytest-Embedded are released
pytest-embedded-serial-esp @ git+https://github.com/JakubAndrysek/pytest-embedded.git@wokwi-python-client#subdirectory=pytest-embedded-serial-esp
pytest-embedded-arduino @ git+https://github.com/JakubAndrysek/pytest-embedded.git@wokwi-python-client#subdirectory=pytest-embedded-arduino
pytest-embedded-wokwi @ git+https://github.com/JakubAndrysek/pytest-embedded.git@wokwi-python-client#subdirectory=pytest-embedded-wokwi
pytest-embedded-qemu @ git+https://github.com/JakubAndrysek/pytest-embedded.git@wokwi-python-client#subdirectory=pytest-embedded-qemu
pytest-embedded @ git+https://github.com/JakubAndrysek/pytest-embedded.git@wokwi-python-client#subdirectory=pytest-embedded
esptool==5.0.2
40 changes: 0 additions & 40 deletions tests/validation/gpio/scenario.yaml

This file was deleted.

17 changes: 9 additions & 8 deletions tests/validation/gpio/test_gpio.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import logging
from pytest_embedded_wokwi import Wokwi
from pytest_embedded import Dut


def test_gpio(dut):
def test_gpio(dut: Dut, wokwi: Wokwi):
LOGGER = logging.getLogger(__name__)

LOGGER.info("Waiting for Button test begin...")
dut.expect_exact("Button test")

LOGGER.info("Expecting button press 1")
dut.expect_exact("Button pressed 1 times")
for i in range(3):
LOGGER.info(f"Setting button pressed for {i + 1} seconds")
wokwi.client.set_control("btn1", "pressed", 1)

LOGGER.info("Expecting button press 2")
dut.expect_exact("Button pressed 2 times")

LOGGER.info("Expecting button press 3")
dut.expect_exact("Button pressed 3 times")
dut.expect_exact(f"Button pressed {i + 1} times")
wokwi.client.set_control("btn1", "pressed", 0)
Loading