From 2a62d3dec5939443ba993828831c398e5621fb28 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 26 Apr 2024 11:39:28 -0400 Subject: [PATCH 01/16] Merged test cases --- src/python_testing/TC_MWOCTRL_2_2.py | 87 ++++++++++++++----- src/python_testing/TC_MWOCTRL_2_3.py | 123 --------------------------- 2 files changed, 67 insertions(+), 143 deletions(-) delete mode 100644 src/python_testing/TC_MWOCTRL_2_3.py diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index a5484c586067c6..a8cac2b03d8b53 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -39,16 +39,25 @@ def desc_TC_MWOCTRL_2_2(self) -> str: def steps_TC_MWOCTRL_2_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "Read the PowerSetting attribute"), - TestStep(3, "Send the SetCookingParameters command"), - TestStep(4, "Read and verify the PowerSetting attribute"), - TestStep(5, "Cause constraint error response"), + TestStep(2, "Set MinPowerValue variable"), + TestStep(3, "Read the MinPower attribute"), + TestStep(4, "Set the MaxPowerValue variable"), + TestStep(5, "Read the MaxPower attribute"), + TestStep(6, "Set the PowerStepValue variable"), + TestStep(7, "Read the PowerStep attribute"), + TestStep(8, "Read the PowerSetting attribute"), + TestStep(9, "Send the SetCookingParameters command"), + TestStep(10, "Read and verify the PowerSetting attribute"), + TestStep(11, "Set the PowerSetting attribute to the minimum value"), + TestStep(12, "Set the PowerSetting attribute to the maximum value"), + TestStep(13, "Cause constraint error response"), ] return steps def pics_TC_MWOCTRL_2_2(self) -> list[str]: pics = [ "MWOCTRL.S", + "MWOCTRL.S.F00", ] return pics @@ -63,40 +72,78 @@ async def test_TC_MWOCTRL_2_2(self): features = Clusters.MicrowaveOvenControl.Bitmaps.Feature commands = Clusters.Objects.MicrowaveOvenControl.Commands - feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - - only_pwrnum_supported = feature_map == features.kPowerAsNumber - - if not only_pwrnum_supported: - logging.info("More than PWRNUM is supported so skipping remaining test steps") + if not feature_map & features.kPowerAsNumber: + logging.info("PWRNUM is not supported so skipping remaining test steps") self.skip_all_remaining_steps(2) return - logging.info("Only the PWRNUM feature is supported so continuing with remaining test steps") + logging.info("The PWRNUM feature is supported so continuing with remaining test steps") + self.step(2) - powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) - asserts.assert_greater_equal(powerValue, 10, "PowerSetting is less than 10") - asserts.assert_less_equal(powerValue, 100, "PowerSetting is greater than 100") - asserts.assert_true(powerValue % 10 == 0, "PowerSetting is not a multiple of 10") + minPowerValue = 10 self.step(3) - newPowerValue = (powerValue+10) % 100 + if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) + logging.info("MinPower is %s" % minPowerValue) + asserts.assert_true(minPowerValue >= 1, "MinPower is less than 1") + + self.step(4) + maxPowerValue = 100 + + self.step(5) + if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + maxPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxPower) + logging.info("MaxPower is %s" % maxPowerValue) + asserts.assert_true(maxPowerValue >= minPowerValue, "MaxPower is less than MinPower") + asserts.assert_true(maxPowerValue <= 100, "MaxPower is greater than 100") + + self.step(6) + powerStepValue = 10 + + self.step(7) + if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) + logging.info("PowerStep is %s" % powerStepValue) + asserts.assert_true(powerStepValue >= 1, "PowerStep is less than 1") + asserts.assert_true(powerStepValue <= maxPowerValue, "PowerStep is greater than MaxPower") + + self.step(8) + powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) + asserts.assert_greater_equal(powerValue, minPowerValue, "PowerSetting is less than the minimum.") + asserts.assert_less_equal(powerValue, maxPowerValue, "PowerSetting is greater than the maxium") + asserts.assert_true((powerValue-minPowerValue) % powerStepValue == 0, "PowerSetting is not a multiple of power step") + + self.step(9) + newPowerValue = (powerValue-minPowerValue) % (maxPowerValue-minPowerValue)+powerStepValue+minPowerValue try: await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) except InteractionModelError as e: asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") - self.step(4) + self.step(10) powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set") - self.step(5) - newPowerValue = 125 + self.step(11) + try: + await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=minPowerValue), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unable to set power value to minimum") + + self.step(12) + try: + await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=maxPowerValue), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unable to set power value to maximum") + + self.step(13) + newPowerValue = maxPowerValue+1 try: await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) asserts.assert_fail("Expected an exception but received none.") except InteractionModelError as e: - asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different error.") + asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response.") if __name__ == "__main__": diff --git a/src/python_testing/TC_MWOCTRL_2_3.py b/src/python_testing/TC_MWOCTRL_2_3.py deleted file mode 100644 index 20a1e730ab620a..00000000000000 --- a/src/python_testing/TC_MWOCTRL_2_3.py +++ /dev/null @@ -1,123 +0,0 @@ -# -# Copyright (c) 2024 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import logging - -import chip.clusters as Clusters -from chip.interaction_model import InteractionModelError, Status -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main -from mobly import asserts - -# This test requires several additional command line arguments -# run with -# --endpoint endpoint - - -class TC_MWOCTRL_2_3(MatterBaseTest): - - async def read_mwoctrl_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.MicrowaveOvenControl - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - def desc_TC_MWOCTRL_2_3(self) -> str: - return "[TC-MWOCTRL-2.3] PWRNUM functionality with DUT as Server" - - def steps_TC_MWOCTRL_2_3(self) -> list[TestStep]: - steps = [ - TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "Read the MinPower attribute"), - TestStep(3, "Read the MaxPower attribute"), - TestStep(4, "Read the PowerStep attribute"), - TestStep(5, "Read the PowerSetting attribute"), - TestStep(6, "Send the SetCookingParameters command"), - TestStep(7, "Read and verify the PowerSetting attribute"), - TestStep(8, "Cause constraint error response"), - ] - return steps - - def pics_TC_MWOCTRL_2_3(self) -> list[str]: - pics = [ - "MWOCTRL.S", - ] - return pics - - @async_test_body - async def test_TC_MWOCTRL_2_3(self): - - endpoint = self.user_params.get("endpoint", 1) - - self.step(1) - attributes = Clusters.MicrowaveOvenControl.Attributes - feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - features = Clusters.MicrowaveOvenControl.Bitmaps.Feature - commands = Clusters.Objects.MicrowaveOvenControl.Commands - - feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - - supports_pwrnum_and_limits = feature_map & (features.kPowerAsNumber or features.kPowerNumberLimits) - - if not supports_pwrnum_and_limits: - logging.info("Device does not support PWRNUM and PWRLMTS so skipping the rest of the tests.") - self.skip_all_remaining_steps(2) - return - - self.step(2) - minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) - logging.info("MinPower is %s" % minPowerValue) - asserts.assert_true(minPowerValue >= 1, "MinPower is less than 1") - - self.step(3) - maxPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxPower) - logging.info("MaxPower is %s" % maxPowerValue) - asserts.assert_true(maxPowerValue >= 1, "MaxPower is less than MinPower") - asserts.assert_true(maxPowerValue <= 100, "MaxPower is greater than 100") - - self.step(4) - powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) - logging.info("PowerStep is %s" % powerStepValue) - asserts.assert_true(powerStepValue >= 1, "PowerStep is less than 1") - asserts.assert_true(powerStepValue <= maxPowerValue, "PowerStep is greater than MaxPower") - - self.step(5) - powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) - logging.info("PowerSetting is %s" % powerValue) - asserts.assert_true(powerValue >= minPowerValue, "PowerSetting is less than MinPower") - asserts.assert_true(powerValue <= maxPowerValue, "PowerSetting is greater than MaxPower") - asserts.assert_true((powerValue-minPowerValue) % powerStepValue == 0, "PowerSetting is not a multiple of 10") - - self.step(6) - newPowerValue = (powerValue-minPowerValue) % (maxPowerValue-minPowerValue)+powerStepValue+minPowerValue - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") - - self.step(7) - powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) - asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set") - - self.step(8) - newPowerValue = maxPowerValue+1 - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) - asserts.assert_fail("Expected an exception but received none.") - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response.") - - -if __name__ == "__main__": - default_matter_test_main() From dd6cc03a03eeadf17086e55fbd24d77faf7bb978 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 26 Apr 2024 12:56:42 -0400 Subject: [PATCH 02/16] Remove removed test --- .github/workflows/tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b495b5f01309f4..40edc3bd1dda7b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -547,7 +547,6 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_5.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_1_2.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' From 67bada458c96a7c9c858b6b871ce45f5e33850b5 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 26 Apr 2024 15:37:27 -0400 Subject: [PATCH 03/16] Update repl tests --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 40edc3bd1dda7b..9476df8b4adf86 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -546,8 +546,8 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_5.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_1_2.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_2_1.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --int-arg PIXIT.RVCRUNM.MODE_CHANGE_OK:0 PIXIT.RVCRUNM.MODE_CHANGE_FAIL:2"' From da224492e757bf3883e4b9016c4b5eb7d1d9d617 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Mon, 6 May 2024 18:58:54 -0400 Subject: [PATCH 04/16] Updates to meet test plan --- .../certification/Test_TC_MWOCTRL_2_1.yaml | 74 ---------- src/python_testing/TC_MWOCTRL_2_1.py | 137 ++++++++++++++++++ src/python_testing/TC_MWOCTRL_2_2.py | 67 ++++++--- 3 files changed, 183 insertions(+), 95 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml create mode 100644 src/python_testing/TC_MWOCTRL_2_1.py diff --git a/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml b/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml deleted file mode 100644 index cd3f26b7e59bb5..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (c) 2024 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 263.1.1. [TC-MWOCTRL-2.1] Primary functionality with DUT as Server - -PICS: - - MWOCTRL.S - -config: - nodeId: 0x12344321 - cluster: "Microwave Oven Control" - endpoint: 1 - -tests: - - label: "Step 1: Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: Read the MaxCookTime attribute" - command: "readAttribute" - attribute: "MaxCookTime" - response: - saveAs: MaxCookTimeValue - constraints: - type: elapsed_s - minValue: 1 - maxValue: 86400 - - - label: "Step 3: Read the CookTime attribute" - command: "readAttribute" - attribute: "CookTime" - response: - constraints: - type: elapsed_s - minValue: 1 - maxValue: MaxCookTimeValue - - - label: "Step 4: Send the SetCookingParameters command" - command: "SetCookingParameters" - arguments: - values: - - name: CookTime - value: 60 - - - label: "Step 5: Read the CookTime attribute" - command: "readAttribute" - attribute: "CookTime" - response: - value: 60 - constraints: - type: elapsed_s - - - label: "Step 6: Read the WattRating attribute" - PICS: MWOCTRL.S.A0008 - command: "readAttribute" - attribute: "WattRating" - response: - constraints: - type: int16u diff --git a/src/python_testing/TC_MWOCTRL_2_1.py b/src/python_testing/TC_MWOCTRL_2_1.py new file mode 100644 index 00000000000000..ae9d254d6b89f2 --- /dev/null +++ b/src/python_testing/TC_MWOCTRL_2_1.py @@ -0,0 +1,137 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +# This test requires several additional command line arguments +# run with +# --endpoint endpoint + + +class TC_MWOCTRL_2_1(MatterBaseTest): + + async def read_mwoctrl_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.MicrowaveOvenControl + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def set_cook_time_expect_success(self, endpoint, value): + commands = Clusters.Objects.MicrowaveOvenControl.Commands + try: + await self.send_single_cmd(cmd=commands.SetCookingParameters(cookTime=value), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + + async def set_bad_cook_time_value_expect_failure(self, endpoint, value): + commands = Clusters.Objects.MicrowaveOvenControl.Commands + try: + await self.send_single_cmd(cmd=Clusters.Objects.MicrowaveOvenControl.Commands.SetCookingParameters(cookTime=value), endpoint=endpoint) + asserts.assert_fail("Expected an exception but received none.") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Expected a CONSTRAINT_ERROR but got a different response.") + + async def read_and_check_cook_time_value(self, endpoint, value): + attributes = Clusters.MicrowaveOvenControl.Attributes + cooktime = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.CookTime) + asserts.assert_equal(cooktime, value, "Cooktime value not as expected") + + def desc_TC_MWOCTRL_2_1(self) -> str: + return "[TC-MWOCTRL-2.1] Primary functionality with DUT as Server" + + def steps_TC_MWOCTRL_2_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read the MaxCookTime attribute and check limits", + "Verify that the DUT response contains an elapsed-s value between 1 and 86400 inclusive. Save value as MaxCookTime." + ), + TestStep(3, "Read the CookTime attribute and check limits", + "Verify that the DUT response contains an elapsed-s value between 1 and MaxCookTime inclusive." + ), + TestStep(4, "Set the CookTime attribute to 60", "Verify DUT responds w/ status SUCCESS(0x00)."), + TestStep(5, "Read the CookTime attribute and check for 60", "Verify that the DUT response contains the CookTime value 60."), + TestStep(6, "Set the CookTime attribute to 1", "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep(7, "Read the CookTime attribute and check for 1", "Verify that the DUT response contains the CookTime value 1."), + TestStep(8, "Set the CookTime attribute to MaxCookTime", "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep(9, "Read the CookTime attribute and check for MaxCookTime", "Verify that the DUT response contains the CookTime value MaxCookTime."), + TestStep(10, "Read the WattRating attribute, if supported", "Verify that the DUT response contains a uint16 value."), + TestStep(11, "Set the CookTime attribute to 0", "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep(12, "Set the CookTime attribute to MaxCookTime+1", "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + ] + return steps + + def pics_TC_MWOCTRL_2_1(self) -> list[str]: + pics = [ + "MWOCTRL.S", + ] + return pics + + @async_test_body + async def test_TC_MWOCTRL_2_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.MicrowaveOvenControl.Attributes + features = Clusters.MicrowaveOvenControl.Bitmaps.Feature + commands = Clusters.Objects.MicrowaveOvenControl.Commands + + self.step(2) + maxCookTime = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxCookTime) + asserts.assert_greater_equal(maxCookTime, 1, "maxCookTime is less than 1") + asserts.assert_less_equal(maxCookTime, 86400, "maxCookTime is greater than 86400") + + self.step(3) + cookTime = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.CookTime) + asserts.assert_greater_equal(cookTime, 1, "cookTime is less than 1") + asserts.assert_less_equal(cookTime, maxCookTime, "cookTime is greater than maxCookTime") + + self.step(4) + newCookTime = 60 + await self.set_cook_time_expect_success(endpoint, newCookTime) + + self.step(5) + await self.read_and_check_cook_time_value(endpoint, newCookTime) + + self.step(6) + await self.set_cook_time_expect_success(endpoint, 1) + + self.step(7) + await self.read_and_check_cook_time_value(endpoint, 1) + + self.step(8) + await self.set_cook_time_expect_success(endpoint, maxCookTime) + + self.step(9) + await self.read_and_check_cook_time_value(endpoint, maxCookTime) + + self.step(10) + if self.pics_guard(self.check_pics("MWOCTRL.S.F01")): + await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.WattRating) + + self.step(11) + await self.set_bad_cook_time_value_expect_failure(endpoint, 0) + + self.step(12) + await self.set_bad_cook_time_value_expect_failure(endpoint, maxCookTime+1) + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index a8cac2b03d8b53..3fa04fb03f63cd 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -33,6 +33,23 @@ async def read_mwoctrl_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.MicrowaveOvenControl return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + async def set_power_setting_expect_success(self, endpoint, value): + try: + await self.send_single_cmd(cmd=Clusters.Objects.MicrowaveOvenControl.Commands.SetCookingParameters(powerSetting=value), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Error while trying to set the power setting.") + + async def set_power_setting_expect_failure(self, endpoint, value): + try: + await self.send_single_cmd(cmd=Clusters.Objects.MicrowaveOvenControl.Commands.SetCookingParameters(powerSetting=value), endpoint=endpoint) + asserts.assert_fail("Expected an exception but received none.") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response: %x", e.status) + + async def read_and_check_power_setting_value(self, endpoint, value): + powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=Clusters.MicrowaveOvenControl.Attributes.PowerSetting) + asserts.assert_equal(powerValue, value, "PowerSetting was not correctly set") + def desc_TC_MWOCTRL_2_2(self) -> str: return "[TC-MWOCTRL-2.2] Secondary functionality with DUT as Server" @@ -49,8 +66,12 @@ def steps_TC_MWOCTRL_2_2(self) -> list[TestStep]: TestStep(9, "Send the SetCookingParameters command"), TestStep(10, "Read and verify the PowerSetting attribute"), TestStep(11, "Set the PowerSetting attribute to the minimum value"), - TestStep(12, "Set the PowerSetting attribute to the maximum value"), - TestStep(13, "Cause constraint error response"), + TestStep(12, "Read and verify the PowerSetting attribute"), + TestStep(13, "Set the PowerSetting attribute to the maximum value"), + TestStep(14, "Read and verify the PowerSetting attribute"), + TestStep(15, "Set PowerSetting to an invalid value"), + TestStep(16, "If PowerStep=1, exit test case."), + TestStep(17, "Set PowerSetting to a value that is not an integer multiple of PowerStep"), ] return steps @@ -116,34 +137,38 @@ async def test_TC_MWOCTRL_2_2(self): self.step(9) newPowerValue = (powerValue-minPowerValue) % (maxPowerValue-minPowerValue)+powerStepValue+minPowerValue - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + await self.set_power_setting_expect_success(endpoint, newPowerValue) self.step(10) - powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) - asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set") + await self.read_and_check_power_setting_value(endpoint, newPowerValue) self.step(11) - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=minPowerValue), endpoint=endpoint) - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.Success, "Unable to set power value to minimum") + await self.set_power_setting_expect_success(endpoint, minPowerValue) self.step(12) - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=maxPowerValue), endpoint=endpoint) - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.Success, "Unable to set power value to maximum") + await self.read_and_check_power_setting_value(endpoint, minPowerValue) self.step(13) + await self.set_power_setting_expect_success(endpoint, maxPowerValue) + + self.step(14) + await self.read_and_check_power_setting_value(endpoint, maxPowerValue) + + self.step(15) newPowerValue = maxPowerValue+1 - try: - await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint) - asserts.assert_fail("Expected an exception but received none.") - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response.") + await self.set_power_setting_expect_failure(endpoint, newPowerValue) + + self.step(16) + if powerStepValue == 1: + self.skip_step(17) + return + + self.step(17) + newPowerValue = minPowerValue + powerStepValue / 2 + logging.info("-------> MinPower = %d", minPowerValue) + logging.info("-------> PowerStep = %d", powerStepValue) + logging.info("-------> newPowerValue = %d", newPowerValue) + await self.set_power_setting_expect_failure(endpoint, newPowerValue) if __name__ == "__main__": From 8b060d785eddce382a495acedbbc5a7b9a5abdcf Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 6 May 2024 22:59:28 +0000 Subject: [PATCH 05/16] Restyled by autopep8 --- src/python_testing/TC_MWOCTRL_2_1.py | 17 ++++++++++------- src/python_testing/TC_MWOCTRL_2_2.py | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/python_testing/TC_MWOCTRL_2_1.py b/src/python_testing/TC_MWOCTRL_2_1.py index ae9d254d6b89f2..3f8c272783ee20 100644 --- a/src/python_testing/TC_MWOCTRL_2_1.py +++ b/src/python_testing/TC_MWOCTRL_2_1.py @@ -60,17 +60,20 @@ def steps_TC_MWOCTRL_2_1(self) -> list[TestStep]: steps = [ TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "Read the MaxCookTime attribute and check limits", - "Verify that the DUT response contains an elapsed-s value between 1 and 86400 inclusive. Save value as MaxCookTime." - ), + "Verify that the DUT response contains an elapsed-s value between 1 and 86400 inclusive. Save value as MaxCookTime." + ), TestStep(3, "Read the CookTime attribute and check limits", - "Verify that the DUT response contains an elapsed-s value between 1 and MaxCookTime inclusive." - ), + "Verify that the DUT response contains an elapsed-s value between 1 and MaxCookTime inclusive." + ), TestStep(4, "Set the CookTime attribute to 60", "Verify DUT responds w/ status SUCCESS(0x00)."), - TestStep(5, "Read the CookTime attribute and check for 60", "Verify that the DUT response contains the CookTime value 60."), + TestStep(5, "Read the CookTime attribute and check for 60", + "Verify that the DUT response contains the CookTime value 60."), TestStep(6, "Set the CookTime attribute to 1", "Verify DUT responds w/ status SUCCESS(0x00)"), - TestStep(7, "Read the CookTime attribute and check for 1", "Verify that the DUT response contains the CookTime value 1."), + TestStep(7, "Read the CookTime attribute and check for 1", + "Verify that the DUT response contains the CookTime value 1."), TestStep(8, "Set the CookTime attribute to MaxCookTime", "Verify DUT responds w/ status SUCCESS(0x00)"), - TestStep(9, "Read the CookTime attribute and check for MaxCookTime", "Verify that the DUT response contains the CookTime value MaxCookTime."), + TestStep(9, "Read the CookTime attribute and check for MaxCookTime", + "Verify that the DUT response contains the CookTime value MaxCookTime."), TestStep(10, "Read the WattRating attribute, if supported", "Verify that the DUT response contains a uint16 value."), TestStep(11, "Set the CookTime attribute to 0", "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), TestStep(12, "Set the CookTime attribute to MaxCookTime+1", "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 3fa04fb03f63cd..0c1aedcd22cfec 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -44,7 +44,8 @@ async def set_power_setting_expect_failure(self, endpoint, value): await self.send_single_cmd(cmd=Clusters.Objects.MicrowaveOvenControl.Commands.SetCookingParameters(powerSetting=value), endpoint=endpoint) asserts.assert_fail("Expected an exception but received none.") except InteractionModelError as e: - asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response: %x", e.status) + asserts.assert_equal(e.status, Status.ConstraintError, + "Expected ConstraintError but received a different response: %x", e.status) async def read_and_check_power_setting_value(self, endpoint, value): powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=Clusters.MicrowaveOvenControl.Attributes.PowerSetting) From a3cb7c7ebcf6394c3267c60f479ca8f3d372f3db Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Mon, 6 May 2024 19:35:14 -0400 Subject: [PATCH 06/16] Fix lint --- src/python_testing/TC_MWOCTRL_2_1.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/python_testing/TC_MWOCTRL_2_1.py b/src/python_testing/TC_MWOCTRL_2_1.py index 3f8c272783ee20..658bdb3ae8e431 100644 --- a/src/python_testing/TC_MWOCTRL_2_1.py +++ b/src/python_testing/TC_MWOCTRL_2_1.py @@ -15,8 +15,6 @@ # limitations under the License. # -import logging - import chip.clusters as Clusters from chip.interaction_model import InteractionModelError, Status from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main @@ -43,7 +41,7 @@ async def set_cook_time_expect_success(self, endpoint, value): async def set_bad_cook_time_value_expect_failure(self, endpoint, value): commands = Clusters.Objects.MicrowaveOvenControl.Commands try: - await self.send_single_cmd(cmd=Clusters.Objects.MicrowaveOvenControl.Commands.SetCookingParameters(cookTime=value), endpoint=endpoint) + await self.send_single_cmd(cmd=commands.SetCookingParameters(cookTime=value), endpoint=endpoint) asserts.assert_fail("Expected an exception but received none.") except InteractionModelError as e: asserts.assert_equal(e.status, Status.ConstraintError, "Expected a CONSTRAINT_ERROR but got a different response.") @@ -93,8 +91,6 @@ async def test_TC_MWOCTRL_2_1(self): self.step(1) attributes = Clusters.MicrowaveOvenControl.Attributes - features = Clusters.MicrowaveOvenControl.Bitmaps.Feature - commands = Clusters.Objects.MicrowaveOvenControl.Commands self.step(2) maxCookTime = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxCookTime) From e904071febd307c45c196e9c7e0173a2492958a8 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Mon, 6 May 2024 19:48:45 -0400 Subject: [PATCH 07/16] Fix lint --- src/python_testing/TC_MWOCTRL_2_2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 0c1aedcd22cfec..12b69ce22d2eae 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -92,7 +92,6 @@ async def test_TC_MWOCTRL_2_2(self): attributes = Clusters.MicrowaveOvenControl.Attributes feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) features = Clusters.MicrowaveOvenControl.Bitmaps.Feature - commands = Clusters.Objects.MicrowaveOvenControl.Commands if not feature_map & features.kPowerAsNumber: logging.info("PWRNUM is not supported so skipping remaining test steps") From 287fdeafe7fd561314d3feef3d7fe2e773c62ded Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Tue, 7 May 2024 11:26:49 -0400 Subject: [PATCH 08/16] Added new python test --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 94d97f7d726418..7011146f8a5d23 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -546,6 +546,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_5.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' From d8e9ef4a59aeb3143227185af0845f2386355e9e Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Tue, 7 May 2024 12:55:35 -0400 Subject: [PATCH 09/16] Add prints for debugging --- src/python_testing/TC_MWOCTRL_2_2.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 12b69ce22d2eae..a728d036cc7a8e 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -136,7 +136,12 @@ async def test_TC_MWOCTRL_2_2(self): asserts.assert_true((powerValue-minPowerValue) % powerStepValue == 0, "PowerSetting is not a multiple of power step") self.step(9) + logging.info("minPowerValue is %s" % minPowerValue) + logging.info("maxPowerValue is %s" % maxPowerValue) + logging.info("powerStepValue is %s" % powerStepValue) + logging.info("powerValue is %s" % powerValue) newPowerValue = (powerValue-minPowerValue) % (maxPowerValue-minPowerValue)+powerStepValue+minPowerValue + logging.info("newPowerValue is %s" % newPowerValue) await self.set_power_setting_expect_success(endpoint, newPowerValue) self.step(10) From 361932997490cdce2cc38a7e758dfc8f2da8096a Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Tue, 7 May 2024 15:39:21 -0400 Subject: [PATCH 10/16] Fix cluster bug. --- .../microwave-oven-control-server.cpp | 2 +- src/python_testing/TC_MWOCTRL_2_2.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp index 4a736cecd01ac6..006311d6f0c9b1 100644 --- a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp +++ b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp @@ -296,7 +296,7 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands:: ChipLogError(Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value is out of range")); VerifyOrExit( - reqPowerSettingNum % powerStepNum == 0, status = Status::InvalidCommand; ChipLogError( + (reqPowerSettingNum - minPowerNum) % powerStepNum == 0, status = Status::ConstraintError; ChipLogError( Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value must be multiple of PowerStep number")); diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index a728d036cc7a8e..9c659cf971b708 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -45,7 +45,7 @@ async def set_power_setting_expect_failure(self, endpoint, value): asserts.assert_fail("Expected an exception but received none.") except InteractionModelError as e: asserts.assert_equal(e.status, Status.ConstraintError, - "Expected ConstraintError but received a different response: %x", e.status) + "Expected ConstraintError but received a different response") async def read_and_check_power_setting_value(self, endpoint, value): powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=Clusters.MicrowaveOvenControl.Attributes.PowerSetting) @@ -103,31 +103,36 @@ async def test_TC_MWOCTRL_2_2(self): self.step(2) minPowerValue = 10 + feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + is_pwrnum_feature_supported = feature_map & features.kPowerAsNumber + is_watts_feature_supported = feature_map & features.kPowerInWatts + is_pwrlmits_feature_supported = feature_map & features.kPowerNumberLimits + self.step(3) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) - logging.info("MinPower is %s" % minPowerValue) asserts.assert_true(minPowerValue >= 1, "MinPower is less than 1") + logging.info("MinPower is %s" % minPowerValue) self.step(4) maxPowerValue = 100 self.step(5) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: maxPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxPower) - logging.info("MaxPower is %s" % maxPowerValue) asserts.assert_true(maxPowerValue >= minPowerValue, "MaxPower is less than MinPower") asserts.assert_true(maxPowerValue <= 100, "MaxPower is greater than 100") + logging.info("MaxPower is %s" % maxPowerValue) self.step(6) powerStepValue = 10 self.step(7) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) - logging.info("PowerStep is %s" % powerStepValue) asserts.assert_true(powerStepValue >= 1, "PowerStep is less than 1") asserts.assert_true(powerStepValue <= maxPowerValue, "PowerStep is greater than MaxPower") + logging.info("PowerStep is %s" % powerStepValue) self.step(8) powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) From d4d521127d1e33a1d5045acc39d167c5423b24f6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 May 2024 19:42:23 +0000 Subject: [PATCH 11/16] Restyled by clang-format --- .../microwave-oven-control-server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp index 006311d6f0c9b1..d47742570ed2e0 100644 --- a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp +++ b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp @@ -296,7 +296,7 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands:: ChipLogError(Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value is out of range")); VerifyOrExit( - (reqPowerSettingNum - minPowerNum) % powerStepNum == 0, status = Status::ConstraintError; ChipLogError( + (reqPowerSettingNum - minPowerNum) % powerStepNum == 0, status = Status::ConstraintError; ChipLogError( Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value must be multiple of PowerStep number")); From 5f02a2bb24406fc5d26375f513e56ccebf46c9a0 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Tue, 7 May 2024 16:43:30 -0400 Subject: [PATCH 12/16] Fix lint --- src/python_testing/TC_MWOCTRL_2_2.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 9c659cf971b708..190cf3b6597fbb 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -92,8 +92,10 @@ async def test_TC_MWOCTRL_2_2(self): attributes = Clusters.MicrowaveOvenControl.Attributes feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) features = Clusters.MicrowaveOvenControl.Bitmaps.Feature + is_pwrlmits_feature_supported = feature_map & features.kPowerNumberLimits + is_pwrnum_feature_supported = feature_map & features.kPowerAsNumber - if not feature_map & features.kPowerAsNumber: + if not is_pwrnum_feature_supported: logging.info("PWRNUM is not supported so skipping remaining test steps") self.skip_all_remaining_steps(2) return @@ -103,10 +105,6 @@ async def test_TC_MWOCTRL_2_2(self): self.step(2) minPowerValue = 10 - feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - is_pwrnum_feature_supported = feature_map & features.kPowerAsNumber - is_watts_feature_supported = feature_map & features.kPowerInWatts - is_pwrlmits_feature_supported = feature_map & features.kPowerNumberLimits self.step(3) if is_pwrlmits_feature_supported: From 96bdcd25bccbc7d34f136203b4b79073192a2e2a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 May 2024 20:44:03 +0000 Subject: [PATCH 13/16] Restyled by autopep8 --- src/python_testing/TC_MWOCTRL_2_2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 190cf3b6597fbb..c7f126509d85e8 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -105,7 +105,6 @@ async def test_TC_MWOCTRL_2_2(self): self.step(2) minPowerValue = 10 - self.step(3) if is_pwrlmits_feature_supported: minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) From 11bd78966f4e2ce913779e3c7b13e21cc541dec3 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Wed, 8 May 2024 14:53:49 -0400 Subject: [PATCH 14/16] Update TP --- src/python_testing/TC_MWOCTRL_2_2.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index c7f126509d85e8..099c283140d770 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -108,7 +108,8 @@ async def test_TC_MWOCTRL_2_2(self): self.step(3) if is_pwrlmits_feature_supported: minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) - asserts.assert_true(minPowerValue >= 1, "MinPower is less than 1") + asserts.assert_greater_equal(minPowerValue, 1, "MinPower is less than 1") + asserts.assert_less_equal(minPowerValue, 99, "MinPower is less than 1") logging.info("MinPower is %s" % minPowerValue) self.step(4) @@ -117,8 +118,8 @@ async def test_TC_MWOCTRL_2_2(self): self.step(5) if is_pwrlmits_feature_supported: maxPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxPower) - asserts.assert_true(maxPowerValue >= minPowerValue, "MaxPower is less than MinPower") - asserts.assert_true(maxPowerValue <= 100, "MaxPower is greater than 100") + asserts.assert_greater(maxPowerValue, minPowerValue, "MaxPower is less than MinPower") + asserts.assert_less(maxPowerValue, 100, "MaxPower is greater than 100") logging.info("MaxPower is %s" % maxPowerValue) self.step(6) @@ -127,8 +128,9 @@ async def test_TC_MWOCTRL_2_2(self): self.step(7) if is_pwrlmits_feature_supported: powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) - asserts.assert_true(powerStepValue >= 1, "PowerStep is less than 1") - asserts.assert_true(powerStepValue <= maxPowerValue, "PowerStep is greater than MaxPower") + asserts.assert_greater_equal(powerStepValue, 1, "PowerStep is less than 1") + asserts.assert_less_equal(powerStepValue, maxPowerValue, "PowerStep is greater than MaxPower") + asserts.assert_true((MaxPower - MinPower) % PowerStep == 0, "PowerStep is not correct for MaxPower - MinPower") logging.info("PowerStep is %s" % powerStepValue) self.step(8) From 447682817fe6853a6068978160ae630fb9d2e465 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Wed, 8 May 2024 15:07:36 -0400 Subject: [PATCH 15/16] Fix names --- src/python_testing/TC_MWOCTRL_2_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 099c283140d770..4a01be3a8fca82 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -130,7 +130,7 @@ async def test_TC_MWOCTRL_2_2(self): powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) asserts.assert_greater_equal(powerStepValue, 1, "PowerStep is less than 1") asserts.assert_less_equal(powerStepValue, maxPowerValue, "PowerStep is greater than MaxPower") - asserts.assert_true((MaxPower - MinPower) % PowerStep == 0, "PowerStep is not correct for MaxPower - MinPower") + asserts.assert_true((maxPowerValue - minPowerValue) % powerStepValue == 0, "PowerStep is not correct for MaxPower - MinPower") logging.info("PowerStep is %s" % powerStepValue) self.step(8) From f51e912992a0c1884835f8dd15396fe21a28d4b4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 8 May 2024 19:08:27 +0000 Subject: [PATCH 16/16] Restyled by autopep8 --- src/python_testing/TC_MWOCTRL_2_2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index 4a01be3a8fca82..ae496f6a669387 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -130,7 +130,8 @@ async def test_TC_MWOCTRL_2_2(self): powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) asserts.assert_greater_equal(powerStepValue, 1, "PowerStep is less than 1") asserts.assert_less_equal(powerStepValue, maxPowerValue, "PowerStep is greater than MaxPower") - asserts.assert_true((maxPowerValue - minPowerValue) % powerStepValue == 0, "PowerStep is not correct for MaxPower - MinPower") + asserts.assert_true((maxPowerValue - minPowerValue) % powerStepValue == + 0, "PowerStep is not correct for MaxPower - MinPower") logging.info("PowerStep is %s" % powerStepValue) self.step(8)