From 74794c64f5ceeb1970f09791fd4131ca3719258c Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 5 Jan 2023 12:27:00 +0800 Subject: [PATCH 1/4] ci: fix ci_build_apps.py for linux target --- tools/ci/ci_build_apps.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ci/ci_build_apps.py b/tools/ci/ci_build_apps.py index a012ca1327..a046eea95a 100644 --- a/tools/ci/ci_build_apps.py +++ b/tools/ci/ci_build_apps.py @@ -60,13 +60,17 @@ def get_pytest_apps( LOGGER.info(f'Found {len(app_dirs)} apps') app_dirs.sort() + default_size_json_path = 'size.json' + if target == 'linux': # no idf_size.py for linux target + default_size_json_path = None # type: ignore + apps = find_apps( app_dirs, target=target, build_dir='build_@t_@w', config_rules_str=config_rules_str, build_log_path='build_log.txt', - size_json_path='size.json', + size_json_path=default_size_json_path, check_warnings=True, manifest_files=[str(p) for p in Path(IDF_PATH).glob('**/.build-test-rules.yml')], default_build_targets=SUPPORTED_TARGETS + extra_default_build_targets, From 25d69353315fd3fb0a725590e15b9c08da4c8c62 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Mon, 9 Jan 2023 11:22:15 +0800 Subject: [PATCH 2/4] ci: add parallel count for build jobs --- .gitlab/ci/build.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index 81073e7b1c..fd88b6c113 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -176,7 +176,7 @@ build_pytest_examples_esp32: extends: - .build_pytest_no_jtag_template - .rules:build:example_test-esp32 - parallel: 4 + parallel: 6 variables: IDF_TARGET: esp32 TEST_DIR: examples @@ -203,7 +203,7 @@ build_pytest_examples_esp32c3: extends: - .build_pytest_no_jtag_template - .rules:build:example_test-esp32c3 - parallel: 3 + parallel: 4 variables: IDF_TARGET: esp32c3 TEST_DIR: examples @@ -212,6 +212,7 @@ build_pytest_examples_esp32c2: extends: - .build_pytest_no_jtag_template - .rules:build:example_test-esp32c2 + parallel: 2 variables: IDF_TARGET: esp32c2 TEST_DIR: examples @@ -244,6 +245,7 @@ build_pytest_examples_esp32c6: extends: - .build_pytest_template - .rules:build:example_test-esp32c6 + parallel: 2 variables: IDF_TARGET: esp32c6 TEST_DIR: examples @@ -252,7 +254,7 @@ build_pytest_components_esp32: extends: - .build_pytest_template - .rules:build:component_ut-esp32 - parallel: 2 + parallel: 5 variables: IDF_TARGET: esp32 TEST_DIR: components @@ -261,7 +263,7 @@ build_pytest_components_esp32s2: extends: - .build_pytest_template - .rules:build:component_ut-esp32s2 - parallel: 2 + parallel: 4 variables: IDF_TARGET: esp32s2 TEST_DIR: components @@ -270,7 +272,7 @@ build_pytest_components_esp32s3: extends: - .build_pytest_template - .rules:build:component_ut-esp32s3 - parallel: 2 + parallel: 4 variables: IDF_TARGET: esp32s3 TEST_DIR: components @@ -279,7 +281,7 @@ build_pytest_components_esp32c3: extends: - .build_pytest_template - .rules:build:component_ut-esp32c3 - parallel: 2 + parallel: 4 variables: IDF_TARGET: esp32c3 TEST_DIR: components @@ -288,6 +290,7 @@ build_pytest_components_esp32c2: extends: - .build_pytest_template - .rules:build:component_ut-esp32c2 + parallel: 3 variables: IDF_TARGET: esp32c2 TEST_DIR: components @@ -296,6 +299,7 @@ build_pytest_components_esp32c6: extends: - .build_pytest_template - .rules:build:component_ut-esp32c6 + parallel: 3 variables: IDF_TARGET: esp32c6 TEST_DIR: components @@ -304,7 +308,7 @@ build_non_test_components_apps: extends: - .build_cmake_template - .rules:build:component_ut - parallel: 2 + parallel: 5 script: - set_component_ut_vars # CI specific options start from "--collect-size-info xxx". could ignore when running locally @@ -358,6 +362,7 @@ build_pytest_test_apps_esp32s3: extends: - .build_pytest_test_apps_template - .rules:build:custom_test-esp32s3 + parallel: 2 variables: IDF_TARGET: esp32s3 TEST_DIR: tools/test_apps @@ -519,7 +524,6 @@ build_esp_idf_tests_cmake_esp32: extends: - .build_esp_idf_tests_cmake_template - .rules:build:unit_test-esp32 - parallel: 2 variables: IDF_TARGET: esp32 @@ -527,7 +531,6 @@ build_esp_idf_tests_cmake_esp32s2: extends: - .build_esp_idf_tests_cmake_template - .rules:build:unit_test-esp32s2 - parallel: 2 variables: IDF_TARGET: esp32s2 @@ -563,7 +566,7 @@ build_examples_cmake_esp32: extends: - .build_cmake_template - .rules:build:example_test-esp32 - parallel: 9 + parallel: 8 variables: IDF_TARGET: esp32 TEST_DIR: examples @@ -572,7 +575,7 @@ build_examples_cmake_esp32s2: extends: - .build_cmake_template - .rules:build:example_test-esp32s2 - parallel: 6 + parallel: 7 variables: IDF_TARGET: esp32s2 TEST_DIR: examples @@ -590,7 +593,7 @@ build_examples_cmake_esp32c2: extends: - .build_cmake_template - .rules:build:example_test-esp32c2 - parallel: 4 + parallel: 6 variables: IDF_TARGET: esp32c2 TEST_DIR: examples @@ -616,7 +619,7 @@ build_examples_cmake_esp32c6: extends: - .build_cmake_template - .rules:build:example_test-esp32c6 - parallel: 4 + parallel: 6 variables: IDF_TARGET: esp32c6 TEST_DIR: examples From b02687a6c4fc4d0006d73d770022a5b33639c6ce Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 5 Jan 2023 12:28:47 +0800 Subject: [PATCH 3/4] test: migrate linux target host test jobs into pytest-embedded --- .gitlab/ci/host-test.yml | 142 +++--------------- .../pytest_esp_event_linux.py | 10 ++ .../pytest_esp_hw_support_linux.py | 12 ++ .../pytest_esp_partition_linux.py | 10 ++ .../rom_test/pytest_esp_rom_linux.py | 10 ++ .../pytest_esp_system_linux.py | 12 ++ .../host_test_linux/pytest_heap_linux.py | 12 ++ .../host_test/log_test/pytest_log_linux.py | 10 ++ .../nvs_host_test/pytest_nvs_host_linux.py | 10 ++ .../nvs_page_test/pytest_nvs_page_linux.py | 10 ++ .../spiffs/host_test/pytest_spiffs_linux.py | 10 ++ .../esp_timer/pytest_esp_timer_cxx.py | 10 ++ .../host_test/gpio/pytest_gpio_cxx.py | 10 ++ .../host_test/i2c/pytest_i2c_cxx.py | 10 ++ .../host_test/spi/pytest_spi_cxx.py | 10 ++ .../host_test/system/pytest_system_cxx.py | 10 ++ tools/ci/check_copyright_config.yaml | 2 + tools/ci/exclude_check_tools_files.txt | 1 + tools/ci/ignore_build_warnings_linux.txt | 6 + tools/test_apps/.build-test-rules.yml | 4 - .../pytest_hello_world_linux_compatible.py | 14 +- 21 files changed, 196 insertions(+), 129 deletions(-) create mode 100644 components/esp_event/host_test/esp_event_unit_test/pytest_esp_event_linux.py create mode 100644 components/esp_hw_support/host_test/host_test_linux/pytest_esp_hw_support_linux.py create mode 100644 components/esp_partition/host_test/partition_api_test/pytest_esp_partition_linux.py create mode 100644 components/esp_rom/host_test/rom_test/pytest_esp_rom_linux.py create mode 100644 components/esp_system/host_test/test_esp_system/pytest_esp_system_linux.py create mode 100644 components/heap/host_test/host_test_linux/pytest_heap_linux.py create mode 100644 components/log/host_test/log_test/pytest_log_linux.py create mode 100644 components/nvs_flash/host_test/nvs_host_test/pytest_nvs_host_linux.py create mode 100644 components/nvs_flash/host_test/nvs_page_test/pytest_nvs_page_linux.py create mode 100644 components/spiffs/host_test/pytest_spiffs_linux.py create mode 100644 examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer/pytest_esp_timer_cxx.py create mode 100644 examples/cxx/experimental/experimental_cpp_component/host_test/gpio/pytest_gpio_cxx.py create mode 100644 examples/cxx/experimental/experimental_cpp_component/host_test/i2c/pytest_i2c_cxx.py create mode 100644 examples/cxx/experimental/experimental_cpp_component/host_test/spi/pytest_spi_cxx.py create mode 100644 examples/cxx/experimental/experimental_cpp_component/host_test/system/pytest_system_cxx.py create mode 100644 tools/ci/ignore_build_warnings_linux.txt diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index 218bdb1880..ad2e95eb68 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -20,13 +20,6 @@ test_nvs_on_host: - cd components/nvs_flash/test_nvs_host - make test -test_nvs_on_host_cmake: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/nvs_flash/host_test/nvs_host_test - - idf.py build - - build/nvs_host_test.elf - test_nvs_coverage: extends: - .host_test_template @@ -340,13 +333,6 @@ test_split_path_by_spaces: - cd ${IDF_PATH}/tools - python -m unittest split_paths_by_spaces.py -test_nvs_page: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/nvs_flash/host_test/nvs_page_test - - idf.py build - - build/test_nvs_page_host.elf - test_mqtt_on_host: extends: .host_test_template script: @@ -354,60 +340,6 @@ test_mqtt_on_host: - idf.py build - LSAN_OPTIONS=verbosity=1:log_threads=1 build/host_mqtt_client_test.elf -test_log: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/log/host_test/log_test - - idf.py build - - build/test_log_host.elf - -test_esp_event: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/esp_event/host_test/esp_event_unit_test - - idf.py build - - build/test_esp_event_host.elf - -test_hello_world_linux_compatible_example: - extends: .host_test_template - script: - - cd ${IDF_PATH}/tools/test_apps/linux_compatible/hello_world_linux_compatible - - idf.py --preview set-target linux - - idf.py build - - timeout 15 build/hello_world.elf | tee test.txt - - grep "Hello world!" test.txt - -test_esp_system: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/esp_system/host_test/test_esp_system/ - - idf.py build - - echo "*" | timeout 5 build/test_esp_system.elf | tee log.txt || true - - grep "6 Tests 0 Failures 0 Ignored" log.txt - -test_heap_linux: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/heap/host_test/host_test_linux/ - - idf.py build - - echo "*" | timeout 5 build/test_heap.elf | tee log.txt || true - - grep "4 Tests 0 Failures 0 Ignored" log.txt - -test_esp_hw_support_linux: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/esp_hw_support/host_test/host_test_linux/ - - idf.py build - - echo "*" | timeout 5 build/test_hw_support_linux.elf | tee log.txt || true - - grep "2 Tests 0 Failures 0 Ignored" log.txt - -test_esp_timer_cxx: - extends: .host_test_template - script: - - cd ${IDF_PATH}/examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer - - idf.py build - - build/test_esp_timer_cxx_host.elf - test_eh_frame_parser: extends: .host_test_template script: @@ -415,57 +347,6 @@ test_eh_frame_parser: - make - ./eh_frame_test -test_rom_on_linux_works: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/esp_rom/host_test/rom_test - - idf.py build - - build/test_rom_host.elf - -test_cxx_gpio: - extends: .host_test_template - script: - - cd ${IDF_PATH}/examples/cxx/experimental/experimental_cpp_component/host_test/gpio - - idf.py build - - build/test_gpio_cxx_host.elf - -test_i2c_cxx: - extends: .host_test_template - script: - - cd ${IDF_PATH}/examples/cxx/experimental/experimental_cpp_component/host_test/i2c - - idf.py build - - build/test_i2c_cxx_host.elf - -test_spi_cxx: - extends: .host_test_template - script: - - cd ${IDF_PATH}/examples/cxx/experimental/experimental_cpp_component/host_test/spi - - idf.py build - - build/test_spi_cxx_host.elf - -test_system_cxx: - extends: .host_test_template - script: - - cd ${IDF_PATH}/examples/cxx/experimental/experimental_cpp_component/host_test/system - - idf.py build - - build/test_system_cxx_host.elf - -test_partition_api_host: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/esp_partition/host_test/partition_api_test - - idf.py build - - timeout 5 ./build/partition_api_test.elf | tee test.txt - - grep " 0 Failures" test.txt - -test_spiffs_host: - extends: .host_test_template - script: - - cd ${IDF_PATH}/components/spiffs/host_test - - idf.py build - - timeout 5 ./build/host_test_spiffs.elf | tee test.txt - - grep " 0 Failures" test.txt - test_gen_soc_caps_kconfig: extends: .host_test_template script: @@ -497,3 +378,26 @@ test_pytest_qemu: --embedded-services idf,qemu --junitxml=XUNIT_RESULT.xml --known-failure-cases-file known_failure_cases/known_failure_cases.txt + +test_pytest_linux: + extends: + - .host_test_template + artifacts: + when: always + paths: + - XUNIT_RESULT.xml + - pytest_embedded_log/ + reports: + junit: XUNIT_RESULT.xml + expire_in: 1 week + script: + # TODO: fix the warnings in build flags and ignore-warning-str: IDF-6637 + # Record the warnings regexes in file tools/ci/ignore_build_warnings_linux.txt to avoid using parentheses and + # doublequotes with bash. + # Please remove that file while fixing all the warnings. + - run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -vv + --target linux + --pytest-apps + -m host_test + --ignore-warning-file tools/ci/ignore_build_warnings_linux.txt + - run_cmd pytest --target linux -m host_test --junitxml=XUNIT_RESULT.xml diff --git a/components/esp_event/host_test/esp_event_unit_test/pytest_esp_event_linux.py b/components/esp_event/host_test/esp_event_unit_test/pytest_esp_event_linux.py new file mode 100644 index 0000000000..7b289385f8 --- /dev/null +++ b/components/esp_event/host_test/esp_event_unit_test/pytest_esp_event_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_event_linux(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/components/esp_hw_support/host_test/host_test_linux/pytest_esp_hw_support_linux.py b/components/esp_hw_support/host_test/host_test_linux/pytest_esp_hw_support_linux.py new file mode 100644 index 0000000000..e29da5c94e --- /dev/null +++ b/components/esp_hw_support/host_test/host_test_linux/pytest_esp_hw_support_linux.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_hw_support_linux(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests.') + dut.write('*') + dut.expect_unity_test_output(timeout=5) diff --git a/components/esp_partition/host_test/partition_api_test/pytest_esp_partition_linux.py b/components/esp_partition/host_test/partition_api_test/pytest_esp_partition_linux.py new file mode 100644 index 0000000000..6d3b8a6d5d --- /dev/null +++ b/components/esp_partition/host_test/partition_api_test/pytest_esp_partition_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_partition_linux(dut: Dut) -> None: + dut.expect_unity_test_output(timeout=5) diff --git a/components/esp_rom/host_test/rom_test/pytest_esp_rom_linux.py b/components/esp_rom/host_test/rom_test/pytest_esp_rom_linux.py new file mode 100644 index 0000000000..c9985e1123 --- /dev/null +++ b/components/esp_rom/host_test/rom_test/pytest_esp_rom_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_rom_linux(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/components/esp_system/host_test/test_esp_system/pytest_esp_system_linux.py b/components/esp_system/host_test/test_esp_system/pytest_esp_system_linux.py new file mode 100644 index 0000000000..7b065ec65e --- /dev/null +++ b/components/esp_system/host_test/test_esp_system/pytest_esp_system_linux.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_system_linux(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests.') + dut.write('*') + dut.expect_unity_test_output(timeout=10) diff --git a/components/heap/host_test/host_test_linux/pytest_heap_linux.py b/components/heap/host_test/host_test_linux/pytest_heap_linux.py new file mode 100644 index 0000000000..6ae0bf382f --- /dev/null +++ b/components/heap/host_test/host_test_linux/pytest_heap_linux.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_heap_linux(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests.') + dut.write('*') + dut.expect_unity_test_output(timeout=10) diff --git a/components/log/host_test/log_test/pytest_log_linux.py b/components/log/host_test/log_test/pytest_log_linux.py new file mode 100644 index 0000000000..4f0e2f0155 --- /dev/null +++ b/components/log/host_test/log_test/pytest_log_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_log_linux(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/components/nvs_flash/host_test/nvs_host_test/pytest_nvs_host_linux.py b/components/nvs_flash/host_test/nvs_host_test/pytest_nvs_host_linux.py new file mode 100644 index 0000000000..2f1bdb807b --- /dev/null +++ b/components/nvs_flash/host_test/nvs_host_test/pytest_nvs_host_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_nvs_host_linux(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/components/nvs_flash/host_test/nvs_page_test/pytest_nvs_page_linux.py b/components/nvs_flash/host_test/nvs_page_test/pytest_nvs_page_linux.py new file mode 100644 index 0000000000..811cef7ccf --- /dev/null +++ b/components/nvs_flash/host_test/nvs_page_test/pytest_nvs_page_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_nvs_page_linux(dut: Dut) -> None: + dut.expect_unity_test_output(timeout=10) diff --git a/components/spiffs/host_test/pytest_spiffs_linux.py b/components/spiffs/host_test/pytest_spiffs_linux.py new file mode 100644 index 0000000000..b4719cc5f1 --- /dev/null +++ b/components/spiffs/host_test/pytest_spiffs_linux.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_spiffs_linux(dut: Dut) -> None: + dut.expect_unity_test_output(timeout=5) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer/pytest_esp_timer_cxx.py b/examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer/pytest_esp_timer_cxx.py new file mode 100644 index 0000000000..5ff567d4c3 --- /dev/null +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer/pytest_esp_timer_cxx.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_esp_timer_cxx(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/pytest_gpio_cxx.py b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/pytest_gpio_cxx.py new file mode 100644 index 0000000000..f070954501 --- /dev/null +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/pytest_gpio_cxx.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_gpio_cxx(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/pytest_i2c_cxx.py b/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/pytest_i2c_cxx.py new file mode 100644 index 0000000000..647cd8b631 --- /dev/null +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/pytest_i2c_cxx.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_i2c_cxx(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/spi/pytest_spi_cxx.py b/examples/cxx/experimental/experimental_cpp_component/host_test/spi/pytest_spi_cxx.py new file mode 100644 index 0000000000..93bd4e0cd8 --- /dev/null +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/spi/pytest_spi_cxx.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_spi_cxx(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/system/pytest_system_cxx.py b/examples/cxx/experimental/experimental_cpp_component/host_test/system/pytest_system_cxx.py new file mode 100644 index 0000000000..9166372bee --- /dev/null +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/system/pytest_system_cxx.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.linux +@pytest.mark.host_test +def test_system_cxx(dut: Dut) -> None: + dut.expect_exact('All tests passed', timeout=5) diff --git a/tools/ci/check_copyright_config.yaml b/tools/ci/check_copyright_config.yaml index d3b71ec38d..ff6709e25b 100644 --- a/tools/ci/check_copyright_config.yaml +++ b/tools/ci/check_copyright_config.yaml @@ -53,6 +53,7 @@ examples_and_unit_tests: - 'components/**/test/**' - 'components/**/test_apps/**' - 'tools/test_apps/**' + - '**/pytest_*.py' allowed_licenses: - Apache-2.0 - Unlicense @@ -145,6 +146,7 @@ xtensa: allowed_licenses: - Apache-2.0 #Files added to the xtensa component by us - MIT #Cadence sources + tinyusb: include: - 'examples/peripherals/usb/device/tusb_midi/' diff --git a/tools/ci/exclude_check_tools_files.txt b/tools/ci/exclude_check_tools_files.txt index 7e9aec0a88..3b54e2c58f 100644 --- a/tools/ci/exclude_check_tools_files.txt +++ b/tools/ci/exclude_check_tools_files.txt @@ -25,6 +25,7 @@ tools/ci/fix_empty_prototypes.sh tools/ci/get-full-sources.sh tools/ci/idf_ci_utils.py tools/ci/ignore_build_warnings.txt +tools/ci/ignore_build_warnings_linux.txt tools/ci/mirror-submodule-update.sh tools/ci/multirun_with_pyenv.sh tools/ci/mypy_ignore_list.txt diff --git a/tools/ci/ignore_build_warnings_linux.txt b/tools/ci/ignore_build_warnings_linux.txt new file mode 100644 index 0000000000..76241a5c9d --- /dev/null +++ b/tools/ci/ignore_build_warnings_linux.txt @@ -0,0 +1,6 @@ +the hex symbol ESP_MAIN_TASK_AFFINITY \(defined at .+\) has a non-hex default FREERTOS_NO_AFFINITY \(undefined\) +"CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE" redefined +No function prototypes found! +-Wdeprecated-declarations +-Wno-enum-conversion +-Wunused-result diff --git a/tools/test_apps/.build-test-rules.yml b/tools/test_apps/.build-test-rules.yml index fe260713ce..31979770ef 100644 --- a/tools/test_apps/.build-test-rules.yml +++ b/tools/test_apps/.build-test-rules.yml @@ -20,10 +20,6 @@ tools/test_apps/build_system/rsource_test: tools/test_apps/linux_compatible/hello_world_linux_compatible: enable: - if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux" - disable_test: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - temporary: true - reason: pytest doesn't support linux target yet, hence, it's tested independenly in the host_tests stage tools/test_apps/peripherals/usb: enable: diff --git a/tools/test_apps/linux_compatible/hello_world_linux_compatible/pytest_hello_world_linux_compatible.py b/tools/test_apps/linux_compatible/hello_world_linux_compatible/pytest_hello_world_linux_compatible.py index 08e67cea7a..a73a140314 100644 --- a/tools/test_apps/linux_compatible/hello_world_linux_compatible/pytest_hello_world_linux_compatible.py +++ b/tools/test_apps/linux_compatible/hello_world_linux_compatible/pytest_hello_world_linux_compatible.py @@ -1,15 +1,17 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 import pytest from pytest_embedded_idf.dut import IdfDut -# Note that support for Linux target console applications hasn't been implemented for pytest-embedded yet -# (https://github.com/espressif/pytest-embedded/issues/106) - -@pytest.mark.esp32 -@pytest.mark.esp32c3 +@pytest.mark.supported_targets @pytest.mark.generic def test_hello_world_linux_compatible(dut: IdfDut) -> None: dut.expect('Hello world!') + + +@pytest.mark.linux +@pytest.mark.host_test +def test_hello_world_linux(dut: IdfDut) -> None: + dut.expect('Hello world!') From 51adb9ab27b51e3500831cdc4f39fd22c9225acc Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 10 Jan 2023 14:58:02 +0800 Subject: [PATCH 4/4] test: temp workaround for linux test apps --- conftest.py | 33 ++++++++++++++++++++++++--------- tools/ci/ci_build_apps.py | 7 ++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/conftest.py b/conftest.py index ed152c3f06..2b4a4f0bc2 100644 --- a/conftest.py +++ b/conftest.py @@ -260,15 +260,20 @@ def build_dir(app_path: str, target: Optional[str], config: Optional[str]) -> st Returns: valid build directory """ - - check_dirs = [] - if target is not None and config is not None: - check_dirs.append(f'build_{target}_{config}') - if target is not None: - check_dirs.append(f'build_{target}') - if config is not None: - check_dirs.append(f'build_{config}') - check_dirs.append('build') + if target == 'linux': + # IDF-6644 + # hard-coded in components/esp_partition/partition_linux.c + # const char *partition_table_file_name = "build/partition_table/partition-table.bin"; + check_dirs = ['build'] + else: + check_dirs = [] + if target is not None and config is not None: + check_dirs.append(f'build_{target}_{config}') + if target is not None: + check_dirs.append(f'build_{target}') + if config is not None: + check_dirs.append(f'build_{config}') + check_dirs.append('build') for check_dir in check_dirs: binary_path = os.path.join(app_path, check_dir) @@ -284,6 +289,15 @@ def build_dir(app_path: str, target: Optional[str], config: Optional[str]) -> st ) +@pytest.fixture(autouse=True) +def linux_cd_into_app_folder(app_path: str, target: Optional[str]) -> None: + # IDF-6644 + # hard-coded in components/esp_partition/partition_linux.c + # const char *partition_table_file_name = "build/partition_table/partition-table.bin"; + if target == 'linux': + os.chdir(app_path) + + @pytest.fixture(autouse=True) @multi_dut_fixture def junit_properties(test_case_name: str, record_xml_attribute: Callable[[str, object], None]) -> None: @@ -327,6 +341,7 @@ def check_performance(idf_path: str) -> Callable[[str, float, str], None]: :param target: target chip :raise: AssertionError: if check fails """ + def _find_perf_item(operator: str, path: str) -> float: with open(path, 'r') as f: data = f.read() diff --git a/tools/ci/ci_build_apps.py b/tools/ci/ci_build_apps.py index a046eea95a..754dedb0a4 100644 --- a/tools/ci/ci_build_apps.py +++ b/tools/ci/ci_build_apps.py @@ -61,13 +61,18 @@ def get_pytest_apps( app_dirs.sort() default_size_json_path = 'size.json' + build_dir = 'build_@t_@w' if target == 'linux': # no idf_size.py for linux target default_size_json_path = None # type: ignore + # IDF-6644 + # hard-coded in components/esp_partition/partition_linux.c + # const char *partition_table_file_name = "build/partition_table/partition-table.bin"; + build_dir = 'build' apps = find_apps( app_dirs, target=target, - build_dir='build_@t_@w', + build_dir=build_dir, config_rules_str=config_rules_str, build_log_path='build_log.txt', size_json_path=default_size_json_path,