From 759974e1e88ed07184b5d3f11d4556500dfab160 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:24:43 -0300 Subject: [PATCH 01/25] ci(wokwi): Add wokwi emulator to CI --- .github/scripts/tests_run.sh | 20 +++++- .github/workflows/hil.yml | 63 +++++++++++++--- .github/workflows/publish.yml | 2 +- tests/pytest.ini | 2 +- tests/requirements.txt | 1 + tests/wifi/.skip.hardware | 0 tests/wifi/test_wifi.py | 2 + tests/wifi/wifi.ino | 132 ++++++++++++++++++++++++++++++++++ 8 files changed, 209 insertions(+), 13 deletions(-) create mode 100644 tests/wifi/.skip.hardware create mode 100644 tests/wifi/test_wifi.py create mode 100644 tests/wifi/wifi.ino diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh index ef56fcf2d0a..7db1c4e2898 100755 --- a/.github/scripts/tests_run.sh +++ b/.github/scripts/tests_run.sh @@ -8,6 +8,11 @@ function run_test() { local sketchdir=$(dirname $sketch) local sketchname=$(basename $sketchdir) + if [[ -f "$sketchdir/.skip.$platform" ]]; then + echo "Skipping $sketchname test in $target" + exit 0 + fi + if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json` else @@ -33,7 +38,13 @@ function run_test() { report_file="tests/$sketchname/$sketchname$i.xml" fi - pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file + if [ $platform == "wokwi" ]; then + extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout" + else + extra_args="--embedded-services esp,arduino" + fi + + pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args result=$? if [ $result -ne 0 ]; then return $result @@ -44,6 +55,8 @@ function run_test() { SCRIPTS_DIR="./.github/scripts" COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count" +platform="hardware" +wokwi_timeout=60000 chunk_run=0 options=0 erase=0 @@ -53,6 +66,11 @@ while [ ! -z "$1" ]; do -c ) chunk_run=1 ;; + -w ) + shift + wokwi_timeout=$1 + platform="wokwi" + ;; -o ) options=1 ;; diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index bc3afe4193a..6af49441358 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -1,4 +1,4 @@ -name: Run tests in hardware +name: Run tests on: pull_request: @@ -9,6 +9,7 @@ on: env: MAX_CHUNKS: 15 + WOKWI_TIMEOUT: 120000 # Milliseconds concurrency: group: hil-${{github.event.pull_request.number || github.ref}} @@ -16,9 +17,7 @@ concurrency: jobs: gen_chunks: - if: | - contains(github.event.pull_request.labels.*.name, 'hil_test') || - (github.event_name == 'schedule' && github.repository == 'espressif/arduino-esp32') + if: github.repository == 'espressif/arduino-esp32' name: Generate Chunks matrix runs-on: ubuntu-latest outputs: @@ -41,7 +40,7 @@ jobs: CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $((sketches - 1))`) echo "chunks=${CHUNKS}" >>$GITHUB_OUTPUT - Build: + build: needs: gen_chunks name: ${{matrix.chip}}-Build#${{matrix.chunks}} runs-on: ubuntu-latest @@ -63,9 +62,53 @@ jobs: ~/.arduino/tests/*/build*.tmp/*.bin ~/.arduino/tests/*/build*.tmp/*.json if-no-files-found: error - Test: - needs: [gen_chunks, Build] - name: ${{matrix.chip}}-Test#${{matrix.chunks}} + + wokwi-test: + needs: [gen_chunks, build] + name: ${{matrix.chip}}-Wokwi_Test#${{matrix.chunks}} + strategy: + fail-fast: false + matrix: + chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] + chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts + uses: actions/download-artifact@v4 + with: + name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts + path: ~/.arduino/tests/ + + - name: Install Wokwi CLI + run: curl -L https://wokwi.com/ci/install.sh | sh + + - name: Install dependencies + run: | + pip install -U pip + pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi + apt update && apt install -y -qq jq + + - name: Run Tests + env: + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} + run: | + bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}} + + - name: Upload test result artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: wokwi_results-${{matrix.chip}}-${{matrix.chunks}} + path: tests/*/*.xml + + hardware-test: + needs: [gen_chunks, build] + name: ${{matrix.chip}}-Hardware_Test#${{matrix.chunks}} + if: | + contains(github.event.pull_request.labels.*.name, 'hil_test') || github.event_name == 'schedule' strategy: fail-fast: false matrix: @@ -100,7 +143,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: test_results-${{matrix.chip}}-${{matrix.chunks}} + name: hw_results-${{matrix.chip}}-${{matrix.chunks}} path: tests/*/*.xml event_file: @@ -108,7 +151,7 @@ jobs: if: | contains(github.event.pull_request.labels.*.name, 'hil_test') || github.event_name == 'schedule' - needs: Test + needs: hardware-test runs-on: ubuntu-latest steps: - name: Upload diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 34d3564c4a8..026c9d59094 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Unit Test Results on: workflow_run: - workflows: [Run tests in hardware] + workflows: [Run tests] branches-ignore: [master] types: diff --git a/tests/pytest.ini b/tests/pytest.ini index ef7e6d7c5ae..530533b12bf 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --embedded-services esp,arduino +addopts = --embedded-services esp,arduino,wokwi # log related log_cli = True diff --git a/tests/requirements.txt b/tests/requirements.txt index 896699b5752..a909553a5cc 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -3,3 +3,4 @@ cryptography>=2.1.4 pytest-cov pytest-embedded-serial-esp>=1.3.4 pytest-embedded-arduino>=1.3.4 +pytest-embedded-wokwi>=1.3.5 diff --git a/tests/wifi/.skip.hardware b/tests/wifi/.skip.hardware new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/wifi/test_wifi.py b/tests/wifi/test_wifi.py new file mode 100644 index 00000000000..dabb1e2d2ab --- /dev/null +++ b/tests/wifi/test_wifi.py @@ -0,0 +1,2 @@ +def test_wifi(dut): + dut.expect_unity_test_output(timeout=240) diff --git a/tests/wifi/wifi.ino b/tests/wifi/wifi.ino new file mode 100644 index 00000000000..49ce2d2fb92 --- /dev/null +++ b/tests/wifi/wifi.ino @@ -0,0 +1,132 @@ +/* HW Timer test */ +#include + +#define TIMER_FREQUENCY 4000000 +#define TIMER_FREQUENCY_XTAL_CLK 1000 + +/* + * ESP32 - APB clk only (1kHz not possible) + * C3 - APB + XTAL clk + * S2 - APB + XTAL clk + * S3 - APB + XTAL clk + */ + +static hw_timer_t *timer = NULL; +static volatile bool alarm_flag; + +/* setUp / tearDown functions are intended to be called before / after each test. */ +void setUp(void) { + timer = timerBegin(TIMER_FREQUENCY); + if (timer == NULL) { + TEST_FAIL_MESSAGE("Timer init failed in setUp()"); + } + timerStop(timer); + timerRestart(timer); +} + +void tearDown(void) { + timerEnd(timer); +} + +void ARDUINO_ISR_ATTR onTimer() { + alarm_flag = true; +} + +void timer_interrupt_test(void) { + + alarm_flag = false; + timerAttachInterrupt(timer, &onTimer); + timerAlarm(timer, (1.2 * TIMER_FREQUENCY), true, 0); + timerStart(timer); + + delay(2000); + + TEST_ASSERT_EQUAL(true, alarm_flag); + + timerStop(timer); + timerRestart(timer); + alarm_flag = false; + timerDetachInterrupt(timer); + timerStart(timer); + + delay(2000); + TEST_ASSERT_EQUAL(false, alarm_flag); +} + +void timer_divider_test(void) { + + uint64_t time_val; + uint64_t comp_time_val; + + timerStart(timer); + + delay(1000); + time_val = timerRead(timer); + + // compare divider 16 and 8, value should be double + timerEnd(timer); + + timer = timerBegin(2 * TIMER_FREQUENCY); + if (timer == NULL) { + TEST_FAIL_MESSAGE("Timer init failed!"); + } + timerRestart(timer); + delay(1000); + comp_time_val = timerRead(timer); + + TEST_ASSERT_INT_WITHIN(4000, 4000000, time_val); + TEST_ASSERT_INT_WITHIN(8000, 8000000, comp_time_val); + + // divider is 256, value should be 2^4 + timerEnd(timer); + + timer = timerBegin(TIMER_FREQUENCY / 16); + if (timer == NULL) { + TEST_FAIL_MESSAGE("Timer init failed!"); + } + timerRestart(timer); + delay(1000); + comp_time_val = timerRead(timer); + + TEST_ASSERT_INT_WITHIN(4000, 4000000, time_val); + TEST_ASSERT_INT_WITHIN(2500, 250000, comp_time_val); +} + +void timer_read_test(void) { + + uint64_t set_timer_val = 0xFF; + uint64_t get_timer_val = 0; + + timerWrite(timer, set_timer_val); + get_timer_val = timerRead(timer); + + TEST_ASSERT_EQUAL(set_timer_val, get_timer_val); +} + +void timer_clock_select_test(void) { + // Set timer frequency that can be achieved using XTAL clock source (autoselected) + timer = timerBegin(TIMER_FREQUENCY_XTAL_CLK); + + uint32_t resolution = timerGetFrequency(timer); + TEST_ASSERT_EQUAL(TIMER_FREQUENCY_XTAL_CLK, resolution); +} + +void setup() { + + // Open serial communications and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; + } + + UNITY_BEGIN(); + RUN_TEST(timer_read_test); + RUN_TEST(timer_interrupt_test); + RUN_TEST(timer_divider_test); +#if !CONFIG_IDF_TARGET_ESP32 + RUN_TEST(timer_clock_select_test); +#endif + UNITY_END(); +} + +void loop() {} From 1695e79725bea104dcaab91a5c6a32071c06a8db Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:25:51 +0200 Subject: [PATCH 02/25] feat(wokwi): Support scenario --- .github/scripts/tests_run.sh | 3 +++ tests/requirements.txt | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh index 7db1c4e2898..501fc69d3f0 100755 --- a/.github/scripts/tests_run.sh +++ b/.github/scripts/tests_run.sh @@ -40,6 +40,9 @@ function run_test() { 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 else extra_args="--embedded-services esp,arduino" fi diff --git a/tests/requirements.txt b/tests/requirements.txt index a909553a5cc..e00d80e6ae3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,6 +1,6 @@ cryptography>=2.1.4 --only-binary cryptography pytest-cov -pytest-embedded-serial-esp>=1.3.4 -pytest-embedded-arduino>=1.3.4 -pytest-embedded-wokwi>=1.3.5 +pytest-embedded-serial-esp>=1.10.0 +pytest-embedded-arduino>=1.10.0 +pytest-embedded-wokwi>=1.10.0 From 296a9a4147c471bab8245a0353d6f7ce16ac846d Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:26:20 +0200 Subject: [PATCH 03/25] feat(wokwi): Add simple CI test for push button --- tests/gpio/.skip.hardware | 0 tests/gpio/.skip.qemu | 0 tests/gpio/esp32.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/esp32c3.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/esp32c6.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/esp32h2.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/esp32s2.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/esp32s3.diagram.json | 28 ++++++++++++++++++++++ tests/gpio/gpio.ino | 41 +++++++++++++++++++++++++++++++++ tests/gpio/scenario.yaml | 39 +++++++++++++++++++++++++++++++ 10 files changed, 248 insertions(+) create mode 100644 tests/gpio/.skip.hardware create mode 100644 tests/gpio/.skip.qemu create mode 100644 tests/gpio/esp32.diagram.json create mode 100644 tests/gpio/esp32c3.diagram.json create mode 100644 tests/gpio/esp32c6.diagram.json create mode 100644 tests/gpio/esp32h2.diagram.json create mode 100644 tests/gpio/esp32s2.diagram.json create mode 100644 tests/gpio/esp32s3.diagram.json create mode 100644 tests/gpio/gpio.ino create mode 100644 tests/gpio/scenario.yaml diff --git a/tests/gpio/.skip.hardware b/tests/gpio/.skip.hardware new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/gpio/.skip.qemu b/tests/gpio/.skip.qemu new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/gpio/esp32.diagram.json b/tests/gpio/esp32.diagram.json new file mode 100644 index 00000000000..ef4574bffa0 --- /dev/null +++ b/tests/gpio/esp32.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-devkit-c-v4", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -13, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v48", "h-38.4" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/esp32c3.diagram.json b/tests/gpio/esp32c3.diagram.json new file mode 100644 index 00000000000..3404e289c67 --- /dev/null +++ b/tests/gpio/esp32c3.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-c3-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -22.6, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v144", "h-144", "v-95.7" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/esp32c6.diagram.json b/tests/gpio/esp32c6.diagram.json new file mode 100644 index 00000000000..f4156b092ed --- /dev/null +++ b/tests/gpio/esp32c6.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-c6-devkitc-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -22.6, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/esp32h2.diagram.json b/tests/gpio/esp32h2.diagram.json new file mode 100644 index 00000000000..46309019003 --- /dev/null +++ b/tests/gpio/esp32h2.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-h2-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -22.6, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/esp32s2.diagram.json b/tests/gpio/esp32s2.diagram.json new file mode 100644 index 00000000000..9244824fddb --- /dev/null +++ b/tests/gpio/esp32s2.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s2-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -22.6, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v-57.6", "h-144", "v42.71" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/esp32s3.diagram.json b/tests/gpio/esp32s3.diagram.json new file mode 100644 index 00000000000..0709ac1752d --- /dev/null +++ b/tests/gpio/esp32s3.diagram.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "P-R-O-C-H-Y", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s3-devkitc-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -22.6, + "left": -19.2, + "attrs": { "color": "green" } + } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "btn1:1.l", "esp32:0", "blue", [ "h-38.4", "v105.78" ] ], + [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v221", "h-269.2", "v-57.42" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/tests/gpio/gpio.ino b/tests/gpio/gpio.ino new file mode 100644 index 00000000000..006e545b0b3 --- /dev/null +++ b/tests/gpio/gpio.ino @@ -0,0 +1,41 @@ +#include +#include + +#define BTN 0 + +void test_button() +{ + Serial.println("Button test"); + static int count = 0; + static int lastState = HIGH; + while(count < 3) + { + int state = digitalRead(BTN); + if (state != lastState) + { + if (state == LOW) + { + count++; + Serial.print("Button pressed "); + Serial.print(count); + Serial.println(" times"); + } + lastState = state; + } + delay(10); + } + TEST_ASSERT_EQUAL(3, count); +} + +void setup() +{ + Serial.begin(115200); + UNITY_BEGIN(); + pinMode(BTN, INPUT_PULLUP); + RUN_TEST(test_button); + UNITY_END(); +} + +void loop() +{ +} \ No newline at end of file diff --git a/tests/gpio/scenario.yaml b/tests/gpio/scenario.yaml new file mode 100644 index 00000000000..aaaf8952b6c --- /dev/null +++ b/tests/gpio/scenario.yaml @@ -0,0 +1,39 @@ +name: Pushbutton counter test +version: 1 +author: Jan Prochazka (jan.prochazka@espressif.com) + +steps: + - wait-serial: 'Button test' + + # Delay 1s (to make sure the test is ready to start) + - delay: 1000ms + # Press once + - set-control: + part-id: btn1 + control: pressed + value: 1 + - delay: 200ms + - set-control: + part-id: btn1 + control: pressed + value: 0 + - delay: 300ms + + # Press 2nd time + - set-control: + part-id: btn1 + control: pressed + value: 1 + - delay: 200ms + - set-control: + part-id: btn1 + control: pressed + value: 0 + - delay: 300ms + + # Press for the 3rd time + - set-control: + part-id: btn1 + control: pressed + value: 1 + - wait-serial: 'Button pressed 3 times' \ No newline at end of file From 01075458007c9cb4692174cce722ce4cc32adf4d Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:27:53 +0200 Subject: [PATCH 04/25] sudo apt command --- .github/workflows/hil.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 6af49441358..a3b454758cd 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -89,7 +89,7 @@ jobs: run: | pip install -U pip pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi - apt update && apt install -y -qq jq + sudo apt update && apt install -y -qq jq - name: Run Tests env: From 831eab6fa00556fc686b1a62af3cbf0a60d5a8c2 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:40:27 +0200 Subject: [PATCH 05/25] sudo both apt commands --- .github/workflows/hil.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index a3b454758cd..d68c2d099bf 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -89,7 +89,7 @@ jobs: run: | pip install -U pip pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi - sudo apt update && apt install -y -qq jq + sudo apt update && sudo apt install -y -qq jq - name: Run Tests env: From c4d3ad7b97c05c5a5f218d32dbb2b5c78ab8b81c Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:17:53 +0200 Subject: [PATCH 06/25] Add missing test.py file --- tests/gpio/test_gpio.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/gpio/test_gpio.py diff --git a/tests/gpio/test_gpio.py b/tests/gpio/test_gpio.py new file mode 100644 index 00000000000..cebe719889d --- /dev/null +++ b/tests/gpio/test_gpio.py @@ -0,0 +1,2 @@ +def test_gpio(dut): + dut.expect_unity_test_output(timeout=240) From d40d17e8fdb0a623b31e4c7abe5cd45717320552 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 08:50:36 +0200 Subject: [PATCH 07/25] Test pytest path changes --- .github/workflows/hil.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index d68c2d099bf..5fb1157fd67 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -89,6 +89,11 @@ jobs: run: | pip install -U pip pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi + git clone https://github.com/P-R-O-C-H-Y/pytest-embedded.git + cd pytest-embedded + git checkout feature/wokwi-scenario-support + pip install -e pytest-embedded-wokwi + cd .. sudo apt update && sudo apt install -y -qq jq - name: Run Tests From d3d807ce497fc6d791d5da07d7a66b745beb3f80 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:10:34 +0200 Subject: [PATCH 08/25] empty push --- .github/workflows/hil.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 5fb1157fd67..c19446c72eb 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -164,3 +164,4 @@ jobs: with: name: Event File path: ${{github.event_path}} + From f7232477d5e7242cdda524937eb0ac404e885414 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:25:16 +0200 Subject: [PATCH 09/25] move wokwi cli token variable --- .github/workflows/hil.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index c19446c72eb..2f2f2c9e338 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -10,6 +10,7 @@ on: env: MAX_CHUNKS: 15 WOKWI_TIMEOUT: 120000 # Milliseconds + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} concurrency: group: hil-${{github.event.pull_request.number || github.ref}} @@ -97,8 +98,6 @@ jobs: sudo apt update && sudo apt install -y -qq jq - name: Run Tests - env: - WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} run: | bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}} From bddf692ba6a8de2cefab695b8993a8681ff033b1 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:36:14 +0200 Subject: [PATCH 10/25] move token back to wokwi job --- .github/workflows/hil.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 2f2f2c9e338..612ebcf2034 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -98,6 +98,8 @@ jobs: sudo apt update && sudo apt install -y -qq jq - name: Run Tests + env: + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} run: | bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}} From fe20ae0a7bf826552622db352ebd88f8de9d2d26 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:23:43 +0200 Subject: [PATCH 11/25] Update hil.yml --- .github/workflows/hil.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 612ebcf2034..815875ba769 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -1,7 +1,7 @@ name: Run tests on: - pull_request: + pull_request_target: types: [opened, reopened, synchronize, labeled] schedule: @@ -10,7 +10,6 @@ on: env: MAX_CHUNKS: 15 WOKWI_TIMEOUT: 120000 # Milliseconds - WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} concurrency: group: hil-${{github.event.pull_request.number || github.ref}} @@ -18,7 +17,7 @@ concurrency: jobs: gen_chunks: - if: github.repository == 'espressif/arduino-esp32' + if: github.repository == 'espressif/arduino-esp32' || contains(github.event.pull_request.labels.*.name, 'run_tests') name: Generate Chunks matrix runs-on: ubuntu-latest outputs: From 685383b9f5d5b3e10ddfc3e6fa9b8f5d35f36434 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:28:17 +0200 Subject: [PATCH 12/25] Update hil.yml --- .github/workflows/hil.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 815875ba769..56bebecf763 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -25,6 +25,8 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR - name: Generate Chunks matrix id: gen-chunks @@ -51,6 +53,9 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR + - name: Build sketches run: | bash .github/scripts/tests_build.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} From b1cd6459c6122094ecacdfda15c0ebf9b2c1c588 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:30:53 +0200 Subject: [PATCH 13/25] revert run on pr --- .github/workflows/hil.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 56bebecf763..701a1f3196f 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -1,7 +1,7 @@ name: Run tests on: - pull_request_target: + pull_request: types: [opened, reopened, synchronize, labeled] schedule: From 9df5f5f40d82f60343bebb57926a6d25d5fde87e Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:40:18 +0200 Subject: [PATCH 14/25] run on PR target --- .github/workflows/hil.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 701a1f3196f..5c6cb496d86 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -1,7 +1,7 @@ name: Run tests on: - pull_request: + pull_request_target: types: [opened, reopened, synchronize, labeled] schedule: @@ -17,7 +17,9 @@ concurrency: jobs: gen_chunks: - if: github.repository == 'espressif/arduino-esp32' || contains(github.event.pull_request.labels.*.name, 'run_tests') + if: | + github.repository == 'espressif/arduino-esp32' && + ( contains(github.event.pull_request.labels.*.name, 'run_tests') || github.event_name == 'schedule' ) name: Generate Chunks matrix runs-on: ubuntu-latest outputs: From ca039178a53d3e5f750a8e01b5658f83b025ef73 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:43:37 +0200 Subject: [PATCH 15/25] run only on master --- .github/workflows/hil.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 5c6cb496d86..01143a90ce0 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -3,6 +3,8 @@ name: Run tests on: pull_request_target: types: [opened, reopened, synchronize, labeled] + branches: + - master schedule: - cron: '0 2 * * *' From 01752c6411f8f00c95a9d8e5ae5292fec3e62766 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 14:20:26 +0200 Subject: [PATCH 16/25] ci(wokwi): Support wokwi --- .github/workflows/hil.yml | 26 ++-- tests/gpio/test_gpio.py | 2 - tests/{ => validation}/gpio/.skip.hardware | 0 tests/{ => validation}/gpio/.skip.qemu | 0 .../{ => validation}/gpio/esp32.diagram.json | 0 .../gpio/esp32c3.diagram.json | 0 .../gpio/esp32c6.diagram.json | 0 .../gpio/esp32h2.diagram.json | 0 .../gpio/esp32s2.diagram.json | 0 .../gpio/esp32s3.diagram.json | 0 tests/{ => validation}/gpio/gpio.ino | 5 +- tests/{ => validation}/gpio/scenario.yaml | 3 +- tests/validation/gpio/test_gpio.py | 5 + .../wifi/.skip.esp32h2} | 0 tests/validation/wifi/.skip.hardware | 0 tests/validation/wifi/.skip.qemu | 0 tests/validation/wifi/test_wifi.py | 3 + tests/validation/wifi/wifi.ino | 124 ++++++++++++++++ tests/wifi/test_wifi.py | 2 - tests/wifi/wifi.ino | 132 ------------------ 20 files changed, 152 insertions(+), 150 deletions(-) delete mode 100644 tests/gpio/test_gpio.py rename tests/{ => validation}/gpio/.skip.hardware (100%) rename tests/{ => validation}/gpio/.skip.qemu (100%) rename tests/{ => validation}/gpio/esp32.diagram.json (100%) rename tests/{ => validation}/gpio/esp32c3.diagram.json (100%) rename tests/{ => validation}/gpio/esp32c6.diagram.json (100%) rename tests/{ => validation}/gpio/esp32h2.diagram.json (100%) rename tests/{ => validation}/gpio/esp32s2.diagram.json (100%) rename tests/{ => validation}/gpio/esp32s3.diagram.json (100%) rename tests/{ => validation}/gpio/gpio.ino (86%) rename tests/{ => validation}/gpio/scenario.yaml (92%) create mode 100644 tests/validation/gpio/test_gpio.py rename tests/{wifi/.skip.hardware => validation/wifi/.skip.esp32h2} (100%) create mode 100644 tests/validation/wifi/.skip.hardware create mode 100644 tests/validation/wifi/.skip.qemu create mode 100644 tests/validation/wifi/test_wifi.py create mode 100644 tests/validation/wifi/wifi.ino delete mode 100644 tests/wifi/test_wifi.py delete mode 100644 tests/wifi/wifi.ino diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 744134e728b..72dc8365c42 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -1,10 +1,8 @@ name: Run tests on: - pull_request_target: + pull_request: types: [opened, reopened, synchronize, labeled] - branches: - - master schedule: - cron: '0 2 * * *' @@ -12,6 +10,7 @@ on: env: MAX_CHUNKS: 15 WOKWI_TIMEOUT: 120000 # Milliseconds + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} concurrency: group: hil-${{github.event.pull_request.number || github.ref}} @@ -32,8 +31,6 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR - name: Generate Chunks matrix id: gen-chunks @@ -87,10 +84,12 @@ jobs: path: | ~/.build_skipped ~/.arduino/tests/**/build*.tmp/*.bin + ~/.arduino/tests/**/build*.tmp/*.elf ~/.arduino/tests/**/build*.tmp/*.json wokwi-test: needs: [gen_chunks, build] + if: github.event_name == 'schedule' name: ${{matrix.chip}}-Wokwi_Test#${{matrix.chunks}} strategy: fail-fast: false @@ -106,8 +105,8 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts - path: ~/.arduino/tests/ - + path: ~/ + - name: Install Wokwi CLI run: curl -L https://wokwi.com/ci/install.sh | sh @@ -123,12 +122,21 @@ jobs: run: | bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}} + - name: Check if tests were skipped + id: check-test-skipped + run: | + if [ -f ~/.test_skipped ]; then + echo "skipped=true" >> $GITHUB_OUTPUT + else + echo "skipped=false" >> $GITHUB_OUTPUT + fi + - name: Upload test result artifacts uses: actions/upload-artifact@v4 - if: always() + if: ${{ always() && steps.check-test-skipped.outputs.skipped == 'false' }} with: name: wokwi_results-${{matrix.chip}}-${{matrix.chunks}} - path: tests/*/*.xml + path: tests/**/*.xml hardware-test: needs: [gen_chunks, build] diff --git a/tests/gpio/test_gpio.py b/tests/gpio/test_gpio.py deleted file mode 100644 index cebe719889d..00000000000 --- a/tests/gpio/test_gpio.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_gpio(dut): - dut.expect_unity_test_output(timeout=240) diff --git a/tests/gpio/.skip.hardware b/tests/validation/gpio/.skip.hardware similarity index 100% rename from tests/gpio/.skip.hardware rename to tests/validation/gpio/.skip.hardware diff --git a/tests/gpio/.skip.qemu b/tests/validation/gpio/.skip.qemu similarity index 100% rename from tests/gpio/.skip.qemu rename to tests/validation/gpio/.skip.qemu diff --git a/tests/gpio/esp32.diagram.json b/tests/validation/gpio/esp32.diagram.json similarity index 100% rename from tests/gpio/esp32.diagram.json rename to tests/validation/gpio/esp32.diagram.json diff --git a/tests/gpio/esp32c3.diagram.json b/tests/validation/gpio/esp32c3.diagram.json similarity index 100% rename from tests/gpio/esp32c3.diagram.json rename to tests/validation/gpio/esp32c3.diagram.json diff --git a/tests/gpio/esp32c6.diagram.json b/tests/validation/gpio/esp32c6.diagram.json similarity index 100% rename from tests/gpio/esp32c6.diagram.json rename to tests/validation/gpio/esp32c6.diagram.json diff --git a/tests/gpio/esp32h2.diagram.json b/tests/validation/gpio/esp32h2.diagram.json similarity index 100% rename from tests/gpio/esp32h2.diagram.json rename to tests/validation/gpio/esp32h2.diagram.json diff --git a/tests/gpio/esp32s2.diagram.json b/tests/validation/gpio/esp32s2.diagram.json similarity index 100% rename from tests/gpio/esp32s2.diagram.json rename to tests/validation/gpio/esp32s2.diagram.json diff --git a/tests/gpio/esp32s3.diagram.json b/tests/validation/gpio/esp32s3.diagram.json similarity index 100% rename from tests/gpio/esp32s3.diagram.json rename to tests/validation/gpio/esp32s3.diagram.json diff --git a/tests/gpio/gpio.ino b/tests/validation/gpio/gpio.ino similarity index 86% rename from tests/gpio/gpio.ino rename to tests/validation/gpio/gpio.ino index 006e545b0b3..586614e038b 100644 --- a/tests/gpio/gpio.ino +++ b/tests/validation/gpio/gpio.ino @@ -24,16 +24,13 @@ void test_button() } delay(10); } - TEST_ASSERT_EQUAL(3, count); } void setup() { Serial.begin(115200); - UNITY_BEGIN(); pinMode(BTN, INPUT_PULLUP); - RUN_TEST(test_button); - UNITY_END(); + test_button(); } void loop() diff --git a/tests/gpio/scenario.yaml b/tests/validation/gpio/scenario.yaml similarity index 92% rename from tests/gpio/scenario.yaml rename to tests/validation/gpio/scenario.yaml index aaaf8952b6c..2bfa9b2a97d 100644 --- a/tests/gpio/scenario.yaml +++ b/tests/validation/gpio/scenario.yaml @@ -5,8 +5,9 @@ author: Jan Prochazka (jan.prochazka@espressif.com) steps: - wait-serial: 'Button test' - # Delay 1s (to make sure the test is ready to start) + # Need for 1s delay for scenario to run properly - delay: 1000ms + # Press once - set-control: part-id: btn1 diff --git a/tests/validation/gpio/test_gpio.py b/tests/validation/gpio/test_gpio.py new file mode 100644 index 00000000000..e36282561b5 --- /dev/null +++ b/tests/validation/gpio/test_gpio.py @@ -0,0 +1,5 @@ +def test_gpio(dut): + dut.expect_exact("Button test") + dut.expect_exact("Button pressed 1 times") + dut.expect_exact("Button pressed 2 times") + dut.expect_exact("Button pressed 3 times") diff --git a/tests/wifi/.skip.hardware b/tests/validation/wifi/.skip.esp32h2 similarity index 100% rename from tests/wifi/.skip.hardware rename to tests/validation/wifi/.skip.esp32h2 diff --git a/tests/validation/wifi/.skip.hardware b/tests/validation/wifi/.skip.hardware new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/validation/wifi/.skip.qemu b/tests/validation/wifi/.skip.qemu new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/validation/wifi/test_wifi.py b/tests/validation/wifi/test_wifi.py new file mode 100644 index 00000000000..8498246d258 --- /dev/null +++ b/tests/validation/wifi/test_wifi.py @@ -0,0 +1,3 @@ +def test_wifi(dut): + dut.expect_exact("WiFi connected") + dut.expect_exact("IP address:") \ No newline at end of file diff --git a/tests/validation/wifi/wifi.ino b/tests/validation/wifi/wifi.ino new file mode 100644 index 00000000000..3e28f60afcd --- /dev/null +++ b/tests/validation/wifi/wifi.ino @@ -0,0 +1,124 @@ +/* + * This sketch shows the WiFi event usage + * +*/ + +/* +* WiFi Events + +0 ARDUINO_EVENT_WIFI_READY < ESP32 WiFi ready +1 ARDUINO_EVENT_WIFI_SCAN_DONE < ESP32 finish scanning AP +2 ARDUINO_EVENT_WIFI_STA_START < ESP32 station start +3 ARDUINO_EVENT_WIFI_STA_STOP < ESP32 station stop +4 ARDUINO_EVENT_WIFI_STA_CONNECTED < ESP32 station connected to AP +5 ARDUINO_EVENT_WIFI_STA_DISCONNECTED < ESP32 station disconnected from AP +6 ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed +7 ARDUINO_EVENT_WIFI_STA_GOT_IP < ESP32 station got IP from connected AP +8 ARDUINO_EVENT_WIFI_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 +9 ARDUINO_EVENT_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode +10 ARDUINO_EVENT_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode +11 ARDUINO_EVENT_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode +12 ARDUINO_EVENT_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode +13 ARDUINO_EVENT_WIFI_AP_START < ESP32 soft-AP start +14 ARDUINO_EVENT_WIFI_AP_STOP < ESP32 soft-AP stop +15 ARDUINO_EVENT_WIFI_AP_STACONNECTED < a station connected to ESP32 soft-AP +16 ARDUINO_EVENT_WIFI_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP +17 ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station +18 ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface +19 ARDUINO_EVENT_WIFI_AP_GOT_IP6 < ESP32 ap interface v6IP addr is preferred +19 ARDUINO_EVENT_WIFI_STA_GOT_IP6 < ESP32 station interface v6IP addr is preferred +20 ARDUINO_EVENT_ETH_START < ESP32 ethernet start +21 ARDUINO_EVENT_ETH_STOP < ESP32 ethernet stop +22 ARDUINO_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up +23 ARDUINO_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down +24 ARDUINO_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP +19 ARDUINO_EVENT_ETH_GOT_IP6 < ESP32 ethernet interface v6IP addr is preferred +25 ARDUINO_EVENT_MAX +*/ + +#include + +const char *ssid = "Wokwi-GUEST"; +const char *password = ""; + +// WARNING: This function is called from a separate FreeRTOS task (thread)! +void WiFiEvent(WiFiEvent_t event) { + Serial.printf("[WiFi-event] event: %d\n", event); + + switch (event) { + case ARDUINO_EVENT_WIFI_READY: Serial.println("WiFi interface ready"); break; + case ARDUINO_EVENT_WIFI_SCAN_DONE: Serial.println("Completed scan for access points"); break; + case ARDUINO_EVENT_WIFI_STA_START: Serial.println("WiFi client started"); break; + case ARDUINO_EVENT_WIFI_STA_STOP: Serial.println("WiFi clients stopped"); break; + case ARDUINO_EVENT_WIFI_STA_CONNECTED: Serial.println("Connected to access point"); break; + case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: Serial.println("Disconnected from WiFi access point"); break; + case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE: Serial.println("Authentication mode of access point has changed"); break; + case ARDUINO_EVENT_WIFI_STA_GOT_IP: + Serial.print("Obtained IP address: "); + Serial.println(WiFi.localIP()); + break; + case ARDUINO_EVENT_WIFI_STA_LOST_IP: Serial.println("Lost IP address and IP address is reset to 0"); break; + case ARDUINO_EVENT_WPS_ER_SUCCESS: Serial.println("WiFi Protected Setup (WPS): succeeded in enrollee mode"); break; + case ARDUINO_EVENT_WPS_ER_FAILED: Serial.println("WiFi Protected Setup (WPS): failed in enrollee mode"); break; + case ARDUINO_EVENT_WPS_ER_TIMEOUT: Serial.println("WiFi Protected Setup (WPS): timeout in enrollee mode"); break; + case ARDUINO_EVENT_WPS_ER_PIN: Serial.println("WiFi Protected Setup (WPS): pin code in enrollee mode"); break; + case ARDUINO_EVENT_WIFI_AP_START: Serial.println("WiFi access point started"); break; + case ARDUINO_EVENT_WIFI_AP_STOP: Serial.println("WiFi access point stopped"); break; + case ARDUINO_EVENT_WIFI_AP_STACONNECTED: Serial.println("Client connected"); break; + case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED: Serial.println("Client disconnected"); break; + case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED: Serial.println("Assigned IP address to client"); break; + case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED: Serial.println("Received probe request"); break; + case ARDUINO_EVENT_WIFI_AP_GOT_IP6: Serial.println("AP IPv6 is preferred"); break; + case ARDUINO_EVENT_WIFI_STA_GOT_IP6: Serial.println("STA IPv6 is preferred"); break; + case ARDUINO_EVENT_ETH_GOT_IP6: Serial.println("Ethernet IPv6 is preferred"); break; + case ARDUINO_EVENT_ETH_START: Serial.println("Ethernet started"); break; + case ARDUINO_EVENT_ETH_STOP: Serial.println("Ethernet stopped"); break; + case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("Ethernet connected"); break; + case ARDUINO_EVENT_ETH_DISCONNECTED: Serial.println("Ethernet disconnected"); break; + case ARDUINO_EVENT_ETH_GOT_IP: Serial.println("Obtained IP address"); break; + default: break; + } +} + +// WARNING: This function is called from a separate FreeRTOS task (thread)! +void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) { + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(IPAddress(info.got_ip.ip_info.ip.addr)); +} + +void setup() { + Serial.begin(115200); + + // delete old config + WiFi.disconnect(true); + + delay(1000); + + // Examples of different ways to register wifi events; + // these handlers will be called from another thread. + WiFi.onEvent(WiFiEvent); + WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP); + WiFiEventId_t eventID = WiFi.onEvent( + [](WiFiEvent_t event, WiFiEventInfo_t info) { + Serial.print("WiFi lost connection. Reason: "); + Serial.println(info.wifi_sta_disconnected.reason); + }, + WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED + ); + + // Remove WiFi event + Serial.print("WiFi Event ID: "); + Serial.println(eventID); + // WiFi.removeEvent(eventID); + + WiFi.begin(ssid, password); + + Serial.println(); + Serial.println(); + Serial.println("Wait for WiFi... "); +} + +void loop() { + delay(1000); +} \ No newline at end of file diff --git a/tests/wifi/test_wifi.py b/tests/wifi/test_wifi.py deleted file mode 100644 index dabb1e2d2ab..00000000000 --- a/tests/wifi/test_wifi.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_wifi(dut): - dut.expect_unity_test_output(timeout=240) diff --git a/tests/wifi/wifi.ino b/tests/wifi/wifi.ino deleted file mode 100644 index 49ce2d2fb92..00000000000 --- a/tests/wifi/wifi.ino +++ /dev/null @@ -1,132 +0,0 @@ -/* HW Timer test */ -#include - -#define TIMER_FREQUENCY 4000000 -#define TIMER_FREQUENCY_XTAL_CLK 1000 - -/* - * ESP32 - APB clk only (1kHz not possible) - * C3 - APB + XTAL clk - * S2 - APB + XTAL clk - * S3 - APB + XTAL clk - */ - -static hw_timer_t *timer = NULL; -static volatile bool alarm_flag; - -/* setUp / tearDown functions are intended to be called before / after each test. */ -void setUp(void) { - timer = timerBegin(TIMER_FREQUENCY); - if (timer == NULL) { - TEST_FAIL_MESSAGE("Timer init failed in setUp()"); - } - timerStop(timer); - timerRestart(timer); -} - -void tearDown(void) { - timerEnd(timer); -} - -void ARDUINO_ISR_ATTR onTimer() { - alarm_flag = true; -} - -void timer_interrupt_test(void) { - - alarm_flag = false; - timerAttachInterrupt(timer, &onTimer); - timerAlarm(timer, (1.2 * TIMER_FREQUENCY), true, 0); - timerStart(timer); - - delay(2000); - - TEST_ASSERT_EQUAL(true, alarm_flag); - - timerStop(timer); - timerRestart(timer); - alarm_flag = false; - timerDetachInterrupt(timer); - timerStart(timer); - - delay(2000); - TEST_ASSERT_EQUAL(false, alarm_flag); -} - -void timer_divider_test(void) { - - uint64_t time_val; - uint64_t comp_time_val; - - timerStart(timer); - - delay(1000); - time_val = timerRead(timer); - - // compare divider 16 and 8, value should be double - timerEnd(timer); - - timer = timerBegin(2 * TIMER_FREQUENCY); - if (timer == NULL) { - TEST_FAIL_MESSAGE("Timer init failed!"); - } - timerRestart(timer); - delay(1000); - comp_time_val = timerRead(timer); - - TEST_ASSERT_INT_WITHIN(4000, 4000000, time_val); - TEST_ASSERT_INT_WITHIN(8000, 8000000, comp_time_val); - - // divider is 256, value should be 2^4 - timerEnd(timer); - - timer = timerBegin(TIMER_FREQUENCY / 16); - if (timer == NULL) { - TEST_FAIL_MESSAGE("Timer init failed!"); - } - timerRestart(timer); - delay(1000); - comp_time_val = timerRead(timer); - - TEST_ASSERT_INT_WITHIN(4000, 4000000, time_val); - TEST_ASSERT_INT_WITHIN(2500, 250000, comp_time_val); -} - -void timer_read_test(void) { - - uint64_t set_timer_val = 0xFF; - uint64_t get_timer_val = 0; - - timerWrite(timer, set_timer_val); - get_timer_val = timerRead(timer); - - TEST_ASSERT_EQUAL(set_timer_val, get_timer_val); -} - -void timer_clock_select_test(void) { - // Set timer frequency that can be achieved using XTAL clock source (autoselected) - timer = timerBegin(TIMER_FREQUENCY_XTAL_CLK); - - uint32_t resolution = timerGetFrequency(timer); - TEST_ASSERT_EQUAL(TIMER_FREQUENCY_XTAL_CLK, resolution); -} - -void setup() { - - // Open serial communications and wait for port to open: - Serial.begin(115200); - while (!Serial) { - ; - } - - UNITY_BEGIN(); - RUN_TEST(timer_read_test); - RUN_TEST(timer_interrupt_test); - RUN_TEST(timer_divider_test); -#if !CONFIG_IDF_TARGET_ESP32 - RUN_TEST(timer_clock_select_test); -#endif - UNITY_END(); -} - -void loop() {} From 186e17e401d2a335ea9c3aabb09ab168db16f76b Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 14:40:21 +0200 Subject: [PATCH 17/25] ci(wokwi): Skip unsupported and performance test --- tests/performance/coremark/.skip.wokwi | 0 tests/performance/fibonacci/.skip.wokwi | 0 tests/performance/psramspeed/.skip.wokwi | 0 tests/performance/ramspeed/.skip.wokwi | 0 tests/performance/superpi/.skip.wokwi | 0 tests/validation/nvs/test_nvs.py | 3 --- tests/validation/periman/.skip.wokwi | 0 tests/validation/touch/.skip.wokwi | 0 tests/validation/uart/.skip.wokwi | 0 9 files changed, 3 deletions(-) create mode 100644 tests/performance/coremark/.skip.wokwi create mode 100644 tests/performance/fibonacci/.skip.wokwi create mode 100644 tests/performance/psramspeed/.skip.wokwi create mode 100644 tests/performance/ramspeed/.skip.wokwi create mode 100644 tests/performance/superpi/.skip.wokwi create mode 100644 tests/validation/periman/.skip.wokwi create mode 100644 tests/validation/touch/.skip.wokwi create mode 100644 tests/validation/uart/.skip.wokwi diff --git a/tests/performance/coremark/.skip.wokwi b/tests/performance/coremark/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/performance/fibonacci/.skip.wokwi b/tests/performance/fibonacci/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/performance/psramspeed/.skip.wokwi b/tests/performance/psramspeed/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/performance/ramspeed/.skip.wokwi b/tests/performance/ramspeed/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/performance/superpi/.skip.wokwi b/tests/performance/superpi/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/validation/nvs/test_nvs.py b/tests/validation/nvs/test_nvs.py index d46db220434..e40549971be 100644 --- a/tests/validation/nvs/test_nvs.py +++ b/tests/validation/nvs/test_nvs.py @@ -2,6 +2,3 @@ def test_nvs(dut): dut.expect("Current counter value: 0") dut.expect("Current counter value: 1") dut.expect("Current counter value: 2") - dut.expect("Current counter value: 3") - dut.expect("Current counter value: 4") - dut.expect("Current counter value: 5") diff --git a/tests/validation/periman/.skip.wokwi b/tests/validation/periman/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/validation/touch/.skip.wokwi b/tests/validation/touch/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/validation/uart/.skip.wokwi b/tests/validation/uart/.skip.wokwi new file mode 100644 index 00000000000..e69de29bb2d From b1c714dedfef1d7937667ad37bae66708726adab Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 14:43:08 +0200 Subject: [PATCH 18/25] ci(wokwi): run wokwi tests without label --- .github/workflows/hil.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 72dc8365c42..65e218d73d2 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -19,8 +19,7 @@ concurrency: jobs: gen_chunks: if: | - contains(github.event.pull_request.labels.*.name, 'hil_test') || - contains(github.event.pull_request.labels.*.name, 'perf_test') || + github.event_name == 'pull_request' || (github.event_name == 'schedule' && github.repository == 'espressif/arduino-esp32') name: Generate Chunks matrix runs-on: ubuntu-latest From bc085e50502eb470836276097fa45ee0e2374ed1 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 16:08:04 +0200 Subject: [PATCH 19/25] debug: run build on windows --- .github/workflows/hil.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 65e218d73d2..040c5a0bfa3 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -62,7 +62,7 @@ jobs: build: needs: gen_chunks name: ${{matrix.chip}}-Build#${{matrix.chunks}} - runs-on: ubuntu-latest + runs-on: windows-latest strategy: matrix: chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] From 99af207858591ad72c6d9ad53d722f54d0d36376 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 16:23:28 +0200 Subject: [PATCH 20/25] RUN WIFI WITH PSRAM ON-OFF --- tests/validation/wifi/cfg.json | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/validation/wifi/cfg.json diff --git a/tests/validation/wifi/cfg.json b/tests/validation/wifi/cfg.json new file mode 100644 index 00000000000..dbaed6f7bd2 --- /dev/null +++ b/tests/validation/wifi/cfg.json @@ -0,0 +1,44 @@ +{ + "targets": [ + { + "name": "esp32", + "fqbn":[ + "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32:PSRAM=disabled,PartitionScheme=huge_app,FlashMode=qio" + ] + }, + { + "name": "esp32s2", + "fqbn": [ + "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32s2:PSRAM=disabled,PartitionScheme=huge_app,FlashMode=dio" + ] + }, + { + "name": "esp32c3", + "fqbn": [ + "espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=dio" + ] + }, + { + "name": "esp32s3", + "fqbn": [ + "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32s3:PSRAM=disabled,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32s3:PSRAM=qspi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio" + ] + }, + { + "name": "esp32c6", + "fqbn": [ + "espressif:esp32:esp32c6:PartitionScheme=huge_app,FlashMode=dio" + ] + }, + { + "name": "esp32h2", + "fqbn": [ + "espressif:esp32:esp32h2:PartitionScheme=huge_app,FlashMode=dio" + ] + } + ] +} From 9ccead06dbcd5493269ad5b1aead78b5c26c2d37 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 16:37:11 +0200 Subject: [PATCH 21/25] fix psram for S3 --- tests/validation/wifi/cfg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validation/wifi/cfg.json b/tests/validation/wifi/cfg.json index dbaed6f7bd2..aa00bcf5ded 100644 --- a/tests/validation/wifi/cfg.json +++ b/tests/validation/wifi/cfg.json @@ -25,7 +25,7 @@ "fqbn": [ "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", "espressif:esp32:esp32s3:PSRAM=disabled,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", - "espressif:esp32:esp32s3:PSRAM=qspi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio" + "espressif:esp32:esp32s3:PSRAM=enabled,USBMode=default,PartitionScheme=huge_app,FlashMode=qio" ] }, { From 71fe262c48b5f11730207db1916c663f9b653cd4 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 16:37:21 +0200 Subject: [PATCH 22/25] Revert "debug: run build on windows" This reverts commit bc085e50502eb470836276097fa45ee0e2374ed1. --- .github/workflows/hil.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 040c5a0bfa3..65e218d73d2 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -62,7 +62,7 @@ jobs: build: needs: gen_chunks name: ${{matrix.chip}}-Build#${{matrix.chunks}} - runs-on: windows-latest + runs-on: ubuntu-latest strategy: matrix: chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] From 9cdd132e9e3114e3ec00f1a9b3b1bfcc26612a64 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Tue, 7 May 2024 16:38:26 +0200 Subject: [PATCH 23/25] ci(wokwi): Run workflow only if build was sucessful --- .github/workflows/wokwi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wokwi.yml b/.github/workflows/wokwi.yml index c4f3ec2ff66..5ed28560313 100644 --- a/.github/workflows/wokwi.yml +++ b/.github/workflows/wokwi.yml @@ -21,7 +21,7 @@ concurrency: jobs: gen_chunks: - if: github.event.workflow_run.event == 'pull_request' + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' name: Generate Chunks matrix runs-on: ubuntu-latest outputs: From 6f4880c92ed26c85ba3c3a6822aacf604d2e36dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 14:45:42 +0000 Subject: [PATCH 24/25] ci(pre-commit): Apply automatic fixes --- tests/validation/gpio/esp32.diagram.json | 2 +- tests/validation/gpio/esp32c3.diagram.json | 2 +- tests/validation/gpio/esp32c6.diagram.json | 2 +- tests/validation/gpio/esp32h2.diagram.json | 2 +- tests/validation/gpio/esp32s2.diagram.json | 2 +- tests/validation/gpio/esp32s3.diagram.json | 2 +- tests/validation/gpio/gpio.ino | 23 ++++++++-------------- tests/validation/gpio/scenario.yaml | 4 ++-- tests/validation/wifi/test_wifi.py | 2 +- tests/validation/wifi/wifi.ino | 2 +- 10 files changed, 18 insertions(+), 25 deletions(-) diff --git a/tests/validation/gpio/esp32.diagram.json b/tests/validation/gpio/esp32.diagram.json index ef4574bffa0..05b28156e37 100644 --- a/tests/validation/gpio/esp32.diagram.json +++ b/tests/validation/gpio/esp32.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/esp32c3.diagram.json b/tests/validation/gpio/esp32c3.diagram.json index 3404e289c67..c237e089ea2 100644 --- a/tests/validation/gpio/esp32c3.diagram.json +++ b/tests/validation/gpio/esp32c3.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/esp32c6.diagram.json b/tests/validation/gpio/esp32c6.diagram.json index f4156b092ed..5020171f4e6 100644 --- a/tests/validation/gpio/esp32c6.diagram.json +++ b/tests/validation/gpio/esp32c6.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/esp32h2.diagram.json b/tests/validation/gpio/esp32h2.diagram.json index 46309019003..48189dcea9f 100644 --- a/tests/validation/gpio/esp32h2.diagram.json +++ b/tests/validation/gpio/esp32h2.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/esp32s2.diagram.json b/tests/validation/gpio/esp32s2.diagram.json index 9244824fddb..e3f850e193e 100644 --- a/tests/validation/gpio/esp32s2.diagram.json +++ b/tests/validation/gpio/esp32s2.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/esp32s3.diagram.json b/tests/validation/gpio/esp32s3.diagram.json index 0709ac1752d..ad9f9e0308a 100644 --- a/tests/validation/gpio/esp32s3.diagram.json +++ b/tests/validation/gpio/esp32s3.diagram.json @@ -25,4 +25,4 @@ [ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v221", "h-269.2", "v-57.42" ] ] ], "dependencies": {} -} \ No newline at end of file +} diff --git a/tests/validation/gpio/gpio.ino b/tests/validation/gpio/gpio.ino index 586614e038b..a5bec1cb5a3 100644 --- a/tests/validation/gpio/gpio.ino +++ b/tests/validation/gpio/gpio.ino @@ -3,36 +3,29 @@ #define BTN 0 -void test_button() -{ +void test_button() { Serial.println("Button test"); static int count = 0; static int lastState = HIGH; - while(count < 3) - { + while (count < 3) { int state = digitalRead(BTN); - if (state != lastState) - { - if (state == LOW) - { + if (state != lastState) { + if (state == LOW) { count++; Serial.print("Button pressed "); Serial.print(count); Serial.println(" times"); - } - lastState = state; + } + lastState = state; } delay(10); } } -void setup() -{ +void setup() { Serial.begin(115200); pinMode(BTN, INPUT_PULLUP); test_button(); } -void loop() -{ -} \ No newline at end of file +void loop() {} diff --git a/tests/validation/gpio/scenario.yaml b/tests/validation/gpio/scenario.yaml index 2bfa9b2a97d..a915b546b49 100644 --- a/tests/validation/gpio/scenario.yaml +++ b/tests/validation/gpio/scenario.yaml @@ -3,7 +3,7 @@ version: 1 author: Jan Prochazka (jan.prochazka@espressif.com) steps: - - wait-serial: 'Button test' + - wait-serial: "Button test" # Need for 1s delay for scenario to run properly - delay: 1000ms @@ -37,4 +37,4 @@ steps: part-id: btn1 control: pressed value: 1 - - wait-serial: 'Button pressed 3 times' \ No newline at end of file + - wait-serial: "Button pressed 3 times" diff --git a/tests/validation/wifi/test_wifi.py b/tests/validation/wifi/test_wifi.py index 8498246d258..aa074192341 100644 --- a/tests/validation/wifi/test_wifi.py +++ b/tests/validation/wifi/test_wifi.py @@ -1,3 +1,3 @@ def test_wifi(dut): dut.expect_exact("WiFi connected") - dut.expect_exact("IP address:") \ No newline at end of file + dut.expect_exact("IP address:") diff --git a/tests/validation/wifi/wifi.ino b/tests/validation/wifi/wifi.ino index 3e28f60afcd..dd93ac137f9 100644 --- a/tests/validation/wifi/wifi.ino +++ b/tests/validation/wifi/wifi.ino @@ -121,4 +121,4 @@ void setup() { void loop() { delay(1000); -} \ No newline at end of file +} From ba3a5492366d35f00cf41371416808183abd8d0c Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Tue, 7 May 2024 16:58:13 +0200 Subject: [PATCH 25/25] ci(wokwi): Add generated files to gitignore --- tests/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/.gitignore b/tests/.gitignore index 4b548d27073..fc427d51090 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -2,3 +2,5 @@ build*/ __pycache__/ *.xml result_*.json +diagram.json +wokwi.toml