diff --git a/.github/workflows/build_and_run_host_test.yml b/.github/workflows/build_and_run_host_test.yml index 89282c8f..ccd18afe 100644 --- a/.github/workflows/build_and_run_host_test.yml +++ b/.github/workflows/build_and_run_host_test.yml @@ -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 diff --git a/device/esp_tinyusb/test_apps/vendor/pytest_vendor.py b/device/esp_tinyusb/test_apps/vendor/pytest_vendor.py index 28b225ab..56b65745 100644 --- a/device/esp_tinyusb/test_apps/vendor/pytest_vendor.py +++ b/device/esp_tinyusb/test_apps/vendor/pytest_vendor.py @@ -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 diff --git a/host/class/cdc/usb_host_cdc_acm/host_test/main/test_main.cpp b/host/class/cdc/usb_host_cdc_acm/host_test/main/test_main.cpp deleted file mode 100644 index c6130ffa..00000000 --- a/host/class/cdc/usb_host_cdc_acm/host_test/main/test_main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - - -extern "C" void app_main(void) -{ - int argc = 1; - const char *argv[2] = { - "target_test_main", - NULL - }; - - auto result = Catch::Session().run(argc, argv); - if (result != 0) { - printf("Test failed with result %d\n", result); - } else { - printf("Test passed.\n"); - } - fflush(stdout); - exit(result); -} diff --git a/pytest.ini b/pytest.ini index dc82314c..1f07f269 100644 --- a/pytest.ini +++ b/pytest.ini @@ -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 = diff --git a/run_host_tests.sh b/run_host_tests.sh new file mode 100755 index 00000000..c31a2c91 --- /dev/null +++ b/run_host_tests.sh @@ -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 \ No newline at end of file