Skip to content

Commit 9aef5f4

Browse files
committed
Merge branch 'add_c2_pytest' into 'main'
add esp32c2 pytest See merge request app-frameworks/esp-matter!716
2 parents 0aac1d3 + 190af4c commit 9aef5f4

File tree

4 files changed

+97
-4
lines changed

4 files changed

+97
-4
lines changed

.gitlab-ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
230230
- pip install -r tools/ci/requirements-build.txt
231231
- python tools/ci/build_apps.py ./examples --pytest_h2
232232

233+
build_esp_matter_examples_pytest_C2_idf_v5_1:
234+
extends:
235+
- .build_examples_template
236+
artifacts:
237+
paths:
238+
- "examples/**/build*/size.json"
239+
- "examples/**/build*/build_log.txt"
240+
- "examples/**/build*/*.bin"
241+
- "examples/**/build*/flasher_args.json"
242+
- "examples/**/build*/config/sdkconfig.json"
243+
- "examples/**/build*/bootloader/*.bin"
244+
- "examples/**/build*/partition_table/*.bin"
245+
- "connectedhomeip/connectedhomeip/out/host/chip-tool"
246+
when: always
247+
expire_in: 4 days
248+
variables:
249+
IDF_VERSION: "v5.2.1"
250+
script:
251+
- cd ${ESP_MATTER_PATH}
252+
- pip install -r tools/ci/requirements-build.txt
253+
- python tools/ci/build_apps.py ./examples --pytest_c2
254+
233255
build_esp_matter_examples_non_pytest_idf_v5_1:
234256
extends:
235257
- .build_examples_template
@@ -307,6 +329,17 @@ pytest_esp32c6_esp_matter_dut:
307329
- pytest examples/ --target esp32c6 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
308330
tags: ["esp32c6", "esp_matter_dut"]
309331

332+
pytest_esp32c2_esp_matter_dut:
333+
stage: target_test
334+
image: ${TARGET_TEST_ENV}
335+
needs:
336+
- build_esp_matter_examples_pytest_C2_idf_v5_1
337+
script:
338+
- cd ${ESP_MATTER_PATH}
339+
- pip install -r tools/ci/requirements-pytest.txt
340+
- pytest examples/ --target esp32c2 -m esp_matter_dut --junitxml=XUNIT_RESULT.xml
341+
tags: ["esp32c2", "esp_matter_dut"]
342+
310343
pytest_esp32h2_esp_matter_dut:
311344
stage: target_test
312345
image: ${TARGET_TEST_ENV}

examples/pytest_esp_matter_light.py

+41-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,46 @@ def test_matter_commissioning_c3(dut:Dut) -> None:
5454
print(out_str)
5555
result = re.findall(r'Run command failure', str(out_str))
5656
if len(result) != 0:
57-
assert False
57+
assert False
58+
59+
@pytest.mark.esp32c2
60+
@pytest.mark.esp_matter_dut
61+
@pytest.mark.parametrize(
62+
' count, app_path, target, erase_all', [
63+
( 1, pytest_build_dir, 'esp32c2', 'y'),
64+
],
65+
indirect=True,
66+
)
67+
68+
# Matter over wifi commissioning
69+
def test_matter_commissioning_c2(dut:Dut) -> None:
70+
light = dut
71+
# BLE start advertising
72+
light.expect(r'chip\[DL\]\: Configuring CHIPoBLE advertising', timeout=20)
73+
# Start commissioning
74+
time.sleep(5)
75+
command = CHIP_TOOL_EXE + ' pairing ble-wifi 1 ChipTEH2 chiptest123 20202021 3840'
76+
out_str = subprocess.getoutput(command)
77+
print(out_str)
78+
result = re.findall(r'Run command failure', str(out_str))
79+
if len(result) != 0:
80+
assert False
81+
# Use toggle command to turn-off the light
82+
time.sleep(3)
83+
command = CHIP_TOOL_EXE + ' onoff toggle 1 1'
84+
out_str = subprocess.getoutput(command)
85+
print(out_str)
86+
result = re.findall(r'Run command failure', str(out_str))
87+
if len(result) != 0:
88+
assert False
89+
# Use toggle command to turn-on the light
90+
time.sleep(5)
91+
command = CHIP_TOOL_EXE + ' onoff toggle 1 1'
92+
out_str = subprocess.getoutput(command)
93+
print(out_str)
94+
result = re.findall(r'Run command failure', str(out_str))
95+
if len(result) != 0:
96+
assert False
5897

5998
@pytest.mark.esp32c6
6099
@pytest.mark.esp_matter_dut
@@ -93,7 +132,7 @@ def test_matter_commissioning_c6(dut:Dut) -> None:
93132
print(out_str)
94133
result = re.findall(r'Run command failure', str(out_str))
95134
if len(result) != 0:
96-
assert False
135+
assert False
97136

98137

99138
# get the host interface name

pytest.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ filterwarnings =
1919
markers =
2020
# target markers
2121
esp32c3: support esp32c3 target
22+
esp32c2: support esp32c2 target
2223
esp32c6: support esp32c6 target
2324
esp32h2: support esp32h2 target
2425
esp32s3: support esp32s3 target
2526
# env markers
2627
esp_matter_dut: esp matter runner which have single dut
27-
28+
2829
# log related
2930
log_cli = True
3031
log_cli_level = INFO

tools/ci/build_apps.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
str(PROJECT_ROOT / 'examples' / '.build-rules.yml'),
4141
]
4242

43+
PYTEST_C2_APPS = [
44+
{"target": "esp32c2", "name": "light"},
45+
]
46+
MAINFEST_FILES = [
47+
str(PROJECT_ROOT / 'examples' / '.build-rules.yml'),
48+
]
49+
4350
def _is_c6_pytest_app(app: App) -> bool:
4451
print(app.name, app.target)
4552
for pytest_app in PYTEST_C6_APPS:
@@ -60,6 +67,12 @@ def _is_c3_pytest_app(app: App) -> bool:
6067
return True
6168
return False
6269

70+
def _is_c2_pytest_app(app: App) -> bool:
71+
for pytest_app in PYTEST_C2_APPS:
72+
if app.name == pytest_app["name"] and app.target == pytest_app["target"]:
73+
return True
74+
return False
75+
6376
def get_cmake_apps(
6477
paths: List[str],
6578
target: str,
@@ -83,7 +96,7 @@ def main(args: argparse.Namespace) -> None:
8396
apps = get_cmake_apps(args.paths, args.target, args.config)
8497

8598
# no_pytest and only_pytest can not be both True
86-
assert not (args.no_pytest and args.pytest_c6 and args.pytest_h2 and args.pytest_c3)
99+
assert not (args.no_pytest and args.pytest_c6 and args.pytest_h2 and args.pytest_c3 and args.pytest_c2)
87100
if args.no_pytest:
88101
apps_for_build = [app for app in apps if not (_is_c6_pytest_app(app) or _is_h2_pytest_app(app))]
89102
elif args.pytest_c6:
@@ -92,6 +105,8 @@ def main(args: argparse.Namespace) -> None:
92105
apps_for_build = [app for app in apps if _is_h2_pytest_app(app)]
93106
elif args.pytest_c3:
94107
apps_for_build = [app for app in apps if _is_c3_pytest_app(app)]
108+
elif args.pytest_c2:
109+
apps_for_build = [app for app in apps if _is_c2_pytest_app(app)]
95110
else:
96111
apps_for_build = apps[:]
97112

@@ -167,6 +182,11 @@ def main(args: argparse.Namespace) -> None:
167182
action="store_true",
168183
help='Only build pytest apps, definded in PYTEST_C3_APPS',
169184
)
185+
parser.add_argument(
186+
'--pytest_c2',
187+
action="store_true",
188+
help='Only build pytest apps, definded in PYTEST_C2_APPS',
189+
)
170190
parser.add_argument(
171191
'--collect-size-info',
172192
type=argparse.FileType('w'),

0 commit comments

Comments
 (0)