15
15
# limitations under the License.
16
16
#
17
17
18
+ # See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments
19
+ # for details about the block below.
20
+ #
21
+ # === BEGIN CI TEST ARGUMENTS ===
22
+ # test-runner-runs:
23
+ # run1:
24
+ # app: examples/fabric-admin/scripts/fabric-sync-app.py
25
+ # app-args: --app-admin=${FABRIC_ADMIN_APP} --app-bridge=${FABRIC_BRIDGE_APP} --stdin-pipe=dut-fsa-stdin --discriminator=1234
26
+ # script-args: >
27
+ # --PICS src/app/tests/suites/certification/ci-pics-values
28
+ # --storage-path admin_storage.json
29
+ # --commissioning-method on-network
30
+ # --discriminator 1234
31
+ # --passcode 20202021
32
+ # --string-arg th_server_app_path:${ALL_CLUSTERS_APP} dut_fsa_stdin_pipe:dut-fsa-stdin
33
+ # --trace-to json:${TRACE_TEST_JSON}.json
34
+ # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
35
+ # script-start-delay: 5
36
+ # factoryreset: true
37
+ # quiet: false
38
+ # === END CI TEST ARGUMENTS ===
39
+
40
+ import asyncio
41
+ import logging
42
+ import os
43
+ import random
44
+ import tempfile
45
+
18
46
import chip .clusters as Clusters
19
47
from chip .interaction_model import Status
20
48
from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
21
49
from mobly import asserts
50
+ from TC_MCORE_FS_1_1 import AppServer
22
51
23
52
_DEVICE_TYPE_AGGREGGATOR = 0x000E
24
53
25
54
26
55
class TC_ECOINFO_2_2 (MatterBaseTest ):
27
56
57
+ def setup_class (self ):
58
+ super ().setup_class ()
59
+
60
+ self .th_server = None
61
+ self .storage = None
62
+
63
+ if self .is_pics_sdk_ci_only :
64
+ self ._setup_ci_prerequisites ()
65
+
66
+ def teardown_class (self ):
67
+ if self .th_server is not None :
68
+ self .th_server .terminate ()
69
+ if self .storage is not None :
70
+ self .storage .cleanup ()
71
+ super ().teardown_class ()
72
+
73
+ def _setup_ci_prerequisites (self ):
74
+ asserts .assert_true (self .is_pics_sdk_ci_only , "This method is only for PICS SDK CI" )
75
+
76
+ th_server_app = self .user_params .get ("th_server_app_path" , None )
77
+ if not th_server_app :
78
+ asserts .fail ("CI setup requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:<path_to_app>" )
79
+ if not os .path .exists (th_server_app ):
80
+ asserts .fail (f"The path { th_server_app } does not exist" )
81
+
82
+ # Get the named pipe path for the DUT_FSA app input from the user params.
83
+ dut_fsa_stdin_pipe = self .user_params .get ("dut_fsa_stdin_pipe" )
84
+ if not dut_fsa_stdin_pipe :
85
+ asserts .fail ("CI setup requires --string-arg dut_fsa_stdin_pipe:<path_to_pipe>" )
86
+ self .dut_fsa_stdin = open (dut_fsa_stdin_pipe , "w" )
87
+
88
+ # Create a temporary storage directory for keeping KVS files.
89
+ self .storage = tempfile .TemporaryDirectory (prefix = self .__class__ .__name__ )
90
+ logging .info ("Temporary storage directory: %s" , self .storage .name )
91
+
92
+ self .th_server_port = 5544
93
+ self .th_server_discriminator = random .randint (0 , 4095 )
94
+ self .th_server_passcode = 20202021
95
+
96
+ # Start the server app.
97
+ self .th_server = AppServer (
98
+ th_server_app ,
99
+ storage_dir = self .storage .name ,
100
+ port = self .th_server_port ,
101
+ discriminator = self .th_server_discriminator ,
102
+ passcode = self .th_server_passcode )
103
+ self .th_server .start ()
104
+
28
105
def steps_TC_ECOINFO_2_2 (self ) -> list [TestStep ]:
29
- steps = [TestStep (1 , "Prepare" , is_commissioning = True ),
30
- TestStep ("1a" , "Read root endpoint's PartsList" ),
31
- TestStep ("1b" , "For each endpoint in 1a read DeviceType list confirming aggregator endpoint exists" ),
32
- TestStep (2 , "Add a bridged device" ),
33
- TestStep ("2a" , "(Manual Step) Add a bridged device using method indicated by the manufacturer" ),
34
- TestStep ("2b" , "Read root endpoint's PartsList, validate exactly one endpoint added" ),
35
- TestStep ("2c" , "On newly added endpoint detected in 2b read DeviceDirectory Ecosystem Information Attribute and validate success" ),
36
- TestStep ("2d" , "On newly added endpoint detected in 2b read LocationDirectory Ecosystem Information Attribute and validate success" ),
37
- TestStep (3 , "Remove bridged device" ),
38
- TestStep ("3a" , "(Manual Step) Removed bridged device added in step 2a using method indicated by the manufacturer" ),
39
- TestStep ("3b" , "Verify that PartsList equals what was read in 1a" ),
40
- TestStep ("3c" , "On endpoint detected in 2b, read DeviceDirectory Ecosystem Information Attribute and validate failure" ),
41
- TestStep ("3d" , "On endpoint detected in 2b, read LocationDirectory Ecosystem Information Attribute and validate failure" )]
42
-
43
- return steps
106
+ return [
107
+ TestStep (0 , "Commission DUT if not done" , is_commissioning = True ),
108
+ TestStep (1 , "Prepare" ),
109
+ TestStep ("1a" , "Read root endpoint's PartsList" ),
110
+ TestStep ("1b" , "For each endpoint in 1a read DeviceType list confirming aggregator endpoint exists" ),
111
+ TestStep (2 , "Add a bridged device" ),
112
+ TestStep ("2a" , "(Manual Step) Add a bridged device using method indicated by the manufacturer" ),
113
+ TestStep ("2b" , "Read root endpoint's PartsList, validate exactly one endpoint added" ),
114
+ TestStep ("2c" , "On newly added endpoint detected in 2b read DeviceDirectory Ecosystem Information Attribute and validate success" ),
115
+ TestStep ("2d" , "On newly added endpoint detected in 2b read LocationDirectory Ecosystem Information Attribute and validate success" ),
116
+ TestStep (3 , "Remove bridged device" ),
117
+ TestStep ("3a" , "(Manual Step) Removed bridged device added in step 2a using method indicated by the manufacturer" ),
118
+ TestStep ("3b" , "Verify that PartsList equals what was read in 1a" ),
119
+ TestStep ("3c" , "On endpoint detected in 2b, read DeviceDirectory Ecosystem Information Attribute and validate failure" ),
120
+ TestStep ("3d" , "On endpoint detected in 2b, read LocationDirectory Ecosystem Information Attribute and validate failure" ),
121
+ ]
44
122
45
123
# This test has some manual steps, so we need a longer timeout. Test typically runs under 1 mins so 3 mins should
46
124
# be enough time for test to run
@@ -53,7 +131,9 @@ async def test_TC_ECOINFO_2_2(self):
53
131
dev_ctrl = self .default_controller
54
132
dut_node_id = self .dut_node_id
55
133
56
- self .print_step (0 , "Commissioning, already done" )
134
+ # Commissioning - done
135
+ self .step (0 )
136
+
57
137
self .step (1 )
58
138
self .step ("1a" )
59
139
root_node_endpoint = 0
@@ -74,7 +154,14 @@ async def test_TC_ECOINFO_2_2(self):
74
154
75
155
self .step (2 )
76
156
self .step ("2a" )
77
- self .wait_for_user_input (prompt_msg = "Add a bridged device using method indicated by the manufacturer" )
157
+ if not self .is_pics_sdk_ci_only :
158
+ self .wait_for_user_input ("Add a bridged device using method indicated by the manufacturer" )
159
+ else :
160
+ # Add some server to the DUT_FSA's Aggregator/Bridge.
161
+ self .dut_fsa_stdin .write (f"pairing onnetwork 2 { self .th_server_passcode } \n " )
162
+ self .dut_fsa_stdin .flush ()
163
+ # Wait for the commissioning to complete.
164
+ await asyncio .sleep (5 )
78
165
79
166
self .step ("2b" )
80
167
root_part_list_step_2 = await dev_ctrl .ReadAttribute (dut_node_id , [(root_node_endpoint , Clusters .Descriptor .Attributes .PartsList )])
@@ -106,7 +193,14 @@ async def test_TC_ECOINFO_2_2(self):
106
193
107
194
self .step (3 )
108
195
self .step ("3a" )
109
- self .wait_for_user_input (prompt_msg = "Removed bridged device added in step 2a using method indicated by the manufacturer" )
196
+ if not self .is_pics_sdk_ci_only :
197
+ self .wait_for_user_input ("Removed bridged device added in step 2a using method indicated by the manufacturer" )
198
+ else :
199
+ # Remove previously added server from the DUT_FSA's Aggregator/Bridge.
200
+ self .dut_fsa_stdin .write ("pairing unpair 2\n " )
201
+ self .dut_fsa_stdin .flush ()
202
+ # Wait for the command to complete.
203
+ await asyncio .sleep (2 )
110
204
111
205
self .step ("3b" )
112
206
root_part_list_step_3 = await dev_ctrl .ReadAttribute (dut_node_id , [(root_node_endpoint , Clusters .Descriptor .Attributes .PartsList )])
0 commit comments