@@ -504,7 +504,7 @@ class MatterTestConfig:
504
504
# List of explicit tests to run by name. If empty, all tests will run
505
505
tests : List [str ] = field (default_factory = list )
506
506
timeout : typing .Union [int , None ] = None
507
- endpoint : int = 0
507
+ endpoint : typing . Union [ int , None ] = 0
508
508
app_pid : int = 0
509
509
510
510
commissioning_method : Optional [str ] = None
@@ -980,7 +980,7 @@ async def read_single_attribute_check_success(
980
980
if node_id is None :
981
981
node_id = self .dut_node_id
982
982
if endpoint is None :
983
- endpoint = self .matter_test_config .endpoint
983
+ endpoint = 0 if self . matter_test_config . endpoint is None else self .matter_test_config .endpoint
984
984
985
985
result = await dev_ctrl .ReadAttribute (node_id , [(endpoint , attribute )], fabricFiltered = fabric_filtered )
986
986
attr_ret = result [endpoint ][cluster ][attribute ]
@@ -1012,7 +1012,7 @@ async def read_single_attribute_expect_error(
1012
1012
if node_id is None :
1013
1013
node_id = self .dut_node_id
1014
1014
if endpoint is None :
1015
- endpoint = self .matter_test_config .endpoint
1015
+ endpoint = 0 if self . matter_test_config . endpoint is None else self .matter_test_config .endpoint
1016
1016
1017
1017
result = await dev_ctrl .ReadAttribute (node_id , [(endpoint , attribute )], fabricFiltered = fabric_filtered )
1018
1018
attr_ret = result [endpoint ][cluster ][attribute ]
@@ -1041,12 +1041,13 @@ async def write_single_attribute(self, attribute_value: object, endpoint_id: int
1041
1041
"""
1042
1042
dev_ctrl = self .default_controller
1043
1043
node_id = self .dut_node_id
1044
- endpoint = self .matter_test_config .endpoint if endpoint_id is None else endpoint_id
1044
+ if endpoint_id is None :
1045
+ endpoint_id = 0 if self .matter_test_config .endpoint is None else self .matter_test_config .endpoint
1045
1046
1046
- write_result = await dev_ctrl .WriteAttribute (node_id , [(endpoint , attribute_value )])
1047
+ write_result = await dev_ctrl .WriteAttribute (node_id , [(endpoint_id , attribute_value )])
1047
1048
if expect_success :
1048
1049
asserts .assert_equal (write_result [0 ].Status , Status .Success ,
1049
- f"Expected write success for write to attribute { attribute_value } on endpoint { endpoint } " )
1050
+ f"Expected write success for write to attribute { attribute_value } on endpoint { endpoint_id } " )
1050
1051
return write_result [0 ].Status
1051
1052
1052
1053
async def send_single_cmd (
@@ -1059,7 +1060,7 @@ async def send_single_cmd(
1059
1060
if node_id is None :
1060
1061
node_id = self .dut_node_id
1061
1062
if endpoint is None :
1062
- endpoint = self .matter_test_config .endpoint
1063
+ endpoint = 0 if self . matter_test_config . endpoint is None else self .matter_test_config .endpoint
1063
1064
1064
1065
result = await dev_ctrl .SendCommand (nodeid = node_id , endpoint = endpoint , payload = cmd , timedRequestTimeoutMs = timedRequestTimeoutMs ,
1065
1066
payloadCapability = payloadCapability )
@@ -1584,7 +1585,7 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig:
1584
1585
config .pics = {} if args .PICS is None else read_pics_from_file (args .PICS )
1585
1586
config .tests = [] if args .tests is None else args .tests
1586
1587
config .timeout = args .timeout # This can be none, we pull the default from the test if it's unspecified
1587
- config .endpoint = 0 if args . endpoint is None else args .endpoint
1588
+ config .endpoint = args .endpoint
1588
1589
config .app_pid = 0 if args .app_pid is None else args .app_pid
1589
1590
1590
1591
config .controller_node_id = args .controller_node_id
@@ -1863,7 +1864,17 @@ async def get_accepted_endpoints_for_test(self: MatterBaseTest, accept_function:
1863
1864
1864
1865
Returns a list of endpoints on which the test should be run given the accept_function for the test.
1865
1866
"""
1866
- wildcard = await self .default_controller .Read (self .dut_node_id , [()])
1867
+
1868
+ if self .matter_test_config .endpoint is not None :
1869
+ msg = """
1870
+ The --endpoint flag is disallowed for tests that run on all matching endpoints.
1871
+ To enable running against a single endpoint for development purposes, use
1872
+ --int-arg force_endpoint:1 (where "1" can be replaced with the desired endpoint)
1873
+ Note that using force_endpoint is disallowed at certification and should be used
1874
+ ONLY FOR DEVELOPMENT.
1875
+ """
1876
+ asserts .fail (msg )
1877
+
1867
1878
matching = [e for e in wildcard .attributes .keys () if accept_function (wildcard , e )]
1868
1879
forced_endpoint = self .user_params .get ('force_endpoint' , None )
1869
1880
if forced_endpoint is None :
@@ -1931,7 +1942,6 @@ def per_endpoint_runner(self: MatterBaseTest, *args, **kwargs):
1931
1942
# Ditto for teardown - we want to tear down after each iteration, and we want to notify the hook that
1932
1943
# the test iteration is stopped. test_stop is called by on_pass or on_fail during the last iteration or
1933
1944
# on failure.
1934
- original_ep = self .matter_test_config .endpoint
1935
1945
for e in endpoints :
1936
1946
logging .info (f'Running test on endpoint { e } ' )
1937
1947
if e != endpoints [0 ]:
@@ -1942,7 +1952,7 @@ def per_endpoint_runner(self: MatterBaseTest, *args, **kwargs):
1942
1952
self .teardown_test ()
1943
1953
test_duration = (datetime .now (timezone .utc ) - self .test_start_time ) / timedelta (microseconds = 1 )
1944
1954
self .runner_hook .test_stop (exception = None , duration = test_duration )
1945
- self .matter_test_config .endpoint = original_ep
1955
+ self .matter_test_config .endpoint = None
1946
1956
return per_endpoint_runner
1947
1957
return run_for_each_matching_endpoint_internal
1948
1958
0 commit comments