From ba235c5615e3209672d035e1a6e39dfc6e054c37 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Tue, 19 Jul 2022 14:19:44 +0800 Subject: [PATCH] ci: add xtal_40mhz tag for c2 tests --- .gitlab/ci/target-test.yml | 6 ++-- conftest.py | 5 ++++ pytest.ini | 1 + tools/ci/check_copyright_ignore.txt | 1 - .../unit-test-app/tools/ConfigDependency.yml | 2 ++ tools/unit-test-app/unit_test.py | 28 +++++++++---------- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index 96ae1804e8..62a98634e7 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -273,7 +273,7 @@ component_ut_pytest_esp32c2_generic: - .rules:test:component_ut-esp32c2 needs: - build_pytest_components_esp32c2 - tags: [ esp32c2, generic ] + tags: [ esp32c2, generic, xtal_40mhz ] component_ut_pytest_esp32c2_xtal_26mhz: extends: @@ -338,7 +338,7 @@ test_app_test_pytest_esp32c2_generic: - .rules:test:custom_test-esp32c2 needs: - build_pytest_test_apps_esp32c2 - tags: [ esp32c2, generic ] + tags: [ esp32c2, generic, xtal_40mhz ] test_app_test_pytest_esp32c3_generic: extends: @@ -652,6 +652,7 @@ test_app_test_esp32c2_generic: tags: - ESP32C2 - Example_GENERIC + - xtal_40mhz test_app_test_005: extends: .test_app_esp32c3_template @@ -920,6 +921,7 @@ UT_C2: tags: - ESP32C2_IDF - UT_T1_1 + - xtal_40mhz UT_C3: extends: .unit_test_esp32c3_template diff --git a/conftest.py b/conftest.py index eeba02fdae..b8f2762c67 100644 --- a/conftest.py +++ b/conftest.py @@ -320,6 +320,11 @@ class IdfPytestEmbedded: for _target in [*SUPPORTED_TARGETS, *PREVIEW_TARGETS]: item.add_marker(_target) + # add 'xtal_40mhz' tag as a default tag for esp32c2 target + for item in items: + if 'esp32c2' in item_marker_names(item) and 'xtal_26mhz' not in item_marker_names(item): + item.add_marker('xtal_40mhz') + # filter all the test cases with "nightly_run" marker if os.getenv('INCLUDE_NIGHTLY_RUN') == '1': # Do not filter nightly_run cases diff --git a/pytest.ini b/pytest.ini index e1043e19f7..497169b9f0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -51,6 +51,7 @@ markers = wifi_high_traffic: wifi high traffic runners wifi_wlan: wifi runner with a wireless NIC xtal_26mhz: runner with 26MHz xtal on board + xtal_40mhz: runner with 40MHz xtal on board external_flash: external flash memory connected via VSPI (FSPI) sdcard_sdmode: sdcard running in SD mode sdcard_spimode: sdcard running in SPI mode diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 40f6d52873..631ba90633 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -2096,4 +2096,3 @@ tools/unit-test-app/idf_ext.py tools/unit-test-app/main/app_main.c tools/unit-test-app/tools/CreateSectionTable.py tools/unit-test-app/tools/UnitTestParser.py -tools/unit-test-app/unit_test.py diff --git a/tools/unit-test-app/tools/ConfigDependency.yml b/tools/unit-test-app/tools/ConfigDependency.yml index 403ca4ad53..5de55f2b8d 100644 --- a/tools/unit-test-app/tools/ConfigDependency.yml +++ b/tools/unit-test-app/tools/ConfigDependency.yml @@ -7,3 +7,5 @@ "ESP32C3_IDF": "CONFIG_IDF_TARGET_ESP32C3=y" "quad_psram": '{CONFIG_SPIRAM_MODE_QUAD=y} and {CONFIG_IDF_TARGET_ESP32S3=y}' "octal_psram": '{CONFIG_SPIRAM_MODE_OCT=y} and {CONFIG_IDF_TARGET_ESP32S3=y}' +"xtal_26mhz": '{CONFIG_ESP32C2_XTAL_FREQ_26=y} and {CONFIG_IDF_TARGET_ESP32C2=y}' +"xtal_40mhz": '{CONFIG_ESP32C2_XTAL_FREQ_40=y} and {CONFIG_IDF_TARGET_ESP32C2=y}' diff --git a/tools/unit-test-app/unit_test.py b/tools/unit-test-app/unit_test.py index 7a69dbd63d..834f263276 100755 --- a/tools/unit-test-app/unit_test.py +++ b/tools/unit-test-app/unit_test.py @@ -1,18 +1,7 @@ #!/usr/bin/env python # -# Copyright 2018 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 """ Test script for unit test case. @@ -307,7 +296,18 @@ def run_unit_test_cases(env, extra_data): for ut_config in case_config: Utility.console_log('Running unit test for config: ' + ut_config, 'O') - dut = env.get_dut('unit-test-app', app_path=UT_APP_PATH, app_config_name=ut_config, allow_dut_exception=True) + + _app = ttfw_idf.UT(app_path=UT_APP_PATH, config_name=ut_config, target=env.default_dut_cls.TARGET) + baud = _app.get_sdkconfig_config_value('CONFIG_ESP_CONSOLE_UART_BAUDRATE') + if baud is None: + baud = 115200 + Utility.console_log('Can\'t find console baudrate in sdkconfig, use 115200 as default') + else: + baud = int(baud, 10) if isinstance(baud, str) else baud + Utility.console_log('Console baudrate is {}'.format(baud)) + + dut = env.get_dut('unit-test-app', app_path=UT_APP_PATH, app_config_name=ut_config, + allow_dut_exception=True, baudrate=baud) if len(case_config[ut_config]) > 0: replace_app_bin(dut, 'unit-test-app', case_config[ut_config][0].get('app_bin')) dut.start_app()