Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(host test): Refactor host test CI run #80

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build_and_run_host_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Build USB Test Application
- name: Build and Test
shell: bash
run: |
. ${IDF_PATH}/export.sh
pip install pytest pytest-cpp idf-build-apps==2.4.3 --upgrade
pip install pytest idf-build-apps==2.4.3 --upgrade
idf-build-apps find --target linux
idf-build-apps build --target linux
pytest host/class/cdc/usb_host_cdc_acm/host_test/build_linux
chmod +x $GITHUB_WORKSPACE/run_host_tests.sh && $GITHUB_WORKSPACE/run_host_tests.sh
2 changes: 1 addition & 1 deletion device/esp_tinyusb/test_apps/vendor/pytest_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def ep_write(buf):
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.usb_device
def test_usb_device_esp_tinyusb(dut: IdfDut) -> None:
def test_usb_device_vendor(dut: IdfDut) -> None:
'''
Running the test locally:
1. Build the test app for your DUT
Expand Down
28 changes: 0 additions & 28 deletions host/class/cdc/usb_host_cdc_acm/host_test/main/test_main.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[pytest]
# only the files with prefix `pytest_` would be recognized as pytest test scripts.
python_files = pytest_*.py
cpp_files = host_test_*.elf

# set traceback to "short" to prevent the overwhelming tracebacks
addopts =
-s
--embedded-services esp,idf
--tb short

markers =
Expand Down
26 changes: 26 additions & 0 deletions run_host_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Extra arguments for the .elf files, to make the host test results and failures more informative
# (https://github.com/catchorg/Catch2/tree/devel/docs)
EXTRA_ARGS="--reporter Automake --reporter console::out=-::colour-mode=ansi"

# Indicator for the CI job, whether a host test has failed or not
TEST_FAILED=0

## Find all host_test*.elf files
for test_file in $(find . -type f -name "host_test*.elf"); do
echo "Running $test_file..."
"$test_file" $EXTRA_ARGS # Call the host_test*.elf file with the extra arguments
if [ $? -ne 0 ]; then # Check whether the host test failed
TEST_FAILED=1
fi
done

# Return exit value 1 (FAIL) 0 (PASS) to ensure that the CI job passes/fails
if [ $TEST_FAILED -ne 0 ]; then
echo "Some host tests failed."
exit 1
else
echo "All host tests passed."
exit 0
fi
Loading