Skip to content

Commit 6560a69

Browse files
committed
Python Scripts TC_RVCCLEANM_2_2.py and TC_RVCRUNM_2_2.py updated
* Updated the python script TC_RVCCLEANM_2_2.py with two new steps '7a' For reading FeatureMap Attribute and '7b' for send ChangeToMode Command * Updated the python script TC_RVCRUNM_2_2.py with two new steps '6a' For reading FeatureMap Attribute and '6b' for send ChangeToMode Command * Updated TC_RVCOPSTATE_2_4.py with updated PICS as per Test Plan
1 parent e1f29bd commit 6560a69

File tree

3 files changed

+65
-17
lines changed

3 files changed

+65
-17
lines changed

src/python_testing/TC_RVCCLEANM_2_2.py

+35-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@
2727
# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
2828
# === END CI TEST ARGUMENTS ===
2929

30+
import enum
3031
from time import sleep
3132

3233
import chip.clusters as Clusters
33-
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
34+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches
3435
from mobly import asserts
3536

37+
class RvcStatusEnum(enum.IntEnum):
38+
# TODO remove this class once InvalidInMode response code is implemented in python SDK
39+
Success = 0x0
40+
UnsupportedMode = 0x1
41+
GenericFailure = 0x2
42+
InvalidInMode = 0x3
3643

3744
class TC_RVCCLEANM_2_2(MatterBaseTest):
3845

@@ -64,6 +71,11 @@ async def read_clean_supported_modes(self) -> Clusters.Objects.RvcCleanMode.Attr
6471
Clusters.RvcCleanMode.Attributes.SupportedModes)
6572
return ret
6673

74+
async def read_feature_map_attribute(self):
75+
ret = await self.read_mod_attribute_expect_success(Clusters.RvcCleanMode,
76+
Clusters.RvcCleanMode.Attributes.FeatureMap)
77+
return ret
78+
6779
async def send_clean_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcCleanMode.Commands.ChangeToModeResponse:
6880
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcCleanMode.Commands.ChangeToMode(newMode=newMode), endpoint=self.endpoint)
6981
return ret
@@ -90,6 +102,9 @@ def write_to_app_pipe(self, command):
90102

91103
@async_test_body
92104
async def test_TC_RVCCLEANM_2_2(self):
105+
# TODO Replace 0x8000 with python object of RVCCLEAN FEATURE bit map when implemented
106+
# 0x8000 corresponds to 16 bit DIRECTMODECH Feature map
107+
self.directmodech_bit_map = 0x8000
93108
self.endpoint = self.matter_test_config.endpoint
94109
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
95110
if self.is_ci:
@@ -157,11 +172,25 @@ async def test_TC_RVCCLEANM_2_2(self):
157172
self.new_clean_mode_th = mode
158173
break
159174

160-
self.print_step(7, "Send ChangeToMode command")
161-
response = await self.send_clean_change_to_mode_cmd(self.new_clean_mode_th)
162-
asserts.assert_equal(response.status, 3,
163-
"The response should contain a ChangeToModeResponse command "
164-
"with the Status set to InvalidInMode(0x03).")
175+
self.print_step("7a", "Read FeatureMap Attribute")
176+
directmodech = await self.read_feature_map_attribute()
177+
directmode_enabled = directmodech & self.directmodech_bit_map
178+
179+
self.print_step("7b", "Send ChangeToMode command")
180+
if directmode_enabled:
181+
response = await self.send_clean_change_to_mode_cmd(self.new_clean_mode_th)
182+
asserts.assert_true(type_matches(response, Clusters.RvcCleanMode.Commands.ChangeToModeResponse),
183+
"The response should ChangeToModeResponse command")
184+
asserts.assert_equal(response.status, RvcStatusEnum.Success,
185+
"The response should contain a ChangeToModeResponse command "
186+
"with the Status set to Success(0x0).")
187+
else:
188+
response = await self.send_clean_change_to_mode_cmd(self.new_clean_mode_th)
189+
asserts.assert_true(type_matches(response, Clusters.RvcCleanMode.Commands.ChangeToModeResponse),
190+
"The response should ChangeToModeResponse command")
191+
asserts.assert_equal(response.status, RvcStatusEnum.InvalidInMode,
192+
"The response should contain a ChangeToModeResponse command "
193+
"with the Status set to InvalidInMode(0x03).")
165194

166195

167196
if __name__ == "__main__":

src/python_testing/TC_RVCOPSTATE_2_4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def test_TC_RVCOPSTATE_2_4(self):
114114

115115
asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported")
116116
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported")
117-
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C128.Rsp"), "RVCOPSTATE.S.C128.Rsp must be supported")
117+
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C80.Rsp"), "RVCOPSTATE.S.C80.Rsp must be supported")
118118

119119
op_states = Clusters.OperationalState.Enums.OperationalStateEnum
120120
rvc_op_states = Clusters.RvcOperationalState.Enums.OperationalStateEnum

src/python_testing/TC_RVCRUNM_2_2.py

+29-10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --int-arg PIXIT.RVCRUNM.MODE_A:1 PIXIT.RVCRUNM.MODE_B:2
2828
# === END CI TEST ARGUMENTS ===
2929

30+
import enum
3031
from time import sleep
3132

3233
import chip.clusters as Clusters
@@ -37,18 +38,25 @@
3738
# Run the test with
3839
# --int-arg PIXIT.RVCRUNM.MODE_A:<mode id> PIXIT.RVCRUNM.MODE_B:<mode id>
3940

41+
class RvcStatusEnum(enum.IntEnum):
42+
# TODO remove this class once InvalidInMode response code is implemented in python SDK
43+
Success = 0x0
44+
UnsupportedMode = 0x1
45+
GenericFailure = 0x2
46+
InvalidInMode = 0x3
47+
4048

4149
def error_enum_to_text(error_enum):
4250
try:
4351
return f'{Clusters.RvcRunMode.Enums.ModeTag(error_enum).name} 0x{error_enum:02x}'
4452
except AttributeError:
45-
if error_enum == 0:
53+
if error_enum == RvcStatusEnum.Success:
4654
return "Success(0x00)"
47-
elif error_enum == 0x1:
55+
elif error_enum == RvcStatusEnum.UnsupportedMode:
4856
return "UnsupportedMode(0x01)"
49-
elif error_enum == 0x2:
57+
elif error_enum == RvcStatusEnum.GenericFailure:
5058
return "GenericFailure(0x02)"
51-
elif error_enum == 0x3:
59+
elif error_enum == RvcStatusEnum.InvalidInMode:
5260
return "InvalidInMode(0x03)"
5361

5462
raise AttributeError("Unknown Enum value")
@@ -122,6 +130,9 @@ async def test_TC_RVCRUNM_2_2(self):
122130
"PIXIT.RVCRUNM.MODE_A:<mode id> \n"
123131
"PIXIT.RVCRUNM.MODE_B:<mode id>")
124132

133+
# TODO Replace 0x8000 with python object of RVCRUN FEATURE bit when implemented
134+
# 0x8000 corresponds to 16 bit DIRECTMODECH Feature map
135+
self.directmodech_bit_map = 0x8000
125136
self.endpoint = self.matter_test_config.endpoint
126137
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
127138
self.mode_a = self.matter_test_config.global_test_params['PIXIT.RVCRUNM.MODE_A']
@@ -193,15 +204,23 @@ async def test_TC_RVCRUNM_2_2(self):
193204
asserts.assert_true(idle_tag_present, "The device must be in a mode with the Idle (0x4000) mode tag.")
194205

195206
self.print_step(5, "Send ChangeToMode MODE_A command")
196-
await self.send_change_to_mode_with_check(self.mode_a, 0)
207+
await self.send_change_to_mode_with_check(self.mode_a, RvcStatusEnum.Success)
197208
# This step is not described in the test plan, but it ought to be
198209
await self.read_current_mode_with_check(self.mode_a)
199210

200-
self.print_step(6, "Send ChangeToMode MODE_B command")
201-
await self.send_change_to_mode_with_check(self.mode_b, 3)
211+
self.print_step("6a", "Read Attribute FeatureMap")
212+
directmodech = await self.read_mod_attribute_expect_success(cluster=Clusters.RvcRunMode,
213+
attribute=Clusters.RvcRunMode.Attributes.FeatureMap)
214+
directmode_enabled = directmodech & self.directmodech_bit_map
215+
216+
self.print_step('6b', "Send ChangeToMode MODE_B command")
217+
if directmode_enabled:
218+
await self.send_change_to_mode_with_check(self.mode_b, RvcStatusEnum.Success)
219+
else:
220+
await self.send_change_to_mode_with_check(self.mode_b, RvcStatusEnum.InvalidInMode)
202221

203222
self.print_step(7, "Send ChangeToMode idle command")
204-
await self.send_change_to_mode_with_check(self.idle_mode_dut, 0)
223+
await self.send_change_to_mode_with_check(self.idle_mode_dut, RvcStatusEnum.Success)
205224
# This step is not described in the test plan, but it ought to be
206225
await self.read_current_mode_with_check(self.idle_mode_dut)
207226

@@ -228,12 +247,12 @@ async def test_TC_RVCRUNM_2_2(self):
228247
"Expected RVCOPSTATE's OperationalState attribute to be one of Stopped(0x00), Paused(0x02), Charging(0x41) or Docked(0x42)")
229248

230249
self.print_step(11, "Send ChangeToMode MODE_B command")
231-
await self.send_change_to_mode_with_check(self.mode_b, 0)
250+
await self.send_change_to_mode_with_check(self.mode_b, RvcStatusEnum.Success)
232251
# This step is not described in the test plan, but it ought to be
233252
await self.read_current_mode_with_check(self.mode_b)
234253

235254
self.print_step(12, "Send ChangeToMode idle command")
236-
await self.send_change_to_mode_with_check(self.idle_mode_dut, 0)
255+
await self.send_change_to_mode_with_check(self.idle_mode_dut, RvcStatusEnum.Success)
237256
# This step is not described in the test plan, but it ought to be
238257
await self.read_current_mode_with_check(self.idle_mode_dut)
239258

0 commit comments

Comments
 (0)