Skip to content

Commit

Permalink
test: uart driver tests
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Jun 30, 2024
1 parent 130d78e commit 5c9d907
Show file tree
Hide file tree
Showing 9 changed files with 176 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 @@ -232,3 +232,27 @@ jobs:
run: pytest test_i2c.py
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

test-uart:
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_uart.py
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
25 changes: 25 additions & 0 deletions test/test_uart.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"]
)
def test_uart(chip: str):

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

steps:
- wait-serial: "Press ENTER to see the list of tests"
- write-serial: "*\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "Waiting for signal: [select to test 'uart' or 'lp_uart' port]!"
- write-serial: "uart\n"
- wait-serial: "7 Tests 0 Failures 0 Ignored"
17 changes: 17 additions & 0 deletions test/uart/diagram.esp32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-devkit-c-v4",
"id": "esp",
"top": 0,
"left": 0,
"attrs": { "__timingOptimizations": "disable" }
}
],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"serialMonitor": { "display": "terminal" },
"dependencies": {}
}
16 changes: 16 additions & 0 deletions test/uart/diagram.esp32c3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-c3-devkitm-1",
"id": "esp",
"top": -0.3,
"left": -42.18,
"attrs": { "__timingOptimizations": "disable" }
}
],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"dependencies": {}
}
16 changes: 16 additions & 0 deletions test/uart/diagram.esp32c6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-c6-devkitc-1",
"id": "esp",
"top": 5.29,
"left": 4.12,
"attrs": { "__timingOptimizations": "disable" }
}
],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions test/uart/diagram.esp32h2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-h2-devkitm-1", "id": "esp", "top": 2.23, "left": -5.1, "attrs": {"__timingOptimizations": "disable"} },
{
"type": "wokwi-slide-potentiometer",
"id": "pot1",
"top": 57.8,
"left": -235.8,
"rotate": 180,
"attrs": { "travelLength": "30", "value": "512" }
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "esp:GND.2", "pot1:GND", "black", [ "h0" ] ],
[ "esp:3V3", "pot1:VCC", "red", [ "v0", "h-19.2", "v105.6" ] ],
[ "esp:4", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
16 changes: 16 additions & 0 deletions test/uart/diagram.esp32s2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-s2-devkitm-1",
"id": "esp",
"top": -13.91,
"left": 4.57,
"attrs": { "__timingOptimizations": "disable" }
}
],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"dependencies": {}
}
16 changes: 16 additions & 0 deletions test/uart/diagram.esp32s3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-s3-devkitc-1",
"id": "esp",
"top": -0.18,
"left": 4.57,
"attrs": { "__timingOptimizations": "disable", "psramSize": "16" }
}
],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"dependencies": {}
}

0 comments on commit 5c9d907

Please sign in to comment.