From e2642bfdaf2f7893e8e4b1c72d960ac6a646409a Mon Sep 17 00:00:00 2001 From: Duyen Tran Date: Thu, 27 Jul 2023 13:05:25 -0400 Subject: [PATCH 1/3] check if we can test mode failure --- src/python_testing/TC_RVCCLEANM_2_1.py | 39 +++++++++++++++----------- src/python_testing/TC_RVCRUNM_2_1.py | 39 +++++++++++++++----------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/python_testing/TC_RVCCLEANM_2_1.py b/src/python_testing/TC_RVCCLEANM_2_1.py index 3c58a7e11795ea..9a8f63404899f6 100644 --- a/src/python_testing/TC_RVCCLEANM_2_1.py +++ b/src/python_testing/TC_RVCCLEANM_2_1.py @@ -50,10 +50,14 @@ async def test_TC_RVCCLEANM_2_1(self): asserts.assert_true('PIXIT_MODEFAIL' in self.matter_test_config.global_test_params, "PIXIT_MODEFAIL must be included on the command line in " "the --int-arg flag as PIXIT_MODEFAIL:") + asserts.assert_true('pixit_can_test_mode_failure' in self.matter_test_config.global_test_params, + "PIXIT_CAN_TEST_MODE_FAILURE must be included on the command line in " + "the --bool-arg flag as PIXIT_CAN_TEST_MODE_FAILURE:") self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] self.modeok = self.matter_test_config.global_test_params['PIXIT_MODEOK'] self.modefail = self.matter_test_config.global_test_params['PIXIT_MODEFAIL'] + self.can_test_mode_failure = self.matter_test_config.global_test_params['pixit_can_test_mode_failure'] asserts.assert_true(self.check_pics("RVCCLEANM.S.A0000"), "RVCCLEANM.S.A0000 must be supported") asserts.assert_true(self.check_pics("RVCCLEANM.S.A0001"), "RVCCLEANM.S.A0001 must be supported") @@ -97,30 +101,31 @@ class CommonCodes(Enum): ret = await self.send_change_to_mode_cmd(newMode=old_current_mode) asserts.assert_true(ret.status == CommonCodes.SUCCESS.value, "Changing the mode to the current mode should be a no-op") - self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modefail)) - input("Press Enter when done.\n") + if self.can_test_mode_failure is True: + self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modefail)) + input("Press Enter when done.\n") - self.print_step(6, "Read CurrentMode attribute") - old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + self.print_step(6, "Read CurrentMode attribute") + old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - logging.info("CurrentMode: %s" % (old_current_mode)) + logging.info("CurrentMode: %s" % (old_current_mode)) - self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.modefail)) + self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.modefail)) - ret = await self.send_change_to_mode_cmd(newMode=self.modefail) - st = ret.status - is_mfg_code = st in range(0x80, 0xC0) - is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcCleanCodes) or is_mfg_code - asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) - st_text_len = len(ret.statusText) - asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len)) + ret = await self.send_change_to_mode_cmd(newMode=self.modefail) + st = ret.status + is_mfg_code = st in range(0x80, 0xC0) + is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcCleanCodes) or is_mfg_code + asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) + st_text_len = len(ret.statusText) + asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len)) - self.print_step(8, "Read CurrentMode attribute") - current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + self.print_step(8, "Read CurrentMode attribute") + current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - logging.info("CurrentMode: %s" % (current_mode)) + logging.info("CurrentMode: %s" % (current_mode)) - asserts.assert_true(current_mode == old_current_mode, "CurrentMode changed after failed ChangeToMode command!") + asserts.assert_true(current_mode == old_current_mode, "CurrentMode changed after failed ChangeToMode command!") self.print_step(9, "Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self.modeok)) input("Press Enter when done.\n") diff --git a/src/python_testing/TC_RVCRUNM_2_1.py b/src/python_testing/TC_RVCRUNM_2_1.py index bc9ff11da23db9..cefd55a155c325 100644 --- a/src/python_testing/TC_RVCRUNM_2_1.py +++ b/src/python_testing/TC_RVCRUNM_2_1.py @@ -50,10 +50,14 @@ async def test_TC_RVCRUNM_2_1(self): asserts.assert_true('PIXIT_MODEFAIL' in self.matter_test_config.global_test_params, "PIXIT_MODEFAIL must be included on the command line in " "the --int-arg flag as PIXIT_MODEFAIL:") + asserts.assert_true('pixit_can_test_mode_failure' in self.matter_test_config.global_test_params, + "PIXIT_CAN_TEST_MODE_FAILURE must be included on the command line in " + "the --bool-arg flag as PIXIT_CAN_TEST_MODE_FAILURE:") self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] self.modeok = self.matter_test_config.global_test_params['PIXIT_MODEOK'] self.modefail = self.matter_test_config.global_test_params['PIXIT_MODEFAIL'] + self.can_test_mode_failure = self.matter_test_config.global_test_params['pixit_can_test_mode_failure'] asserts.assert_true(self.check_pics("RVCRUNM.S.A0000"), "RVCRUNM.S.A0000 must be supported") asserts.assert_true(self.check_pics("RVCRUNM.S.A0001"), "RVCRUNM.S.A0001 must be supported") @@ -97,30 +101,31 @@ class CommonCodes(Enum): ret = await self.send_change_to_mode_cmd(newMode=old_current_mode) asserts.assert_true(ret.status == CommonCodes.SUCCESS.value, "Changing the mode to the current mode should be a no-op") - self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modefail)) - input("Press Enter when done.\n") + if self.can_test_mode_failure is True: + self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modefail)) + input("Press Enter when done.\n") - self.print_step(6, "Read CurrentMode attribute") - old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + self.print_step(6, "Read CurrentMode attribute") + old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - logging.info("CurrentMode: %s" % (old_current_mode)) + logging.info("CurrentMode: %s" % (old_current_mode)) - self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.modefail)) + self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.modefail)) - ret = await self.send_change_to_mode_cmd(newMode=self.modefail) - st = ret.status - is_mfg_code = st in range(0x80, 0xC0) - is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcRunCodes) or is_mfg_code - asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) - st_text_len = len(ret.statusText) - asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len)) + ret = await self.send_change_to_mode_cmd(newMode=self.modefail) + st = ret.status + is_mfg_code = st in range(0x80, 0xC0) + is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcRunCodes) or is_mfg_code + asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) + st_text_len = len(ret.statusText) + asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len)) - self.print_step(8, "Read CurrentMode attribute") - current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + self.print_step(8, "Read CurrentMode attribute") + current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - logging.info("CurrentMode: %s" % (current_mode)) + logging.info("CurrentMode: %s" % (current_mode)) - asserts.assert_true(current_mode == old_current_mode, "CurrentMode changed after failed ChangeToMode command!") + asserts.assert_true(current_mode == old_current_mode, "CurrentMode changed after failed ChangeToMode command!") self.print_step(9, "Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self.modeok)) input("Press Enter when done.\n") From 9f1281239b28d0731c5564a5efcbba0df13e0f45 Mon Sep 17 00:00:00 2001 From: Duyen Tran Date: Thu, 27 Jul 2023 14:47:01 -0400 Subject: [PATCH 2/3] remove whitespace --- src/python_testing/TC_RVCCLEANM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_RVCCLEANM_2_1.py b/src/python_testing/TC_RVCCLEANM_2_1.py index 9a8f63404899f6..d2d9f9e78b92ae 100644 --- a/src/python_testing/TC_RVCCLEANM_2_1.py +++ b/src/python_testing/TC_RVCCLEANM_2_1.py @@ -52,7 +52,7 @@ async def test_TC_RVCCLEANM_2_1(self): "the --int-arg flag as PIXIT_MODEFAIL:") asserts.assert_true('pixit_can_test_mode_failure' in self.matter_test_config.global_test_params, "PIXIT_CAN_TEST_MODE_FAILURE must be included on the command line in " - "the --bool-arg flag as PIXIT_CAN_TEST_MODE_FAILURE:") + "the --bool-arg flag as PIXIT_CAN_TEST_MODE_FAILURE:") self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] self.modeok = self.matter_test_config.global_test_params['PIXIT_MODEOK'] From 2c6018d0f5ca482619adda75b0f2b70f6d908c3c Mon Sep 17 00:00:00 2001 From: Duyen Tran Date: Thu, 27 Jul 2023 15:22:01 -0400 Subject: [PATCH 3/3] clean up --- src/python_testing/TC_RVCCLEANM_2_1.py | 3 ++- src/python_testing/TC_RVCRUNM_2_1.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_RVCCLEANM_2_1.py b/src/python_testing/TC_RVCCLEANM_2_1.py index d2d9f9e78b92ae..8a2683c2317472 100644 --- a/src/python_testing/TC_RVCCLEANM_2_1.py +++ b/src/python_testing/TC_RVCCLEANM_2_1.py @@ -116,7 +116,8 @@ class CommonCodes(Enum): st = ret.status is_mfg_code = st in range(0x80, 0xC0) is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcCleanCodes) or is_mfg_code - asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) + asserts.assert_true( + is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) st_text_len = len(ret.statusText) asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len)) diff --git a/src/python_testing/TC_RVCRUNM_2_1.py b/src/python_testing/TC_RVCRUNM_2_1.py index cefd55a155c325..f9bd8937ae59bb 100644 --- a/src/python_testing/TC_RVCRUNM_2_1.py +++ b/src/python_testing/TC_RVCRUNM_2_1.py @@ -116,7 +116,8 @@ class CommonCodes(Enum): st = ret.status is_mfg_code = st in range(0x80, 0xC0) is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st in rvcRunCodes) or is_mfg_code - asserts.assert_true(is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) + asserts.assert_true( + is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modefail)) st_text_len = len(ret.statusText) asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len))