diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 032d6d41..144f05e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/test/test_i2c.py b/test/test_i2c.py new file mode 100644 index 00000000..18f974c1 --- /dev/null +++ b/test/test_i2c.py @@ -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 diff --git a/test/test_i2c.scenario.yaml b/test/test_i2c.scenario.yaml new file mode 100644 index 00000000..bb0c0747 --- /dev/null +++ b/test/test_i2c.scenario.yaml @@ -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'