Skip to content

Commit fe96faa

Browse files
hicklinrestyled-commitsplauric
authored andcommitted
Enable rvc python tests to run in ci (project-chip#31872)
* Replaced the vendor specific mode tag for the mapping mode with the mapping mode tag. * Updated the rvc-app's RvcOperationalStateDelegate to allow setting of a callback furtion for when the GoHome commond in received. * Implemented the GoHome handler for rvc-app. * Updated the PICS file for the rvc-app. * Fixed the Admin commissioning cluter's zap config for the rvc-app * Renamed the PICS values file to be similar to the ci file. Updated the script that runs all the RVC yaml tests. * Updated the rvc-app state machine diagram. * Updated theh rvc-app README. * Restyled by clang-format * Restyled by prettier-markdown * Restyled by shfmt * Updated the rvc-app .matter file. * Reduced the text of some errors as it was longer that allowed. * Added an out-of-band message to reset the rvc-app to its start-up state. * Updated a returend error following the spec change. * Excluded the RVC state diagram png from the lint check for %zu. * Added the PICS_SDK_CI_ONLY PICS to the rvc-app-pics-values to allow it to run tests in CI. * Improved the TC_RVCCLEANM_2_1 test to allow the CI to run the tests against the rvc-app. * Improved the TC_RVCRUNM_2_1 test to allow the CI to run the tests against the rvc-app. * Improved the TC_RVCCLEAN_2_2 test to allow the CI to run the tests against the rvc-app. * Improved the TC_RVCRUNN_2_2 test to allow the CI to run the tests against the rvc-app. * Improved the TC_RVCOPSTATE_2_1 test to allow the CI to run the tests against the rvc-app. * Improved the TC_RVCOPSTATE_2_3 test to allow the CI to run the tests against the rvc-app. * Restyled by autopep8 * Restyled by isort * Updated the rvc-app readme. * Removed PIXIT settings from the rvc-app-pics values. * Excluded all binary files from the lint check for %zu. * Fixed typos from code review Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com> * Re-removed the OpenBasicCommissioningWindow command of the Administrator Commissioning cluster in the rvc-app due to security concerns. * Updated the rvc-app .matter file. * Removed sleeps between messages to the DUT as they are not needed. * Restyled by isort * Fixed extra imports in python tests. --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com>
1 parent 53443cc commit fe96faa

File tree

7 files changed

+285
-53
lines changed

7 files changed

+285
-53
lines changed

examples/rvc-app/rvc-common/pics/rvc-app-pics-values

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PICS_SDK_CI_ONLY=1
2+
13
RVCCLEANM.S=1
24
RVCCLEANM.S.A0000=1
35
RVCCLEANM.S.A0001=1

src/python_testing/TC_RVCCLEANM_2_1.py

+39-8
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,30 @@ def __init__(self, *args):
3333
self.endpoint = 0
3434
self.mode_ok = 0
3535
self.mode_fail = 0
36+
self.is_ci = False
37+
self.app_pipe = "/tmp/chip_rvc_fifo_"
3638

3739
async def read_mod_attribute_expect_success(self, endpoint, attribute):
3840
cluster = Clusters.Objects.RvcCleanMode
3941
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
4042

41-
async def send_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse:
43+
async def send_clean_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse:
4244
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcCleanMode.Commands.ChangeToMode(newMode=newMode), endpoint=self.endpoint)
4345
asserts.assert_true(type_matches(ret, Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse),
44-
"Unexpected return type for ChangeToMode")
46+
"Unexpected return type for RVC Clean Mode ChangeToMode")
4547
return ret
4648

49+
async def send_run_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcRunMode.Commands.ChangeToModeResponse:
50+
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=newMode), endpoint=self.endpoint)
51+
asserts.assert_true(type_matches(ret, Clusters.Objects.RvcRunMode.Commands.ChangeToModeResponse),
52+
"Unexpected return type for RVC Run Mode ChangeToMode")
53+
return ret
54+
55+
# Sends and out-of-band command to the rvc-app
56+
def write_to_app_pipe(self, command):
57+
with open(self.app_pipe, "w") as app_pipe:
58+
app_pipe.write(command + "\n")
59+
4760
def pics_TC_RVCCLEANM_2_1(self) -> list[str]:
4861
return ["RVCCLEANM.S"]
4962

@@ -60,6 +73,12 @@ async def test_TC_RVCCLEANM_2_1(self):
6073
self.endpoint = self.matter_test_config.endpoint
6174
self.mode_ok = self.matter_test_config.global_test_params['PIXIT.RVCCLEANM.MODE_CHANGE_OK']
6275
self.mode_fail = self.matter_test_config.global_test_params['PIXIT.RVCCLEANM.MODE_CHANGE_FAIL']
76+
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
77+
if self.is_ci:
78+
app_pid = self.matter_test_config.app_pid
79+
if app_pid == 0:
80+
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
81+
self.app_pipe = self.app_pipe + str(app_pid)
6382

6483
asserts.assert_true(self.check_pics("RVCCLEANM.S.A0000"), "RVCCLEANM.S.A0000 must be supported")
6584
asserts.assert_true(self.check_pics("RVCCLEANM.S.A0001"), "RVCCLEANM.S.A0001 must be supported")
@@ -70,6 +89,10 @@ async def test_TC_RVCCLEANM_2_1(self):
7089

7190
self.print_step(1, "Commissioning, already done")
7291

92+
# Ensure that the device is in the correct state
93+
if self.is_ci:
94+
self.write_to_app_pipe('{"Name": "Reset"}')
95+
7396
self.print_step(2, "Read SupportedModes attribute")
7497
supported_modes = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.SupportedModes)
7598

@@ -100,14 +123,18 @@ class CommonCodes(Enum):
100123

101124
self.print_step(4, "Send ChangeToMode command with NewMode set to %d" % (old_current_mode))
102125

103-
ret = await self.send_change_to_mode_cmd(newMode=old_current_mode)
126+
ret = await self.send_clean_change_to_mode_cmd(newMode=old_current_mode)
104127
asserts.assert_true(ret.status == CommonCodes.SUCCESS.value, "Changing the mode to the current mode should be a no-op")
105128

106129
if self.check_pics("RVCCLEANM.S.M.CAN_TEST_MODE_FAILURE"):
107130
asserts.assert_true(self.mode_fail in modes,
108131
"The MODE_CHANGE_FAIL PIXIT value (%d) is not a supported mode" % (self.mode_fail))
109132
self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.mode_fail))
110-
input("Press Enter when done.\n")
133+
if self.is_ci:
134+
print("Changing mode to Cleaning")
135+
await self.send_run_change_to_mode_cmd(1)
136+
else:
137+
input("Press Enter when done.\n")
111138

112139
self.print_step(6, "Read CurrentMode attribute")
113140
old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
@@ -116,7 +143,7 @@ class CommonCodes(Enum):
116143

117144
self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.mode_fail))
118145

119-
ret = await self.send_change_to_mode_cmd(newMode=self.mode_fail)
146+
ret = await self.send_clean_change_to_mode_cmd(newMode=self.mode_fail)
120147
st = ret.status
121148
is_mfg_code = st in range(0x80, 0xC0)
122149
is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (
@@ -134,7 +161,11 @@ class CommonCodes(Enum):
134161
asserts.assert_true(current_mode == old_current_mode, "CurrentMode changed after failed ChangeToMode command!")
135162

136163
self.print_step(9, "Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self.mode_ok))
137-
input("Press Enter when done.\n")
164+
if self.is_ci:
165+
print("Changing mode to Idle")
166+
await self.send_run_change_to_mode_cmd(0)
167+
else:
168+
input("Press Enter when done.\n")
138169

139170
self.print_step(10, "Read CurrentMode attribute")
140171
old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
@@ -143,7 +174,7 @@ class CommonCodes(Enum):
143174

144175
self.print_step(11, "Send ChangeToMode command with NewMode set to %d" % (self.mode_ok))
145176

146-
ret = await self.send_change_to_mode_cmd(newMode=self.mode_ok)
177+
ret = await self.send_clean_change_to_mode_cmd(newMode=self.mode_ok)
147178
asserts.assert_true(ret.status == CommonCodes.SUCCESS.value,
148179
"Changing to mode %d must succeed due to the current state of the device" % (self.mode_ok))
149180

@@ -157,7 +188,7 @@ class CommonCodes(Enum):
157188

158189
self.print_step(13, "Send ChangeToMode command with NewMode set to %d" % (invalid_mode))
159190

160-
ret = await self.send_change_to_mode_cmd(newMode=invalid_mode)
191+
ret = await self.send_clean_change_to_mode_cmd(newMode=invalid_mode)
161192
asserts.assert_true(ret.status == CommonCodes.UNSUPPORTED_MODE.value,
162193
"Attempt to change to invalid mode %d didn't fail as expected" % (invalid_mode))
163194

src/python_testing/TC_RVCCLEANM_2_2.py

+29-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def __init__(self, *args):
3131
self.run_mode_dut = 0
3232
self.old_clean_mode_dut = 0
3333
self.new_clean_mode_th = 0
34+
self.is_ci = False
35+
self.app_pipe = "/tmp/chip_rvc_fifo_"
3436

3537
async def read_mod_attribute_expect_success(self, cluster, attribute):
3638
return await self.read_single_attribute_check_success(
@@ -48,10 +50,14 @@ async def read_clean_supported_modes(self) -> Clusters.Objects.RvcCleanMode.Attr
4850
Clusters.RvcCleanMode.Attributes.SupportedModes)
4951
return ret
5052

51-
async def send_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse:
53+
async def send_clean_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse:
5254
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcCleanMode.Commands.ChangeToMode(newMode=newMode), endpoint=self.endpoint)
5355
return ret
5456

57+
async def send_run_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcRunMode.Commands.ChangeToModeResponse:
58+
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=newMode), endpoint=self.endpoint)
59+
return ret
60+
5561
# Prints the instruction and waits for a user input to continue
5662
def print_instruction(self, step_number, instruction):
5763
self.print_step(step_number, instruction)
@@ -60,18 +66,37 @@ def print_instruction(self, step_number, instruction):
6066
def pics_TC_RVCCLEANM_2_2(self) -> list[str]:
6167
return ["RVCCLEANM.S"]
6268

69+
# Sends and out-of-band command to the rvc-app
70+
def write_to_app_pipe(self, command):
71+
with open(self.app_pipe, "w") as app_pipe:
72+
app_pipe.write(command + "\n")
73+
6374
@async_test_body
6475
async def test_TC_RVCCLEANM_2_2(self):
6576
self.endpoint = self.matter_test_config.endpoint
77+
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
78+
if self.is_ci:
79+
app_pid = self.matter_test_config.app_pid
80+
if app_pid == 0:
81+
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
82+
self.app_pipe = self.app_pipe + str(app_pid)
6683

6784
asserts.assert_true(self.check_pics("RVCCLEANM.S"), "RVCCLEANM.S must be supported")
6885
asserts.assert_true(self.check_pics("RVCRUNM.S.A0000"), "RVCRUNM.S.A0000 must be supported")
6986
asserts.assert_true(self.check_pics("RVCRUNM.S.A0001"), "RVCRUNM.S.A0001 must be supported")
7087

7188
self.print_step(1, "Commissioning, already done")
7289

73-
self.print_instruction(2, "Manually put the device in a state in which the RVC Run Mode "
74-
"cluster’s CurrentMode attribute is set to a mode without the Idle mode tag.")
90+
# Ensure that the device is in the correct state
91+
if self.is_ci:
92+
self.write_to_app_pipe('{"Name": "Reset"}')
93+
94+
self.print_step(
95+
2, "Manually put the device in a state in which the RVC Run Mode cluster’s CurrentMode attribute is set to a mode without the Idle mode tag.")
96+
if self.is_ci:
97+
await self.send_run_change_to_mode_cmd(1)
98+
else:
99+
input("Press Enter when done.\n")
75100

76101
self.print_step(3, "Read the RvcRunMode SupportedModes attribute")
77102
supported_run_modes = await self.read_run_supported_modes()
@@ -115,7 +140,7 @@ async def test_TC_RVCCLEANM_2_2(self):
115140
break
116141

117142
self.print_step(7, "Send ChangeToMode command")
118-
response = await self.send_change_to_mode_cmd(self.new_clean_mode_th)
143+
response = await self.send_clean_change_to_mode_cmd(self.new_clean_mode_th)
119144
asserts.assert_equal(response.status, 3,
120145
"The response should contain a ChangeToModeResponse command "
121146
"with the Status set to InvalidInMode(0x03).")

0 commit comments

Comments
 (0)