From 190af4c3f362cf1f0bdb0d154332c2419329510f Mon Sep 17 00:00:00 2001 From: liyashuai Date: Wed, 24 Apr 2024 10:31:06 +0800 Subject: [PATCH] add esp32c2 pytest --- .gitlab-ci.yml | 33 ++++++++++++++++++++++ examples/pytest_esp_matter_light.py | 43 +++++++++++++++++++++++++++-- pytest.ini | 3 +- tools/ci/build_apps.py | 22 ++++++++++++++- 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b0ab35bf..47c702a94 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -230,6 +230,28 @@ build_esp_matter_examples_pytest_H2_idf_v5_1: - pip install -r tools/ci/requirements-build.txt - python tools/ci/build_apps.py ./examples --pytest_h2 +build_esp_matter_examples_pytest_C2_idf_v5_1: + extends: + - .build_examples_template + artifacts: + paths: + - "examples/**/build*/size.json" + - "examples/**/build*/build_log.txt" + - "examples/**/build*/*.bin" + - "examples/**/build*/flasher_args.json" + - "examples/**/build*/config/sdkconfig.json" + - "examples/**/build*/bootloader/*.bin" + - "examples/**/build*/partition_table/*.bin" + - "connectedhomeip/connectedhomeip/out/host/chip-tool" + when: always + expire_in: 4 days + variables: + IDF_VERSION: "v5.2.1" + script: + - cd ${ESP_MATTER_PATH} + - pip install -r tools/ci/requirements-build.txt + - python tools/ci/build_apps.py ./examples --pytest_c2 + build_esp_matter_examples_non_pytest_idf_v5_1: extends: - .build_examples_template @@ -307,6 +329,17 @@ pytest_esp32c6_esp_matter_dut: - pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml tags: ["esp32c6", "esp_matter_dut"] +pytest_esp32c2_esp_matter_dut: + stage: target_test + image: ${TARGET_TEST_ENV} + needs: + - build_esp_matter_examples_pytest_C2_idf_v5_1 + script: + - cd ${ESP_MATTER_PATH} + - pip install -r tools/ci/requirements-pytest.txt + - pytest examples/ --target esp32c2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml + tags: ["esp32c2", "esp_matter_dut"] + pytest_esp32h2_esp_matter_dut: stage: target_test image: ${TARGET_TEST_ENV} diff --git a/examples/pytest_esp_matter_light.py b/examples/pytest_esp_matter_light.py index 62ea652c3..0dffbead1 100644 --- a/examples/pytest_esp_matter_light.py +++ b/examples/pytest_esp_matter_light.py @@ -54,7 +54,46 @@ def test_matter_commissioning_c3(dut:Dut) -> None: print(out_str) result = re.findall(r'Run command failure', str(out_str)) if len(result) != 0: - assert False + assert False + +@pytest.mark.esp32c2 +@pytest.mark.esp_matter_dut +@pytest.mark.parametrize( + ' count, app_path, target, erase_all', [ + ( 1, pytest_build_dir, 'esp32c2', 'y'), + ], + indirect=True, +) + +# Matter over wifi commissioning +def test_matter_commissioning_c2(dut:Dut) -> None: + light = dut + # BLE start advertising + light.expect(r'chip\[DL\]\: Configuring CHIPoBLE advertising', timeout=20) + # Start commissioning + time.sleep(5) + command = CHIP_TOOL_EXE + ' pairing ble-wifi 1 ChipTEH2 chiptest123 20202021 3840' + out_str = subprocess.getoutput(command) + print(out_str) + result = re.findall(r'Run command failure', str(out_str)) + if len(result) != 0: + assert False + # Use toggle command to turn-off the light + time.sleep(3) + command = CHIP_TOOL_EXE + ' onoff toggle 1 1' + out_str = subprocess.getoutput(command) + print(out_str) + result = re.findall(r'Run command failure', str(out_str)) + if len(result) != 0: + assert False + # Use toggle command to turn-on the light + time.sleep(5) + command = CHIP_TOOL_EXE + ' onoff toggle 1 1' + out_str = subprocess.getoutput(command) + print(out_str) + result = re.findall(r'Run command failure', str(out_str)) + if len(result) != 0: + assert False @pytest.mark.esp32c6 @pytest.mark.esp_matter_dut @@ -93,7 +132,7 @@ def test_matter_commissioning_c6(dut:Dut) -> None: print(out_str) result = re.findall(r'Run command failure', str(out_str)) if len(result) != 0: - assert False + assert False # get the host interface name diff --git a/pytest.ini b/pytest.ini index bca0a4d21..015c0b84a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -19,12 +19,13 @@ filterwarnings = markers = # target markers esp32c3: support esp32c3 target + esp32c2: support esp32c2 target esp32c6: support esp32c6 target esp32h2: support esp32h2 target esp32s3: support esp32s3 target # env markers esp_matter_dut: esp matter runner which have single dut - + # log related log_cli = True log_cli_level = INFO diff --git a/tools/ci/build_apps.py b/tools/ci/build_apps.py index 320ea066f..2ba7022e8 100644 --- a/tools/ci/build_apps.py +++ b/tools/ci/build_apps.py @@ -40,6 +40,13 @@ str(PROJECT_ROOT / 'examples' / '.build-rules.yml'), ] +PYTEST_C2_APPS = [ + {"target": "esp32c2", "name": "light"}, +] +MAINFEST_FILES = [ + str(PROJECT_ROOT / 'examples' / '.build-rules.yml'), +] + def _is_c6_pytest_app(app: App) -> bool: print(app.name, app.target) for pytest_app in PYTEST_C6_APPS: @@ -60,6 +67,12 @@ def _is_c3_pytest_app(app: App) -> bool: return True return False +def _is_c2_pytest_app(app: App) -> bool: + for pytest_app in PYTEST_C2_APPS: + if app.name == pytest_app["name"] and app.target == pytest_app["target"]: + return True + return False + def get_cmake_apps( paths: List[str], target: str, @@ -83,7 +96,7 @@ def main(args: argparse.Namespace) -> None: apps = get_cmake_apps(args.paths, args.target, args.config) # no_pytest and only_pytest can not be both True - assert not (args.no_pytest and args.pytest_c6 and args.pytest_h2 and args.pytest_c3) + assert not (args.no_pytest and args.pytest_c6 and args.pytest_h2 and args.pytest_c3 and args.pytest_c2) if args.no_pytest: apps_for_build = [app for app in apps if not (_is_c6_pytest_app(app) or _is_h2_pytest_app(app))] elif args.pytest_c6: @@ -92,6 +105,8 @@ def main(args: argparse.Namespace) -> None: apps_for_build = [app for app in apps if _is_h2_pytest_app(app)] elif args.pytest_c3: apps_for_build = [app for app in apps if _is_c3_pytest_app(app)] + elif args.pytest_c2: + apps_for_build = [app for app in apps if _is_c2_pytest_app(app)] else: apps_for_build = apps[:] @@ -167,6 +182,11 @@ def main(args: argparse.Namespace) -> None: action="store_true", help='Only build pytest apps, definded in PYTEST_C3_APPS', ) + parser.add_argument( + '--pytest_c2', + action="store_true", + help='Only build pytest apps, definded in PYTEST_C2_APPS', + ) parser.add_argument( '--collect-size-info', type=argparse.FileType('w'),