From b0629e808f7345a080a641286c4d14913dac32e9 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 9 Feb 2024 09:26:53 -0500 Subject: [PATCH 1/4] Fixing bad history --- .github/workflows/tests.yaml | 13 +- BUILD.gn | 12 ++ .../include/microwave-oven-device.h | 2 +- scripts/build/builders/host.py | 4 +- scripts/build/gn_gen_cirque.sh | 2 +- scripts/tests/chiptest/__init__.py | 2 + scripts/tests/chiptest/linux.py | 1 + scripts/tests/chiptest/test_definition.py | 6 +- scripts/tests/run_test_suite.py | 9 +- .../microwave-oven-control-server.cpp | 2 +- src/app/tests/suites/certification/PICS.yaml | 24 +++ .../certification/Test_TC_MWOCTRL_1_1.yaml | 170 ++++++++++++++++++ .../certification/Test_TC_MWOCTRL_2_1.yaml | 74 ++++++++ .../certification/Test_TC_MWOCTRL_2_5.yaml | 55 ++++++ .../certification/Test_TC_MWOM_1_1.yaml | 94 ++++++++++ .../tests/suites/certification/ci-pics-values | 9 + .../data_model/controller-clusters.zap | 2 +- src/python_testing/TC_MWOCTRL_2_2.py | 94 ++++++++++ src/python_testing/TC_MWOCTRL_2_3.py | 114 ++++++++++++ src/python_testing/TC_MWOCTRL_2_4.py | 99 ++++++++++ src/python_testing/TC_MWOM_1_2.py | 107 +++++++++++ 21 files changed, 886 insertions(+), 9 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_MWOCTRL_1_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_MWOCTRL_2_5.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_MWOM_1_1.yaml create mode 100644 src/python_testing/TC_MWOCTRL_2_2.py create mode 100644 src/python_testing/TC_MWOCTRL_2_3.py create mode 100644 src/python_testing/TC_MWOCTRL_2_4.py create mode 100644 src/python_testing/TC_MWOM_1_2.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fbaf631aaf7733..ed28ebb62d9b9b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -212,6 +212,7 @@ jobs: --target linux-x64-tv-app-${BUILD_VARIANT} \ --target linux-x64-bridge-${BUILD_VARIANT} \ --target linux-x64-lit-icd-${BUILD_VARIANT} \ + --target linux-x64-microwave-oven-${BUILD_VARIANT} \ build \ --copy-artifacts-to objdir-clone \ " @@ -232,6 +233,7 @@ jobs: --tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ + --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ " - name: Run purposeful failure tests using the python parser sending commands to chip-tool @@ -271,6 +273,7 @@ jobs: --tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ + --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ " - name: Run Tests using chip-repl (including slow) if: github.event_name == 'push' @@ -288,6 +291,7 @@ jobs: --tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ + --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ " - name: Uploading core files uses: actions/upload-artifact@v4 @@ -354,6 +358,7 @@ jobs: --target darwin-x64-tv-app-${BUILD_VARIANT} \ --target darwin-x64-bridge-${BUILD_VARIANT} \ --target darwin-x64-lit-icd-${BUILD_VARIANT} \ + --target darwin-x64-microwave-oven-${BUILD_VARIANT} \ build \ --copy-artifacts-to objdir-clone \ " @@ -374,7 +379,8 @@ jobs: --ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \ --tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/darwin-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ - --lit-icd-app ./out/darwin-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ + --lit-icd-app ./out/darwin-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ + --microwave-oven-app ./out/darwin-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ " - name: Run purposeful failure tests using the python parser sending commands to chip-tool @@ -453,6 +459,7 @@ jobs: --target linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test \ + --target linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-python-bindings \ build \ --copy-artifacts-to objdir-clone \ @@ -512,6 +519,10 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--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 --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--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/TestTimeSyncTrustedTimeSourceRunner.py' + 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"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/BUILD.gn b/BUILD.gn index 89861ea79af5d0..e201b56ceac00d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -347,6 +347,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { enable_linux_lighting_app_build = enable_default_builds && (host_os == "linux" || host_os == "mac") + # Build the Linux microwave oven app example. + enable_microwave_oven_app_build = + enable_default_builds && (host_os == "linux" || host_os == "mac") + # Build the Linux thermostat app example. enable_linux_thermostat_app_build = enable_default_builds && (host_os == "linux" || host_os == "mac") @@ -594,6 +598,14 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { extra_build_deps += [ ":linux_bridge_app" ] } + if (enable_microwave_oven_app_build) { + group("linux_microwave_oven_app") { + deps = [ "${chip_root}/examples/microwave-oven-app/linux(${standalone_toolchain})" ] + } + + extra_build_deps += [ ":linux_microwave_oven_app" ] + } + if (enable_linux_lighting_app_build) { group("linux_lighting_app") { deps = [ diff --git a/examples/microwave-oven-app/microwave-oven-common/include/microwave-oven-device.h b/examples/microwave-oven-app/microwave-oven-common/include/microwave-oven-device.h index 2775d2a3227812..4e88aa1117c21e 100644 --- a/examples/microwave-oven-app/microwave-oven-common/include/microwave-oven-device.h +++ b/examples/microwave-oven-app/microwave-oven-common/include/microwave-oven-device.h @@ -230,7 +230,7 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate, static constexpr uint8_t kMaxPowerNum = 90u; static constexpr uint8_t kPowerStepNum = 10u; static constexpr uint32_t kMaxCookTimeSec = 86400u; - static constexpr uint8_t kDefaultPowerSettingNum = 100u; + static constexpr uint8_t kDefaultPowerSettingNum = kMaxPowerNum; // define the mode value static constexpr uint8_t kModeNormal = 0u; diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index e11d5c2d43779a..7b7a02d421f097 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -228,8 +228,8 @@ def OutputNames(self): yield 'dishwasher-app' yield 'dishwasher-app.map' elif self == HostApp.MICROWAVE_OVEN: - yield 'microwave-oven-app' - yield 'microwave-oven-app.map' + yield 'chip-microwave-oven-app' + yield 'chip-microwave-oven-app.map' elif self == HostApp.REFRIGERATOR: yield 'refrigerator-app' yield 'refrigerator-app.map' diff --git a/scripts/build/gn_gen_cirque.sh b/scripts/build/gn_gen_cirque.sh index d6f6bd86905a0e..a0713f571189ab 100755 --- a/scripts/build/gn_gen_cirque.sh +++ b/scripts/build/gn_gen_cirque.sh @@ -36,7 +36,7 @@ echo "Setup build environment" source "./scripts/activate.sh" echo "Build: GN configure" -gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args out/debug --args='target_os="all"'"chip_build_tests=false chip_enable_wifi=false chip_im_force_fabric_quota_check=true enable_default_builds=false enable_host_gcc_build=true enable_standalone_chip_tool_build=true enable_linux_all_clusters_app_build=true enable_linux_lighting_app_build=true enable_linux_lit_icd_app_build=true" +gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args out/debug --args='target_os="all"'"chip_build_tests=false chip_enable_wifi=false chip_im_force_fabric_quota_check=true enable_default_builds=false enable_host_gcc_build=true enable_standalone_chip_tool_build=true enable_linux_all_clusters_app_build=true enable_linux_lighting_app_build=true enable_microwave_oven_app_build=true enable_linux_lit_icd_app_build=true" echo "Build: Ninja build" time ninja -C out/debug all check diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index dba11f15d44c1e..82006643481fd2 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -299,6 +299,8 @@ def target_for_name(name: str): return TestTarget.BRIDGE if name.startswith("TestIcd") or name.startswith("Test_TC_ICDM_"): return TestTarget.LIT_ICD + if name.startswith("Test_TC_MWOCTRL_") or name.startswith("Test_TC_MWOM_"): + return TestTarget.MWO return TestTarget.ALL_CLUSTERS diff --git a/scripts/tests/chiptest/linux.py b/scripts/tests/chiptest/linux.py index 9668e566671b3d..1d679ee236a3fd 100644 --- a/scripts/tests/chiptest/linux.py +++ b/scripts/tests/chiptest/linux.py @@ -182,6 +182,7 @@ def PathsWithNetworkNamespaces(paths: ApplicationPaths) -> ApplicationPaths: ota_requestor_app='ip netns exec app'.split() + paths.ota_requestor_app, tv_app='ip netns exec app'.split() + paths.tv_app, lit_icd_app='ip netns exec app'.split() + paths.lit_icd_app, + microwave_oven_app='ip netns exec app'.split() + paths.microwave_oven_app, bridge_app='ip netns exec app'.split() + paths.bridge_app, chip_repl_yaml_tester_cmd='ip netns exec tool'.split() + paths.chip_repl_yaml_tester_cmd, chip_tool_with_python_cmd='ip netns exec tool'.split() + paths.chip_tool_with_python_cmd, diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index 19f0a7dcb74b0b..fc27c447d222b5 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -175,6 +175,7 @@ class TestTarget(Enum): OTA = auto() BRIDGE = auto() LIT_ICD = auto() + MWO = auto() @dataclass @@ -187,12 +188,13 @@ class ApplicationPaths: tv_app: typing.List[str] bridge_app: typing.List[str] lit_icd_app: typing.List[str] + microwave_oven_app: typing.List[str] chip_repl_yaml_tester_cmd: typing.List[str] chip_tool_with_python_cmd: typing.List[str] def items(self): return [self.chip_tool, self.all_clusters_app, self.lock_app, self.ota_provider_app, self.ota_requestor_app, - self.tv_app, self.bridge_app, self.lit_icd_app, self.chip_repl_yaml_tester_cmd, self.chip_tool_with_python_cmd] + self.tv_app, self.bridge_app, self.lit_icd_app, self.microwave_oven_app, self.chip_repl_yaml_tester_cmd, self.chip_tool_with_python_cmd] @dataclass @@ -301,6 +303,8 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str, target_app = paths.bridge_app elif self.target == TestTarget.LIT_ICD: target_app = paths.lit_icd_app + elif self.target == TestTarget.MWO: + target_app = paths.microwave_oven_app else: raise Exception("Unknown test target - " "don't know which application to run") diff --git a/scripts/tests/run_test_suite.py b/scripts/tests/run_test_suite.py index d4d94b28bf858c..9dbe01d9dbcfa0 100755 --- a/scripts/tests/run_test_suite.py +++ b/scripts/tests/run_test_suite.py @@ -254,6 +254,9 @@ def cmd_list(context): @click.option( '--lit-icd-app', help='what lit-icd app to use') +@click.option( + '--microwave-oven-app', + help='what microwave oven app to use') @click.option( '--chip-repl-yaml-tester', help='what python script to use for running yaml tests using chip-repl as controller') @@ -285,7 +288,7 @@ def cmd_list(context): help='Number of tests that are expected to fail in each iteration. Overall test will pass if the number of failures matches this. Nonzero values require --keep-going') @click.pass_context def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, ota_requestor_app, - tv_app, bridge_app, lit_icd_app, chip_repl_yaml_tester, chip_tool_with_python, pics_file, keep_going, test_timeout_seconds, expected_failures): + tv_app, bridge_app, lit_icd_app, microwave_oven_app, chip_repl_yaml_tester, chip_tool_with_python, pics_file, keep_going, test_timeout_seconds, expected_failures): if expected_failures != 0 and not keep_going: logging.exception(f"'--expected-failures {expected_failures}' used without '--keep-going'") sys.exit(2) @@ -315,6 +318,9 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o if lit_icd_app is None: lit_icd_app = paths_finder.get('lit-icd-app') + if microwave_oven_app is None: + microwave_oven_app = paths_finder.get('chip-microwave-oven-app') + if chip_repl_yaml_tester is None: chip_repl_yaml_tester = paths_finder.get('yamltest_with_chip_repl_tester.py') @@ -334,6 +340,7 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o tv_app=[tv_app], bridge_app=[bridge_app], lit_icd_app=[lit_icd_app], + microwave_oven_app=[microwave_oven_app], chip_repl_yaml_tester_cmd=['python3'] + [chip_repl_yaml_tester], chip_tool_with_python_cmd=['python3'] + [chip_tool_with_python], ) 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 9d57d762bd36c4..f6c6304b610c73 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 @@ -229,7 +229,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::SetCookingParameters::DecodableType & req) { ChipLogDetail(Zcl, "Microwave Oven Control: HandleSetCookingParameters"); - Status status; + Status status = Status::Success; uint8_t opState; uint8_t modeValue; uint8_t reqCookMode; diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 205955b9ebdeb2..2022b27bd22f12 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -1905,6 +1905,30 @@ PICS: "Does the device implement sending the ChangeToModeResponse command?" id: DISHM.S.C01.Tx + # + # Microwave Oven Mode Cluster + # + - label: + "Does the device implement the Microwave Oven Mode cluster as a server" + id: MWOM.S + + # + # Microwave Oven Control Cluster + # + - label: + "Does the device implement the Microwave Oven Control cluster as a + server" + id: MWOCTRL.S + + # + # server / features + # + - label: "Does the device support the power as a number feature" + id: MWOCTRL.S.F00 + + - label: "Does the device support the power number limits feature" + id: MWOCTRL.S.F02 + # Descriptor Cluster TestPlan - label: "Does the device implement the Descriptor cluster as a server?" id: DESC.S diff --git a/src/app/tests/suites/certification/Test_TC_MWOCTRL_1_1.yaml b/src/app/tests/suites/certification/Test_TC_MWOCTRL_1_1.yaml new file mode 100644 index 00000000000000..d06db8ae77d741 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_MWOCTRL_1_1.yaml @@ -0,0 +1,170 @@ +# 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-1.1] Global attributes 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 global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3a: Check for no features selected." + command: "readAttribute" + attribute: "FeatureMap" + PICS: "!MWOCTRL.S.F00 && !MWOCTRL.S.F01 && !MWOCTRL.S.F02" + response: + value: 0 + constraints: + type: bitmap32 + + - label: "Step 3b: Check for PWRNUM feature support" + command: "readAttribute" + attribute: "FeatureMap" + PICS: MWOCTRL.S.F00 + response: + saveAs: powerNumSupported + constraints: + type: bitmap32 + hasMasksSet: [0x1] + hasMasksClear: [0x2] + + - label: "Step 3c: Check for WATTS feature support" + command: "readAttribute" + attribute: "FeatureMap" + PICS: MWOCTRL.S.F01 + response: + saveAs: wattsSupported + constraints: + type: bitmap32 + hasMasksClear: [0x1, 0x4] + hasMasksSet: [0x2] + + - label: "Step 3d: Check for PWRLMTS feature support" + command: "readAttribute" + attribute: "FeatureMap" + PICS: MWOCTRL.S.F02 + response: + saveAs: wattsSupported + constraints: + type: bitmap32 + hasMasksSet: [0x1, 0x4] + hasMasksClear: [0x2] + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 65528, 65529, 65530, 65531, 65532, 65533] + + - label: "Step 4b: Read the global attribute: AttributeList" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 65528, 65529, 65531, 65532, 65533] + + - label: "Step 4c: Check for mandatory attribute support for PWRNUM feature" + PICS: MWOCTRL.S.F00 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [2] + + - label: "Step 4d: Check for optional attribute support for PWRNUM feature" + PICS: MWOCTRL.S.F02 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [3, 4, 5] + + - label: "Step 4e: Check for mandatory attribute support for WATTS feaure" + PICS: MWOCTRL.S.F01 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [6, 7] + + - label: "Step 4f: Check for optional WattRating attribute support" + PICS: MWOCTRL.S.A0008 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [8] + + - label: "Step 5: TH reads EventList attribute from DUT" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "EventList" + response: + value: [] + constraints: + type: list + + - label: "Step 6a: Check for mandatory commands." + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0] + + - label: "Step 6b: Check for optional command AddMoreTime." + PICS: MWOCTRL.S.C01.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 7: TH reads from the DUT the GeneratedCommandList attribute." + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + constraints: + type: list + contains: [] 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 new file mode 100644 index 00000000000000..cd3f26b7e59bb5 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_1.yaml @@ -0,0 +1,74 @@ +# 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/app/tests/suites/certification/Test_TC_MWOCTRL_2_5.yaml b/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_5.yaml new file mode 100644 index 00000000000000..d69e23f0f86e73 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_MWOCTRL_2_5.yaml @@ -0,0 +1,55 @@ +# 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.5] Add more time command with DUT as Server + +PICS: + - MWOCTRL.S + - MWOCTRL.S.C01.Rsp + +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: Send the SetCookingParameters command" + command: "SetCookingParameters" + arguments: + values: + - name: CookTime + value: 60 + + - label: "Step 3: Send the AddMoreTime command" + command: "AddMoreTime" + arguments: + values: + - name: TimeToAdd + value: 30 + + - label: "Step 4: Read the CookTime attribute" + command: "readAttribute" + attribute: "CookTime" + response: + value: 90 + constraints: + type: elapsed_s diff --git a/src/app/tests/suites/certification/Test_TC_MWOM_1_1.yaml b/src/app/tests/suites/certification/Test_TC_MWOM_1_1.yaml new file mode 100644 index 00000000000000..a35aa47a01870f --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_MWOM_1_1.yaml @@ -0,0 +1,94 @@ +# 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-MWOM-1.1] Global attributes with DUT as Server + +PICS: + - MWOM.S + +config: + nodeId: 0x12344321 + cluster: "Microwave Oven Mode" + 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 global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3: Read the global attribute: FeatureMap" + command: "readAttribute" + attribute: "FeatureMap" + PICS: "!MWOM.S.F00" + response: + value: 0 + constraints: + type: bitmap32 + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 65528, 65529, 65530, 65531, 65532, 65533] + excludes: [2, 3] + + - label: "Step 4b: Read the global attribute: AttributeList" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 65528, 65529, 65531, 65532, 65533] + excludes: [2, 3] + + - label: "Step 5: TH reads EventList attribute from DUT" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "EventList" + response: + value: [] + constraints: + type: list + + - label: "Step 6: TH reads from the DUT the AcceptedCommandList attribute." + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + excludes: [0] + + - label: "Step 7: TH reads from the DUT the GeneratedCommandList attribute." + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + constraints: + type: list + excludes: [1] diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 465041b9f9af73..055a8101fc1f0f 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -343,6 +343,15 @@ DISHM.S.M.CAN_MANUALLY_CONTROLLED=0 PIXIT.DISHM.MODE_CHANGE_FAIL=1 PIXIT.DISHM.MODE_CHANGE_OK=1 +# MICROWAVE OVEN CONTROL CLUSTER +MWOCTRL.S=1 +MWOCTRL.S.F00=1 +# MWOCTRL.S.F01=1 +MWOCTRL.S.F02=1 + +# MICROWAVE OVEN MODE CLUSTER +MWOM.S=1 + # MEDIA CLUSTER # App Launcher APPLAUNCHER.S=1 diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index df0b178cad6397..02a58c61ee3c09 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -5709,4 +5709,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py new file mode 100644 index 00000000000000..abe02d8237a8db --- /dev/null +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -0,0 +1,94 @@ +# +# 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_2(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_2(self) -> str: + return "[TC-MWOCTRL-2.2] Secondary functionality with DUT as Server" + + 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"), + ] + return steps + + def pics_TC_MWOCTRL_2_2(self) -> list[str]: + pics = [ + "MWOCTRL.S", + ] + return pics + + @async_test_body + async def test_TC_MWOCTRL_2_2(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) + + only_pwrnum_supported = feature_map == features.kPowerAsNumber + + if not only_pwrnum_supported: + logging.info("More than PWRNUM is 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") + 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") + + self.step(3) + newPowerValue = (powerValue+10) % 100 + 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) + powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting) + asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_MWOCTRL_2_3.py b/src/python_testing/TC_MWOCTRL_2_3.py new file mode 100644 index 00000000000000..0d34c5b3ee8fde --- /dev/null +++ b/src/python_testing/TC_MWOCTRL_2_3.py @@ -0,0 +1,114 @@ +# +# 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"), + ] + 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") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_MWOCTRL_2_4.py b/src/python_testing/TC_MWOCTRL_2_4.py new file mode 100644 index 00000000000000..8cb3885ada0613 --- /dev/null +++ b/src/python_testing/TC_MWOCTRL_2_4.py @@ -0,0 +1,99 @@ +# +# 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_4(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_4(self) -> str: + return "[TC-MWOCTRL-2.4] WATTS functionality with DUT as Server" + + def steps_TC_MWOCTRL_2_4(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read the SupportedWatts attribute"), + TestStep(3, "Read the SelectedWattIndex attribute"), + TestStep(4, "Send the SetCookingParameters command"), + TestStep(5, "Read and verify the SelectedWattIndex attribute"), + ] + return steps + + def pics_TC_MWOCTRL_2_4(self) -> list[str]: + pics = [ + "MWOCTRL.S", + ] + return pics + + @async_test_body + async def test_TC_MWOCTRL_2_4(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) + + only_watts_supported = feature_map == features.kPowerInWatts + + if not only_watts_supported: + logging.info("PowerInWatts is not supported so skipping the rest of the tests.") + self.skip_all_remaining_steps(2) + return + + self.step(2) + supportedWattsList = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedWatts) + asserts.assert_true(len(supportedWattsList) > 0, "SupportedWatts list is empty") + + self.step(3) + selectedWattIndex = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.SelectedWattIndex) + logging.info("SelectedWattIndex is %s" % selectedWattIndex) + asserts.assert_true(selectedWattIndex >= 0 and selectedWattIndex < len( + supportedWattsList), "SelectedWattIndex is out of range") + + self.step(4) + newWattIndex = (selectedWattIndex+1) % (len(supportedWattsList)-1) + try: + await self.send_single_cmd(cmd=commands.SetCookingParameters(wattSettingIndex=newWattIndex), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(5) + selectedWattIndex = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.SelectedWattIndex) + asserts.assert_true(selectedWattIndex == newWattIndex, "SelectedWattIndex was not correctly set") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_MWOM_1_2.py b/src/python_testing/TC_MWOM_1_2.py new file mode 100644 index 00000000000000..8dc60d9e131e68 --- /dev/null +++ b/src/python_testing/TC_MWOM_1_2.py @@ -0,0 +1,107 @@ +# +# Copyright (c) 2023 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 matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_MWOM_1_2(MatterBaseTest): + + async def read_mod_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.MicrowaveOvenMode + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_MWOM_1_2(self) -> str: + return "[TC-MWOM-1.2] Cluster attributes with DUT as Server" + + def steps_TC_MWOM_1_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read the SupportedModes attribute"), + TestStep(3, "Read the CurrentMode attribute"), + ] + return steps + + def pics_TC_MWOM_1_2(self) -> list[str]: + pics = [ + "MWOM.S", + ] + return pics + + @async_test_body + async def test_TC_MWOM_1_2(self): + + endpoint = self.user_params.get("endpoint", 1) + + attributes = Clusters.MicrowaveOvenMode.Attributes + + self.step(1) + + self.step(2) + supported_modes = await self.read_mod_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedModes) + asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least 2 entries!") + asserts.assert_less_equal(len(supported_modes), 255, "SupportedModes must have at most 255 entries!") + modes = set([m.mode for m in supported_modes]) + asserts.assert_equal(len(modes), len(supported_modes), "SupportedModes must have unique mode values") + + labels = set([m.label for m in supported_modes]) + asserts.assert_equal(len(labels), len(supported_modes), "SupportedModes must have unique mode label values") + + # common mode tags + commonTags = {0x0: 'Auto', + 0x1: 'Quick', + 0x2: 'Quiet', + 0x3: 'LowNoise', + 0x4: 'LowEnergy', + 0x5: 'Vacation', + 0x6: 'Min', + 0x7: 'Max', + 0x8: 'Night', + 0x9: 'Day'} + + # derived cluster defined tags + # kUnknownEnumValue may not be defined + try: + derivedTags = [tag.value for tag in Clusters.MicrowaveOvenMode.Enums.ModeTag + if tag is not Clusters.MicrowaveOvenMode.Enums.ModeTag.kUnknownEnumValue] + except AttributeError: + derivedTags = Clusters.MicrowaveOvenMode.Enums.ModeTag + + logging.info("Derived tags: %s" % derivedTags) + + for m in supported_modes: + for t in m.modeTags: + is_mfg = (0x8000 <= t.value and t.value <= 0xBFFF) + asserts.assert_true(t.value in commonTags.keys() or t.value in derivedTags or is_mfg, + "Found a SupportedModes entry with invalid mode tag value!") + if t.value == Clusters.MicrowaveOvenMode.Enums.ModeTag.kNormal: + normal_present = True + logging.info("Found normal mode tag %s with tag value %s", m.mode, t.value) + + asserts.assert_true(normal_present, "SupportedModes does not have an entry of Normal(0x4000)") + + self.step(3) + current_mode = await self.read_mod_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentMode) + logging.info("CurrentMode: %s" % current_mode) + asserts.assert_true(current_mode in modes, "CurrentMode is not a supported mode!") + + +if __name__ == "__main__": + default_matter_test_main() From 4fbf4ed61322a65effc319ac333528728d81f429 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 9 Feb 2024 10:20:29 -0500 Subject: [PATCH 2/4] Removed duplicate def --- .../microwave-oven-common/src/microwave-oven-device.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp b/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp index 39e8ab2bf98b73..5ba3eedbc99a03 100644 --- a/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp +++ b/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp @@ -24,10 +24,9 @@ using namespace chip::app::Clusters::OperationalState; using namespace chip::app::Clusters::ModeBase; using namespace chip::app::Clusters::MicrowaveOvenControl; template -using List = chip::app::DataModel::List; -using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type; -using OperationalStateEnum = chip::app::Clusters::OperationalState::OperationalStateEnum; -using Status = Protocols::InteractionModel::Status; +using List = chip::app::DataModel::List; +using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type; +using Status = Protocols::InteractionModel::Status; void ExampleMicrowaveOvenDevice::MicrowaveOvenInit() { From a10cffa7c26dcb67de29318d835bebb869347a60 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 9 Feb 2024 12:32:32 -0500 Subject: [PATCH 3/4] Added build target for microwave oven --- .github/workflows/darwin-tests.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index 288166dfb87130..cf8649234a1959 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -99,6 +99,8 @@ jobs: --target darwin-x64-tv-app-${BUILD_VARIANT} \ --target darwin-x64-bridge-${BUILD_VARIANT} \ --target darwin-x64-lit-icd-${BUILD_VARIANT} \ + --target darwin-x64-microwave-oven-${BUILD_VARIANT} \ + build \ --copy-artifacts-to objdir-clone \ " @@ -118,6 +120,7 @@ jobs: --ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \ --tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/darwin-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ + --microwave-oven-app ./out/darwin-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ " - name: Run OTA Test run: | From f2043e94dc779d5f8a9447037e738aecdf679b3a Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 9 Feb 2024 14:35:03 -0500 Subject: [PATCH 4/4] Apply suggestions from code review --- .github/workflows/darwin-tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index cf8649234a1959..05943be5b0e155 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -100,7 +100,6 @@ jobs: --target darwin-x64-bridge-${BUILD_VARIANT} \ --target darwin-x64-lit-icd-${BUILD_VARIANT} \ --target darwin-x64-microwave-oven-${BUILD_VARIANT} \ - build \ --copy-artifacts-to objdir-clone \ "