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

Test event triggers #37907

Closed
wants to merge 12 commits into from
103 changes: 40 additions & 63 deletions src/app/tests/suites/certification/Test_TC_CC_3_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,72 +72,59 @@ tests:

- label:
"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up),
StepSize=60 and TransitionTime=200 (20s)"
StepSize=80 and TransitionTime=200 (20s)"
PICS: CC.S.F00 && CC.S.C02.Rsp
command: "StepHue"
arguments:
values:
- name: "StepMode"
value: 1
- name: "StepSize"
value: 60
value: 80
- name: "TransitionTime"
value: 200
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 10s"
- label: "Wait 5s"
PICS: CC.S.F00
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 10000
value: 5000

- label: "Step 2c: TH reads CurrentHue attribute from DUT"
- label: "Step 2c: TH reads CurrentHue attribute from DUT" # Expects 220 (200 + 80*(5/20)) with a tolerance of +/- 3 (15% of 20), so the expected value is in the range [217, 223]
PICS: CC.S.F00 && CC.S.A0000
command: "readAttribute"
attribute: "CurrentHue"
response:
constraints:
minValue: 195
maxValue: 254
minValue: 217
maxValue: 223

- label: "Wait 10s"
- label: "Wait 15s"
PICS: CC.S.F00
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 10000
value: 15000

#Tolerance to be computed from the range
#Start value 230, expected value 5, 230 - 5 = 225, 225 % 15 = 34 , So 5+/-34 We need two range here as 254 is the max value
#Range will be: 230...254...0...39
#Multiple range not supported in YAML: https://github.com/project-chip/connectedhomeip/issues/23197
# Start value 200, expected value 25 (200 + 80*(20/20) = 280 mod 255) with a tolerance of +/- 12 (15% of 80), so the expected value is in the range [13, 37]
# Multiple range not supported in YAML: https://github.com/project-chip/connectedhomeip/issues/23197
- label: "Step 2d: TH reads CurrentHue attribute from DUT"
PICS: CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP
verification: |
./chip-tool colorcontrol read current-hue 1 1

After another 10 seconds , Verify that CurrentHue value is 5 On TH(chip-tool) Logs and below is the sample log provided for the raspi platform

[1649662328.012887][8447:8452] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0300 Attribute 0x0000_0000 DataVersion: 4087279986
[1649662328.012957][8447:8452] CHIP:TOO: Current hue: 5
[1649662328.013055][8447:8452] CHIP:EM: Sending Standalone Ack for MessageCounter:8634142 on exchange 13871i
(Value can vary)
cluster: "LogCommands"
command: "UserPrompt"
arguments:
values:
- name: "message"
value: "Enter 'y' after success"
- name: "expectedValue"
value: "y"
PICS: CC.S.F00 && CC.S.A0000
command: "readAttribute"
attribute: "CurrentHue"
response:
constraints:
minValue: 13
maxValue: 37

- label: "Wait 5s"
PICS: CC.S.F00
Expand All @@ -148,25 +135,15 @@ tests:
- name: "ms"
value: 5000

#Multiple range not supported in YAML: https://github.com/project-chip/connectedhomeip/issues/23197
# Multiple range not supported in YAML: https://github.com/project-chip/connectedhomeip/issues/23197
- label: "Step 2e: TH reads CurrentHue attribute from DUT"
PICS: CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP
verification: |
./chip-tool colorcontrol read current-hue 1 1

After another 5 seconds , Verify that CurrentHue value is 5 On TH(chip-tool) Logs and below is the sample log provided for the raspi platform

[1649662328.012887][8447:8452] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0300 Attribute 0x0000_0000 DataVersion: 4087279986
[1649662328.012957][8447:8452] CHIP:TOO: Current hue: 5
[1649662328.013055][8447:8452] CHIP:EM: Sending Standalone Ack for MessageCounter:8634142 on exchange 13871i
cluster: "LogCommands"
command: "UserPrompt"
arguments:
values:
- name: "message"
value: "Enter 'y' after success"
- name: "expectedValue"
value: "y"
PICS: CC.S.F00 && CC.S.A0000
command: "readAttribute"
attribute: "CurrentHue"
response:
constraints:
minValue: 13
maxValue: 37

- label:
"Step 3a: TH sends MoveToHue command to DUT with Hue=50,
Expand Down Expand Up @@ -197,57 +174,57 @@ tests:

- label:
"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down),
StepSize=60 and TransitionTime=200 (20s)"
StepSize=100 and TransitionTime=200 (20s)"
PICS: CC.S.F00 && CC.S.C02.Rsp
command: "StepHue"
arguments:
values:
- name: "StepMode"
value: 3
- name: "StepSize"
value: 60
value: 100
- name: "TransitionTime"
value: 200
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 10s"
- label: "Wait 5s"
PICS: CC.S.F00
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 10000
value: 5000

- label: "Step 3c: TH reads CurrentHue attribute from DUT"
- label: "Step 3c: TH reads CurrentHue attribute from DUT" # Expects 25 (50 - 100*(5/20)) with a tolerance of +/- 4 (15% of 25), so the expected value is in the range [21, 29]
PICS: CC.S.F00 && CC.S.A0000
command: "readAttribute"
attribute: "CurrentHue"
response:
constraints:
minValue: 17
maxValue: 23
minValue: 21
maxValue: 29

- label: "Wait 10s"
- label: "Wait 15s"
PICS: CC.S.F00
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 10000
value: 15000

- label: "Step 3d: TH reads CurrentHue attribute from DUT"
- label: "Step 3d: TH reads CurrentHue attribute from DUT" # Expects 205 (50 - 100*(20/20) = -50 mod 255) with a tolerance of +/- 15 (15% of 100), so the expected value is in the range [190, 220]
PICS: CC.S.F00 && CC.S.A0000
command: "readAttribute"
attribute: "CurrentHue"
response:
constraints:
minValue: 208
maxValue: 255
minValue: 190
maxValue: 220

- label: "Wait 5s"
PICS: CC.S.F00
Expand All @@ -264,8 +241,8 @@ tests:
attribute: "CurrentHue"
response:
constraints:
minValue: 208
maxValue: 255
minValue: 190
maxValue: 220

- label: "Step 4a: TH reads ColorMode attribute from DUT"
PICS: CC.S.F00 && CC.S.A0008
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/suites/certification/ci-pics-values
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ CC.S.C41.Rsp=1
CC.S.C42.Rsp=1
CC.S.C43.Rsp=1
CC.S.C44.Rsp=1
CC.S.F00=0
CC.S.F00=1
CC.S.F01=1
CC.S.F02=1
CC.S.F03=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ class MatterTestConfig:
tc_version_to_simulate: int = None
tc_user_response_to_simulate: int = None

# If this is set tests will allow sending test event triggers with endpoint 0 for older devices
legacy: bool = None


class ClusterMapper:
"""Describe clusters/attributes using schema names."""
Expand Down Expand Up @@ -1289,7 +1292,7 @@ async def send_single_cmd(
return result

async def send_test_event_triggers(self, eventTrigger: int, enableKey: bytes = None):
"""This helper function sends a test event trigger to the General Diagnostics cluster on endpoint 0
"""This helper function sends a test event trigger to the General Diagnostics cluster, If --use-legacy-test-event-trigers flag is present the endpoint will 0

The enableKey can be passed into the function, or omitted which will then
use the one provided to the script via --hex-arg enableKey:<HEX VALUE>
Expand All @@ -1304,13 +1307,37 @@ async def send_test_event_triggers(self, eventTrigger: int, enableKey: bytes = N
else:
enableKey = self.matter_test_config.global_test_params['enableKey']

# What about --endpoing != 0 and legacy = True? Right now target endpoint is set to 0

target_endpoint = 0
if not self.matter_test_config.legacy and self.matter_test_config.endpoint is not None:
target_endpoint = self.matter_test_config.endpoint

print("")
print("Target endpoint: ", target_endpoint)
print("")

print("")
print("Event trigger: ", hex(eventTrigger))
print("")

eventTrigger = eventTrigger | (target_endpoint << 32)

print("")
print("Event trigger: ", hex(eventTrigger))
print("")

try:
# GeneralDiagnostics cluster is meant to be on Endpoint 0 (Root)
await self.send_single_cmd(endpoint=0,
cmd=Clusters.GeneralDiagnostics.Commands.TestEventTrigger(
enableKey,
eventTrigger)
)
general_diagnosis_result = await self.send_single_cmd(endpoint=0,
cmd=Clusters.GeneralDiagnostics.Commands.TestEventTrigger(
enableKey,
eventTrigger)
)

print("")
logger.info(general_diagnosis_result)
print("")

except InteractionModelError as e:
asserts.fail(
Expand Down Expand Up @@ -1943,6 +1970,7 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig:
config.endpoint = args.endpoint # This can be None, the get_endpoint function allows the tests to supply a default
config.app_pid = 0 if args.app_pid is None else args.app_pid
config.fail_on_skipped_tests = args.fail_on_skipped
config.legacy = True if args.use_legacy_test_event_triggers else args.use_legacy_test_event_triggers

config.controller_node_id = args.controller_node_id
config.trace_to = args.trace_to
Expand Down Expand Up @@ -1998,6 +2026,8 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig
basic_group.add_argument('--app-pid', type=int, default=0, help="The PID of the app against which the test is going to run")
basic_group.add_argument('--timeout', type=int, help="Test timeout in seconds")
basic_group.add_argument("--PICS", help="PICS file path", type=str)
basic_group.add_argument("--use-legacy-test-event-triggers", action="store_true", default=False,
help="Send test event triggers with endpoint 0 for older devices")

commission_group = parser.add_argument_group(title="Commissioning", description="Arguments to commission a node")

Expand Down
Loading