diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp index e3761994deee5c..8095ac05072022 100644 --- a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp @@ -21,6 +21,7 @@ #include #include +constexpr const char * kEventNumberKey = "eventNumber"; constexpr const char * kDataVersionKey = "dataVersion"; constexpr const char * kClusterIdKey = "clusterId"; constexpr const char * kEndpointIdKey = "endpointId"; @@ -129,9 +130,10 @@ CHIP_ERROR LogEventAsJSON(const chip::app::EventHeader & header, chip::TLV::TLVR VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); Json::Value value; - value[kClusterIdKey] = header.mPath.mClusterId; - value[kEndpointIdKey] = header.mPath.mEndpointId; - value[kEventIdKey] = header.mPath.mEventId; + value[kClusterIdKey] = header.mPath.mClusterId; + value[kEndpointIdKey] = header.mPath.mEndpointId; + value[kEventIdKey] = header.mPath.mEventId; + value[kEventNumberKey] = header.mEventNumber; chip::TLV::TLVReader reader; reader.Init(*data); diff --git a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py index 929b80570b9acd..0ee564203ba86a 100644 --- a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py +++ b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py @@ -35,6 +35,7 @@ _CLUSTER_ERROR = 'clusterError' _VALUE = 'value' _DATA_VERSION = 'dataVersion' +_EVENT_NUMBER = 'eventNumber' # FabricIndex is a special case where the field is added as a struct field by the SDK # if needed but is not part of the XML definition of the struct. @@ -89,7 +90,7 @@ def __translate_names(self, payloads): elif key == _EVENT_ID: key = _EVENT value = specs.get_event_name(payload[_CLUSTER_ID], value) - elif key == _VALUE or key == _ERROR or key == _CLUSTER_ERROR or key == _DATA_VERSION: + elif key == _VALUE or key == _ERROR or key == _CLUSTER_ERROR or key == _DATA_VERSION or key == _EVENT_NUMBER: pass else: # Raise an error since the other fields probably needs to be translated too. diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py index ef597d22f2e72f..b5743b852d9ba9 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser.py @@ -688,6 +688,10 @@ def wait_for(self): def event_number(self): return self._test.event_number + @event_number.setter + def event_number(self, value): + self._test.event_number = value + @property def pics(self): return self._test.pics diff --git a/scripts/py_matter_yamltests/matter_yamltests/runner.py b/scripts/py_matter_yamltests/matter_yamltests/runner.py index 25ba0ffcebb248..620a8218c7ff5b 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/runner.py +++ b/scripts/py_matter_yamltests/matter_yamltests/runner.py @@ -124,7 +124,12 @@ def run(self, config: TestRunnerConfig) -> bool: class TestRunner(TestRunnerBase): """ TestRunner is a default runner implementation. + + last_event_number: The latest event number value after the readEvent command. """ + + last_event_number: int = 0 + async def start(self): return @@ -175,6 +180,9 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig): test_duration = 0 for idx, request in enumerate(parser.tests): + if request.is_event and request.event_number == 'newEventsOnly': + request.event_number = self.last_event_number + 1 + if not request.is_pics_enabled: hooks.step_skipped(request.label, request.pics) continue @@ -199,6 +207,13 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig): duration = round((time.time() - start) * 1000, 2) test_duration += duration + if request.is_event: + last_event = responses[-1] + if isinstance(last_event, dict): + received_event_number = last_event.get('eventNumber') + if isinstance(received_event_number, int) and self.last_event_number < received_event_number: + self.last_event_number = received_event_number + logger = request.post_process_response(responses) if logger.is_failure(): diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index e3d2f25d2db368..d148b043186bc6 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -135,25 +135,16 @@ def _GetInDevelopmentTests() -> Set[str]: "Test_TC_PSCFG_1_1.yaml", # Power source configuration cluster is deprecated and removed from all-clusters "Test_TC_PSCFG_2_1.yaml", # Power source configuration cluster is deprecated and removed from all-clusters "Test_TC_PSCFG_2_2.yaml", # Power source configuration cluster is deprecated and removed from all-clusters - "Test_TC_SMOKECO_2_6.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes - # TestEventTriggersEnabled is true, which it's not in CI. Also, test - # has wrong key for eventNumber: because using the right key leads to - # codegen that does not compile. "Test_TC_SMOKECO_2_2.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes - # TestEventTriggersEnabled is true, which it's not in CI. Also, test - # has wrong key for eventNumber: because using the right key leads to - # codegen that does not compile. + # TestEventTriggersEnabled is true, which it's not in CI. "Test_TC_SMOKECO_2_3.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes - # TestEventTriggersEnabled is true, which it's not in CI. Also, test - # has wrong key for eventNumber: because using the right key leads to - # codegen that does not compile. + # TestEventTriggersEnabled is true, which it's not in CI. "Test_TC_SMOKECO_2_4.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes - # TestEventTriggersEnabled is true, which it's not in CI. Also, test - # has wrong key for eventNumber: because using the right key leads to - # codegen that does not compile. - "Test_TC_SMOKECO_2_5.yaml", # chip-repl does not support local timeout (07/20/2023) and test uses unknown - # keepSubscriptions key in the YAML. Also, test has wrong key for eventNumber: - # because using the right key leads to codegen that does not compile. + # TestEventTriggersEnabled is true, which it's not in CI. + "Test_TC_SMOKECO_2_5.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes + # TestEventTriggersEnabled is true, which it's not in CI. + "Test_TC_SMOKECO_2_6.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes + # TestEventTriggersEnabled is true, which it's not in CI. } diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml index 7c239e0ec22c35..740f0de7897085 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml @@ -36,9 +36,6 @@ config: TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR: type: int64u defaultValue: "0xffffffff000000a0" - EVENT_NUMBER: - type: int64u - defaultValue: 0 tests: - label: "Step 1: Commission DUT to TH" @@ -69,6 +66,11 @@ tests: constraints: type: enum8 + - label: "TH gets last event number from DUT" + PICS: SMOKECO.S.E0a + command: "readEvent" + event: "AllClear" + - label: "Step 4: TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster" @@ -121,7 +123,7 @@ tests: PICS: SMOKECO.S.E00 command: "readEvent" event: "SmokeAlarm" - EVENT_NUMBER: EVENT_NUMBER + 1 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 1 } @@ -201,7 +203,7 @@ tests: PICS: SMOKECO.S.E00 command: "readEvent" event: "SmokeAlarm" - EVENT_NUMBER: EVENT_NUMBER + 2 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 2 } @@ -246,6 +248,6 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 3 + eventNumber: "newEventsOnly" response: value: {} diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_3.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_3.yaml index 7ce62ab407c78a..e18e494ec387e5 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_3.yaml @@ -35,9 +35,6 @@ config: TEST_EVENT_TRIGGER_CO_ALARM_CLEAR: type: int64u defaultValue: "0xffffffff000000a1" - EVENT_NUMBER: - type: int64u - defaultValue: 0 tests: - label: "Step 1: Commission DUT to TH" @@ -68,6 +65,11 @@ tests: constraints: type: enum8 + - label: "TH gets last event number from DUT" + PICS: SMOKECO.S.E0a + command: "readEvent" + event: "AllClear" + - label: "Step 4: TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster" @@ -120,7 +122,7 @@ tests: PICS: SMOKECO.S.E01 command: "readEvent" event: "COAlarm" - EVENT_NUMBER: EVENT_NUMBER + 1 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 1 } @@ -200,7 +202,7 @@ tests: PICS: SMOKECO.S.E01 command: "readEvent" event: "COAlarm" - EVENT_NUMBER: EVENT_NUMBER + 2 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 2 } @@ -245,6 +247,6 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 3 + eventNumber: "newEventsOnly" response: value: {} diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_4.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_4.yaml index 29e403aa9e5fba..bac2511118f3cb 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_4.yaml @@ -48,9 +48,6 @@ config: TEST_EVENT_TRIGGER_END_OF_SERVICE_ALERT_CLEAR: type: int64u defaultValue: "0xffffffff000000aa" - EVENT_NUMBER: - type: int64u - defaultValue: 0 tests: - label: "Step 1: Commission DUT to TH" @@ -81,6 +78,11 @@ tests: constraints: type: enum8 + - label: "TH gets last event number from DUT" + PICS: SMOKECO.S.E0a + command: "readEvent" + event: "AllClear" + - label: "Step 4: TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster" @@ -133,7 +135,7 @@ tests: PICS: SMOKECO.S.E02 command: "readEvent" event: "LowBattery" - EVENT_NUMBER: EVENT_NUMBER + 1 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 1 } @@ -178,7 +180,7 @@ tests: PICS: SMOKECO.S.E02 command: "readEvent" event: "LowBattery" - EVENT_NUMBER: EVENT_NUMBER + 2 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: 2 } @@ -223,7 +225,7 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 3 + eventNumber: "newEventsOnly" response: value: {} @@ -279,7 +281,7 @@ tests: PICS: SMOKECO.S.E03 command: "readEvent" event: "HardwareFault" - EVENT_NUMBER: EVENT_NUMBER + 4 + eventNumber: "newEventsOnly" response: value: {} @@ -325,7 +327,7 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 5 + eventNumber: "newEventsOnly" response: value: {} @@ -381,7 +383,7 @@ tests: PICS: SMOKECO.S.E04 command: "readEvent" event: "EndOfService" - EVENT_NUMBER: EVENT_NUMBER + 6 + eventNumber: "newEventsOnly" response: value: {} @@ -427,7 +429,7 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 7 + eventNumber: "newEventsOnly" response: value: {} @@ -499,7 +501,7 @@ tests: PICS: SMOKECO.S.E05 command: "readEvent" event: "SelfTestComplete" - EVENT_NUMBER: EVENT_NUMBER + 8 + eventNumber: "newEventsOnly" response: value: {} @@ -516,7 +518,7 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 9 + eventNumber: "newEventsOnly" response: value: {} @@ -561,7 +563,7 @@ tests: PICS: SMOKECO.S.E05 command: "readEvent" event: "SelfTestComplete" - EVENT_NUMBER: EVENT_NUMBER + 10 + eventNumber: "newEventsOnly" response: value: {} @@ -578,6 +580,6 @@ tests: PICS: SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 11 + eventNumber: "newEventsOnly" response: value: {} diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml index d41f1c662672e6..7082d25acb5847 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml @@ -81,9 +81,6 @@ config: TTEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_CLEAR: type: int64u defaultValue: "0xffffffff000000a8" - EVENT_NUMBER: - type: int64u - defaultValue: 0 tests: - label: "Step 1: Commission DUT to TH" @@ -115,6 +112,11 @@ tests: constraints: type: enum8 + - label: "TH gets last event number from DUT" + PICS: SMOKECO.S.E0a + command: "readEvent" + event: "AllClear" + - label: "Step 4: TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster" @@ -161,7 +163,7 @@ tests: PICS: SMOKECO.S.A0008 && SMOKECO.S.E08 command: "readEvent" event: "InterconnectSmokeAlarm" - EVENT_NUMBER: EVENT_NUMBER + 1 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: interconnectSmokeAlarmSeverityLevel } @@ -216,7 +218,7 @@ tests: PICS: SMOKECO.S.A0008 && SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 2 + eventNumber: "newEventsOnly" response: value: {} @@ -274,7 +276,7 @@ tests: PICS: SMOKECO.S.A0009 && SMOKECO.S.E09 command: "readEvent" event: "InterconnectCOAlarm" - EVENT_NUMBER: EVENT_NUMBER + 3 + eventNumber: "newEventsOnly" response: value: { AlarmSeverityLevel: interconnectCOAlarmSeverityLevel } @@ -329,7 +331,7 @@ tests: PICS: SMOKECO.S.A0009 && SMOKECO.S.E0a command: "readEvent" event: "AllClear" - EVENT_NUMBER: EVENT_NUMBER + 4 + eventNumber: "newEventsOnly" response: value: {} @@ -687,7 +689,7 @@ tests: PICS: SMOKECO.S.A0004 && SMOKECO.S.F00 && SMOKECO.S.E06 command: "readEvent" event: "AlarmMuted" - EVENT_NUMBER: EVENT_NUMBER + 5 + eventNumber: "newEventsOnly" response: value: {} @@ -724,7 +726,7 @@ tests: PICS: SMOKECO.S.A0004 && SMOKECO.S.F00 && SMOKECO.S.E07 command: "readEvent" event: "MuteEnded" - EVENT_NUMBER: EVENT_NUMBER + 6 + eventNumber: "newEventsOnly" response: value: {} @@ -919,7 +921,7 @@ tests: PICS: SMOKECO.S.A0004 && SMOKECO.S.F01 && SMOKECO.S.E06 command: "readEvent" event: "AlarmMuted" - EVENT_NUMBER: EVENT_NUMBER + 7 + eventNumber: "newEventsOnly" response: value: {} @@ -956,7 +958,7 @@ tests: PICS: SMOKECO.S.A0004 && SMOKECO.S.F01 && SMOKECO.S.E07 command: "readEvent" event: "MuteEnded" - EVENT_NUMBER: EVENT_NUMBER + 8 + eventNumber: "newEventsOnly" response: value: {}