Skip to content

Commit 35fcc33

Browse files
Revert "Refactoring of support test scripts to enhance matter testing infrast…" (project-chip#36016)
This reverts commit b1cd9fd.
1 parent 33991c5 commit 35fcc33

File tree

203 files changed

+391
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+391
-495
lines changed

docs/testing/python.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Python tests located in src/python_testing
2525
section should include various parameters and their respective values,
2626
which will guide the test runner on how to execute the tests.
2727
- All test classes inherit from `MatterBaseTest` in
28-
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
28+
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
2929
- Support for commissioning using the python controller
3030
- Default controller (`self.default_controller`) of type `ChipDeviceCtrl`
3131
- `MatterBaseTest` inherits from the Mobly BaseTestClass
@@ -38,7 +38,7 @@ Python tests located in src/python_testing
3838
decorated with the @async_test_body decorator
3939
- Use `ChipDeviceCtrl` to interact with the DUT
4040
- Controller API is in `ChipDeviceCtrl.py` (see API doc in file)
41-
- Some support methods in `matter_testing.py`
41+
- Some support methods in `matter_testing_support.py`
4242
- Use Mobly assertions for failing tests
4343
- `self.step()` along with a `steps_*` method to mark test plan steps for cert
4444
tests
@@ -379,7 +379,7 @@ pai = await dev_ctrl.SendCommand(nodeid, 0, Clusters.OperationalCredentials.Comm
379379
## Mobly helpers
380380

381381
The test system is based on Mobly, and the
382-
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
382+
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
383383
class provides some helpers for Mobly integration.
384384

385385
- `default_matter_test_main`
@@ -561,11 +561,11 @@ these steps to set this up:
561561

562562
## Other support utilities
563563

564-
- `basic_composition`
564+
- `basic_composition_support`
565565
- wildcard read, whole device analysis
566566
- `CommissioningFlowBlocks`
567567
- various commissioning support for core tests
568-
- `spec_parsing`
568+
- `spec_parsing_support`
569569
- parsing data model XML into python readable format
570570

571571
# Running tests locally

scripts/spec_xml/generate_spec_xml.py

+38-22
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,26 @@
2424
from pathlib import Path
2525

2626
import click
27-
from paths import Branch, get_chip_root, get_data_model_path, get_documentation_file_path, get_in_progress_defines
2827

29-
# Use the get_in_progress_defines() function to fetch the in-progress defines
30-
CURRENT_IN_PROGRESS_DEFINES = get_in_progress_defines()
31-
32-
# Replace hardcoded paths with dynamic paths using paths.py functions
33-
DEFAULT_CHIP_ROOT = get_chip_root()
34-
DEFAULT_OUTPUT_DIR_1_3 = get_data_model_path(Branch.V1_3)
35-
DEFAULT_OUTPUT_DIR_IN_PROGRESS = get_data_model_path(Branch.IN_PROGRESS)
36-
DEFAULT_OUTPUT_DIR_TOT = get_data_model_path(Branch.MASTER)
37-
DEFAULT_DOCUMENTATION_FILE = get_documentation_file_path()
28+
DEFAULT_CHIP_ROOT = os.path.abspath(
29+
os.path.join(os.path.dirname(__file__), '..', '..'))
30+
DEFAULT_OUTPUT_DIR_1_3 = os.path.abspath(
31+
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', '1.3'))
32+
DEFAULT_OUTPUT_DIR_IN_PROGRESS = os.path.abspath(
33+
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', 'in_progress'))
34+
DEFAULT_OUTPUT_DIR_TOT = os.path.abspath(
35+
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', 'master'))
36+
DEFAULT_DOCUMENTATION_FILE = os.path.abspath(
37+
os.path.join(DEFAULT_CHIP_ROOT, 'docs', 'spec_clusters.md'))
38+
39+
# questions
40+
# is energy-calendar still in?
41+
# is heat-pump out? wasn't in 0.7
42+
# location-cluster - is this define gone now?
43+
# queuedpreset - is this define gone now?
44+
CURRENT_IN_PROGRESS_DEFINES = ['aliro', 'atomicwrites', 'battery-storage', 'device-location', 'e2e-jf', 'energy-calendar', 'energy-drlc',
45+
'energy-management', 'heat-pump', 'hrap-1', 'hvac', 'matter-fabric-synchronization', 'metering', 'secondary-net',
46+
'service-area-cluster', 'solar-power', 'tcp', 'water-heater', 'wifiSetup']
3847

3948

4049
def get_xml_path(filename, output_dir):
@@ -81,6 +90,7 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
8190
'--include-in-progress',
8291
type=click.Choice(['All', 'None', 'Current']), default='All')
8392
def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
93+
# Clusters need to be scraped first because the cluster directory is passed to the device type directory
8494
if not output_dir:
8595
output_dir_map = {'All': DEFAULT_OUTPUT_DIR_TOT, 'None': DEFAULT_OUTPUT_DIR_1_3, 'Current': DEFAULT_OUTPUT_DIR_IN_PROGRESS}
8696
output_dir = output_dir_map[include_in_progress]
@@ -93,28 +103,30 @@ def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
93103

94104
def scrape_clusters(scraper, spec_root, output_dir, dry_run, include_in_progress):
95105
src_dir = os.path.abspath(os.path.join(spec_root, 'src'))
96-
sdm_clusters_dir = os.path.abspath(os.path.join(src_dir, 'service_device_management'))
106+
sdm_clusters_dir = os.path.abspath(
107+
os.path.join(src_dir, 'service_device_management'))
97108
app_clusters_dir = os.path.abspath(os.path.join(src_dir, 'app_clusters'))
98109
dm_clusters_dir = os.path.abspath(os.path.join(src_dir, 'data_model'))
99-
media_clusters_dir = os.path.abspath(os.path.join(app_clusters_dir, 'media'))
100-
101-
clusters_output_dir = os.path.join(output_dir, 'clusters')
110+
media_clusters_dir = os.path.abspath(
111+
os.path.join(app_clusters_dir, 'media'))
112+
clusters_output_dir = os.path.abspath(os.path.join(output_dir, 'clusters'))
102113

103114
if not os.path.exists(clusters_output_dir):
104115
os.makedirs(clusters_output_dir)
105116

106-
print('Generating main spec to get file include list - this may take a few minutes')
117+
print('Generating main spec to get file include list - this make take a few minutes')
107118
main_out = make_asciidoc('pdf', include_in_progress, spec_root, dry_run)
108-
print('Generating cluster spec to get file include list - this may take a few minutes')
119+
print('Generating cluster spec to get file include list - this make take a few minutes')
109120
cluster_out = make_asciidoc('pdf-appclusters-book', include_in_progress, spec_root, dry_run)
110121

111122
def scrape_cluster(filename: str) -> None:
112123
base = Path(filename).stem
113124
if base not in main_out and base not in cluster_out:
114-
print(f'Skipping file: {base} as it is not compiled into the asciidoc')
125+
print(f'skipping file: {base} as it is not compiled into the asciidoc')
115126
return
116127
xml_path = get_xml_path(filename, clusters_output_dir)
117-
cmd = [scraper, 'cluster', '-i', filename, '-o', xml_path, '-nd']
128+
cmd = [scraper, 'cluster', '-i', filename, '-o',
129+
xml_path, '-nd']
118130
if include_in_progress == 'All':
119131
cmd.extend(['--define', 'in-progress'])
120132
elif include_in_progress == 'Current':
@@ -138,29 +150,33 @@ def scrape_all_clusters(dir: str, exclude_list: list[str] = []) -> None:
138150
tree = ElementTree.parse(f'{xml_path}')
139151
root = tree.getroot()
140152
cluster = next(root.iter('cluster'))
153+
# If there's no cluster ID table, this isn't a cluster
141154
try:
142155
next(cluster.iter('clusterIds'))
143156
except StopIteration:
157+
# If there's no cluster ID table, this isn't a cluster just some kind of intro adoc
144158
print(f'Removing file {xml_path} as it does not include any cluster definitions')
145159
os.remove(xml_path)
146160
continue
147161

148162

149163
def scrape_device_types(scraper, spec_root, output_dir, dry_run, include_in_progress):
150-
device_type_dir = os.path.abspath(os.path.join(spec_root, 'src', 'device_types'))
151-
device_types_output_dir = os.path.abspath(os.path.join(output_dir, 'device_types'))
164+
device_type_dir = os.path.abspath(
165+
os.path.join(spec_root, 'src', 'device_types'))
166+
device_types_output_dir = os.path.abspath(
167+
os.path.join(output_dir, 'device_types'))
152168
clusters_output_dir = os.path.abspath(os.path.join(output_dir, 'clusters'))
153169

154170
if not os.path.exists(device_types_output_dir):
155171
os.makedirs(device_types_output_dir)
156172

157-
print('Generating device type library to get file include list - this may take a few minutes')
173+
print('Generating device type library to get file include list - this make take a few minutes')
158174
device_type_output = make_asciidoc('pdf-devicelibrary-book', include_in_progress, spec_root, dry_run)
159175

160176
def scrape_device_type(filename: str) -> None:
161177
base = Path(filename).stem
162178
if base not in device_type_output:
163-
print(f'Skipping file: {filename} as it is not compiled into the asciidoc')
179+
print(f'skipping file: {filename} as it is not compiled into the asciidoc')
164180
return
165181
xml_path = get_xml_path(filename, device_types_output_dir)
166182
cmd = [scraper, 'devicetype', '-c', '-cls', clusters_output_dir,

scripts/spec_xml/paths.py

-109
This file was deleted.

src/python_testing/MinimalRepresentation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
from dataclasses import dataclass, field
1919

20-
from chip.testing.conformance import ConformanceDecision
21-
from chip.testing.global_attribute_ids import GlobalAttributeIds
22-
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main
2320
from chip.tlv import uint
21+
from conformance_support import ConformanceDecision
22+
from global_attribute_ids import GlobalAttributeIds
23+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
2424
from TC_DeviceConformance import DeviceConformanceTests
2525

2626

src/python_testing/TCP_Tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import chip.clusters as Clusters
3434
from chip import ChipDeviceCtrl
3535
from chip.interaction_model import InteractionModelError
36-
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main
36+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
3737
from mobly import asserts
3838

3939

src/python_testing/TC_ACE_1_2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction, TypedAttributePath
4343
from chip.exceptions import ChipStackError
4444
from chip.interaction_model import Status
45-
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main
45+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
4646
from mobly import asserts
4747

4848

src/python_testing/TC_ACE_1_3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
import chip.clusters as Clusters
4040
from chip.interaction_model import Status
41-
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
41+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
4242
from mobly import asserts
4343

4444

src/python_testing/TC_ACE_1_4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
import chip.clusters as Clusters
4444
from chip.interaction_model import Status
45-
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main
45+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
4646
from mobly import asserts
4747

4848
# This test requires several additional command line arguments

src/python_testing/TC_ACE_1_5.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import chip.clusters as Clusters
4141
from chip import ChipDeviceCtrl
4242
from chip.interaction_model import Status
43-
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main
43+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
4444
from mobly import asserts
4545

4646

src/python_testing/TC_ACL_2_11.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
import queue
4343

4444
import chip.clusters as Clusters
45+
from basic_composition_support import arls_populated
4546
from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction, ValueDecodeFailure
4647
from chip.clusters.ClusterObjects import ALL_ACCEPTED_COMMANDS, ALL_ATTRIBUTES, ALL_CLUSTERS, ClusterEvent
4748
from chip.clusters.Objects import AccessControl
4849
from chip.clusters.Types import NullValue
4950
from chip.interaction_model import InteractionModelError, Status
50-
from chip.testing.basic_composition import arls_populated
51-
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
51+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
5252
from mobly import asserts
5353

5454

src/python_testing/TC_ACL_2_2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# === END CI TEST ARGUMENTS ===
3333

3434
import chip.clusters as Clusters
35-
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
35+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
3636
from mobly import asserts
3737

3838

src/python_testing/TC_AccessChecker.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
from typing import Optional
2424

2525
import chip.clusters as Clusters
26+
from basic_composition_support import BasicCompositionTests
2627
from chip.interaction_model import Status
27-
from chip.testing.basic_composition import BasicCompositionTests
28-
from chip.testing.global_attribute_ids import GlobalAttributeIds
29-
from chip.testing.matter_testing import (AttributePathLocation, ClusterPathLocation, MatterBaseTest, TestStep, async_test_body,
30-
default_matter_test_main)
31-
from chip.testing.spec_parsing import XmlCluster, build_xml_clusters
3228
from chip.tlv import uint
29+
from global_attribute_ids import GlobalAttributeIds
30+
from matter_testing_support import (AttributePathLocation, ClusterPathLocation, MatterBaseTest, TestStep, async_test_body,
31+
default_matter_test_main)
32+
from spec_parsing_support import XmlCluster, build_xml_clusters
3333

3434

3535
class AccessTestType(Enum):

src/python_testing/TC_BOOLCFG_2_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from operator import ior
3737

3838
import chip.clusters as Clusters
39-
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
39+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
4040
from mobly import asserts
4141

4242

src/python_testing/TC_BOOLCFG_3_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
import chip.clusters as Clusters
3838
from chip.interaction_model import Status
39-
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
39+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
4040
from mobly import asserts
4141

4242

0 commit comments

Comments
 (0)