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 2 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
11 changes: 11 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def __init__(self, test: dict, config: dict, definitions: SpecDefinitions, pics_
self.busy_wait_ms = _value_or_none(test, 'busyWaitMs')
self.wait_for = _value_or_none(test, 'wait')
self.event_number = _value_or_none(test, 'eventNumber')
self.is_last_event_number = _value_or_none(test, 'isLastEventNumber')
self.run_if = _value_or_none(test, 'runIf')
self.save_response_as = _value_or_none(test, 'saveResponseAs')

Expand Down Expand Up @@ -578,6 +579,8 @@ def __init__(self, test: _TestStepWithPlaceholders, step_index: int, runtime_con
self._test.run_if)
self._test.event_number = self._config_variable_substitution(
self._test.event_number)
self._test.is_last_event_number = self._config_variable_substitution(
self._test.is_last_event_number)
self._test.cluster = self._config_variable_substitution(
self._test.cluster)
self._test.command = self._config_variable_substitution(
Expand Down Expand Up @@ -683,6 +686,14 @@ 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 is_last_event_number(self):
return self._test.is_last_event_number

@property
def pics(self):
return self._test.pics
Expand Down
17 changes: 17 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

import asyncio
import re
import time
from abc import ABC, abstractmethod
from asyncio import CancelledError
Expand Down Expand Up @@ -125,6 +126,10 @@ class TestRunner(TestRunnerBase):
"""
TestRunner is a default runner implementation.
"""

pattern = re.compile(r'EventNumber = (0x[0-9a-f]+)')
last_event_number = 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_last_event_number:
request.event_number = self.last_event_number

if not request.is_pics_enabled:
hooks.step_skipped(request.label, request.pics)
continue
Expand All @@ -195,6 +203,15 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig):
duration = round((time.time() - start) * 1000, 2)
test_duration += duration

# TODO: To get the event number, the method could be improved
for log in reversed(logs):
match = self.pattern.search(log.message)
if match:
received_event_number = int(match.group(1), 16) + 1
if self.last_event_number < received_event_number:
self.last_event_number = received_event_number
break

logger = request.post_process_response(responses)

if logger.is_failure():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __check_test_step(self, config: dict, content):
'command': str,
'event': str,
'eventNumber': (int, str), # Can be a variable.
'isLastEventNumber': bool, # Can be a variable.
'disabled': bool,
'fabricFiltered': bool,
'verification': str,
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
isLastEventNumber: true
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
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
isLastEventNumber: true
response:
value: {}

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

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

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

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

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

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

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

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