Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method in python runner to get eventNumber for TC-SMOKECO tests #28704

Merged
merged 7 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/chip-tool/commands/common/RemoteDataModelLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <lib/support/SafeInt.h>
#include <lib/support/jsontlv/TlvJson.h>

constexpr const char * kEventNumberKey = "eventNumber";
constexpr const char * kDataVersionKey = "dataVersion";
constexpr const char * kClusterIdKey = "clusterId";
constexpr const char * kEndpointIdKey = "endpointId";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,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
Expand Down
15 changes: 15 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -195,6 +203,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():
Expand Down
23 changes: 7 additions & 16 deletions scripts/tests/chiptest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}


Expand Down
14 changes: 8 additions & 6 deletions src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ config:
TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR:
type: int64u
defaultValue: "0xffffffff000000a0"
EVENT_NUMBER:
type: int64u
defaultValue: 0

tests:
- label: "Commission DUT to TH"
Expand Down Expand Up @@ -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:
"TH reads TestEventTriggersEnabled attribute from General Diagnostics
Cluster"
Expand Down Expand Up @@ -121,7 +123,7 @@ tests:
PICS: SMOKECO.S.E00
command: "readEvent"
event: "SmokeAlarm"
EVENT_NUMBER: EVENT_NUMBER + 1
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 1 }

Expand Down Expand Up @@ -201,7 +203,7 @@ tests:
PICS: SMOKECO.S.E00
command: "readEvent"
event: "SmokeAlarm"
EVENT_NUMBER: EVENT_NUMBER + 2
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 2 }

Expand Down Expand Up @@ -246,6 +248,6 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 3
eventNumber: "newEventsOnly"
response:
value: {}
14 changes: 8 additions & 6 deletions src/app/tests/suites/certification/Test_TC_SMOKECO_2_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ config:
TEST_EVENT_TRIGGER_CO_ALARM_CLEAR:
type: int64u
defaultValue: "0xffffffff000000a1"
EVENT_NUMBER:
type: int64u
defaultValue: 0

tests:
- label: "Commission DUT to TH"
Expand Down Expand Up @@ -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:
"TH reads TestEventTriggersEnabled attribute from General Diagnostics
Cluster"
Expand Down Expand Up @@ -120,7 +122,7 @@ tests:
PICS: SMOKECO.S.E01
command: "readEvent"
event: "COAlarm"
EVENT_NUMBER: EVENT_NUMBER + 1
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 1 }

Expand Down Expand Up @@ -200,7 +202,7 @@ tests:
PICS: SMOKECO.S.E01
command: "readEvent"
event: "COAlarm"
EVENT_NUMBER: EVENT_NUMBER + 2
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 2 }

Expand Down Expand Up @@ -245,6 +247,6 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 3
eventNumber: "newEventsOnly"
response:
value: {}
30 changes: 16 additions & 14 deletions src/app/tests/suites/certification/Test_TC_SMOKECO_2_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Commission DUT to TH"
Expand Down Expand Up @@ -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:
"TH reads TestEventTriggersEnabled attribute from General Diagnostics
Cluster"
Expand Down Expand Up @@ -133,7 +135,7 @@ tests:
PICS: SMOKECO.S.E02
command: "readEvent"
event: "LowBattery"
EVENT_NUMBER: EVENT_NUMBER + 1
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 1 }

Expand Down Expand Up @@ -178,7 +180,7 @@ tests:
PICS: SMOKECO.S.E02
command: "readEvent"
event: "LowBattery"
EVENT_NUMBER: EVENT_NUMBER + 2
eventNumber: "newEventsOnly"
response:
value: { AlarmSeverityLevel: 2 }

Expand Down Expand Up @@ -223,7 +225,7 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 3
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -279,7 +281,7 @@ tests:
PICS: SMOKECO.S.E03
command: "readEvent"
event: "HardwareFault"
EVENT_NUMBER: EVENT_NUMBER + 4
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -325,7 +327,7 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 5
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -381,7 +383,7 @@ tests:
PICS: SMOKECO.S.E04
command: "readEvent"
event: "EndOfService"
EVENT_NUMBER: EVENT_NUMBER + 6
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -427,7 +429,7 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 7
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -499,7 +501,7 @@ tests:
PICS: SMOKECO.S.E05
command: "readEvent"
event: "SelfTestComplete"
EVENT_NUMBER: EVENT_NUMBER + 8
eventNumber: "newEventsOnly"
response:
value: {}

Expand All @@ -516,7 +518,7 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 9
eventNumber: "newEventsOnly"
response:
value: {}

Expand Down Expand Up @@ -561,7 +563,7 @@ tests:
PICS: SMOKECO.S.E05
command: "readEvent"
event: "SelfTestComplete"
EVENT_NUMBER: EVENT_NUMBER + 10
eventNumber: "newEventsOnly"
response:
value: {}

Expand All @@ -578,6 +580,6 @@ tests:
PICS: SMOKECO.S.E0a
command: "readEvent"
event: "AllClear"
EVENT_NUMBER: EVENT_NUMBER + 11
eventNumber: "newEventsOnly"
response:
value: {}
Loading