Skip to content

Commit fbf07ac

Browse files
Merge pull request #80 from espressif/ci/host_test_refactor
refactor(host test): Refactor host test CI run
2 parents 0d5b6e9 + e2394d1 commit fbf07ac

File tree

5 files changed

+31
-33
lines changed

5 files changed

+31
-33
lines changed

.github/workflows/build_and_run_host_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
- uses: actions/checkout@v4
2020
with:
2121
submodules: 'true'
22-
- name: Build USB Test Application
22+
- name: Build and Test
2323
shell: bash
2424
run: |
2525
. ${IDF_PATH}/export.sh
26-
pip install pytest pytest-cpp idf-build-apps==2.4.3 --upgrade
26+
pip install pytest idf-build-apps==2.4.3 --upgrade
2727
idf-build-apps find --target linux
2828
idf-build-apps build --target linux
29-
pytest host/class/cdc/usb_host_cdc_acm/host_test/build_linux
29+
chmod +x $GITHUB_WORKSPACE/run_host_tests.sh && $GITHUB_WORKSPACE/run_host_tests.sh

device/esp_tinyusb/test_apps/vendor/pytest_vendor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def ep_write(buf):
6868
@pytest.mark.esp32s3
6969
@pytest.mark.esp32p4
7070
@pytest.mark.usb_device
71-
def test_usb_device_esp_tinyusb(dut: IdfDut) -> None:
71+
def test_usb_device_vendor(dut: IdfDut) -> None:
7272
'''
7373
Running the test locally:
7474
1. Build the test app for your DUT

host/class/cdc/usb_host_cdc_acm/host_test/main/test_main.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[pytest]
22
# only the files with prefix `pytest_` would be recognized as pytest test scripts.
33
python_files = pytest_*.py
4-
cpp_files = host_test_*.elf
54

65
# set traceback to "short" to prevent the overwhelming tracebacks
76
addopts =
87
-s
8+
--embedded-services esp,idf
99
--tb short
1010

1111
markers =

run_host_tests.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Extra arguments for the .elf files, to make the host test results and failures more informative
4+
# (https://github.com/catchorg/Catch2/tree/devel/docs)
5+
EXTRA_ARGS="--reporter Automake --reporter console::out=-::colour-mode=ansi"
6+
7+
# Indicator for the CI job, whether a host test has failed or not
8+
TEST_FAILED=0
9+
10+
## Find all host_test*.elf files
11+
for test_file in $(find . -type f -name "host_test*.elf"); do
12+
echo "Running $test_file..."
13+
"$test_file" $EXTRA_ARGS # Call the host_test*.elf file with the extra arguments
14+
if [ $? -ne 0 ]; then # Check whether the host test failed
15+
TEST_FAILED=1
16+
fi
17+
done
18+
19+
# Return exit value 1 (FAIL) 0 (PASS) to ensure that the CI job passes/fails
20+
if [ $TEST_FAILED -ne 0 ]; then
21+
echo "Some host tests failed."
22+
exit 1
23+
else
24+
echo "All host tests passed."
25+
exit 0
26+
fi

0 commit comments

Comments
 (0)