Skip to content

Commit

Permalink
test: i2c driver tests
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Jun 30, 2024
1 parent e3aa752 commit 130d78e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,27 @@ jobs:
run: pytest test_nvs_flash.py
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

test-i2c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- run: pip install -r test/requirements.txt

- name: Run a Wokwi CI server
uses: wokwi/wokwi-ci-server-action@v1

- name: Install Wokwi CLI
run: curl -L https://wokwi.com/ci/install.sh | sh

- name: Test on Wokwi
working-directory: test
run: pytest test_i2c.py
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
25 changes: 25 additions & 0 deletions test/test_i2c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import subprocess

import pytest


@pytest.mark.parametrize(
"chip", ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6", "esp32h2", "esp32p4"]
)
def test_pcnt(chip: str):

# Run the Wokwi CLI
result = subprocess.run(
[
"wokwi-cli",
"--elf",
f"../bin/{chip}/idf/latest/components/esp_driver_i2c/test_apps/i2c_test_apps/firmware.uf2",
"--timeout",
"5000",
"--scenario",
"test_i2c.scenario.yaml",
"--diagram-file",
f"diagram.{chip}.json",
]
)
assert result.returncode == 0
32 changes: 32 additions & 0 deletions test/test_i2c.scenario.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: I2C Unity Tests
version: 1
author: Uri Shaked

steps:
- wait-serial: 'Press ENTER to see the list of tests'
- write-serial: "2\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "3\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "4\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "5\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "6\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "7\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "8\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "9\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'
- wait-serial: "Enter next test, or 'enter' to see menu"
- write-serial: "10\n"
- wait-serial: '1 Tests 0 Failures 0 Ignored'

0 comments on commit 130d78e

Please sign in to comment.