Skip to content

Commit

Permalink
[matter_yamltests] Allow endpoint, cluster, command, attribute, event…
Browse files Browse the repository at this point in the history
… to use a variable
  • Loading branch information
vivien-apple committed May 22, 2023
1 parent bfa0580 commit cefd967
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 54 deletions.
10 changes: 10 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ 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.cluster = self._config_variable_substitution(
self._test.cluster)
self._test.command = self._config_variable_substitution(
self._test.command)
self._test.attribute = self._config_variable_substitution(
self._test.attribute)
self._test.event = self._config_variable_substitution(
self._test.event)
self._test.endpoint = self._config_variable_substitution(
self._test.endpoint)
test.update_arguments(self.arguments)
test.update_responses(self.responses)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __check_test_step(self, content):
'nodeId': int,
'runIf': str, # Should be a variable.
'groupId': int,
'endpoint': int,
'endpoint': (int, str), # Can be a variable
'cluster': str,
'attribute': str,
'command': str,
Expand Down
18 changes: 17 additions & 1 deletion scripts/py_matter_yamltests/test_yaml_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ def test_key_tests_step_int_keys(self):
keys = [
'nodeId',
'groupId',
'endpoint',
'minInterval',
'maxInterval',
'timedInteractionTimeoutMs',
Expand Down Expand Up @@ -307,6 +306,23 @@ def test_key_tests_step_response_key(self):
x = content.format(value=value)
self.assertRaises(TestStepInvalidTypeError, load, x)

def test_key_tests_step_endpoint_number_key(self):
load = YamlLoader().load

content = ('tests:\n'
' - endpoint: {value}')

_, _, _, _, tests = load(content.format(value=1))
self.assertEqual(tests, [{'endpoint': 1}])

_, _, _, _, tests = load(content.format(value='TestKey'))
self.assertEqual(tests, [{'endpoint': 'TestKey'}])

wrong_values = self._get_wrong_values([str, int], spaces=6)
for value in wrong_values:
x = content.format(value=value)
self.assertRaises(TestStepInvalidTypeError, load, x)

def test_key_tests_step_event_number_key(self):
load = YamlLoader().load

Expand Down
16 changes: 8 additions & 8 deletions src/app/tests/suites/certification/Test_TC_DGETH_2_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,35 +136,35 @@ tests:
command: "readAttribute"
attribute: "PacketRxCount"
response:
saveAs: PacketRxCount
saveAs: PacketRxCountValue

- label: "TH reads PacketTxCount attribute value from DUT"
PICS: DGETH.S.A0003
command: "readAttribute"
attribute: "PacketTxCount"
response:
saveAs: PacketTxCount
saveAs: PacketTxCountValue

- label: "TH reads TxErrCount attribute value from DUT"
PICS: DGETH.S.A0004
command: "readAttribute"
attribute: "TxErrCount"
response:
saveAs: TxErrCount
saveAs: TxErrCountValue

- label: "TH reads CollisionCount attribute value from DUT"
PICS: DGETH.S.A0005
command: "readAttribute"
attribute: "CollisionCount"
response:
saveAs: CollisionCount
saveAs: CollisionCountValue

- label: "TH reads OverrunCount attribute value from DUT"
PICS: DGETH.S.A0006
command: "readAttribute"
attribute: "OverrunCount"
response:
saveAs: OverrunCount
saveAs: OverrunCountValue

#issue #13648
- label: "Sends ResetCounts command"
Expand Down Expand Up @@ -215,20 +215,20 @@ tests:
attribute: "TxErrCount"
response:
constraints:
maxValue: TxErrCount
maxValue: TxErrCountValue

- label: "TH reads CollisionCount attribute value from DUT"
PICS: DGETH.S.A0005
command: "readAttribute"
attribute: "CollisionCount"
response:
constraints:
maxValue: CollisionCount
maxValue: CollisionCountValue

- label: "TH reads OverrunCount attribute value from DUT"
PICS: DGETH.S.A0006
command: "readAttribute"
attribute: "OverrunCount"
response:
constraints:
maxValue: OverrunCount
maxValue: OverrunCountValue
36 changes: 18 additions & 18 deletions src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tests:
command: "readAttribute"
attribute: "MinSetpointDeadBand"
response:
saveAs: MinSetpointDeadBand
saveAs: MinSetpointDeadBandValue

- label:
"Saving value for comparision in step 6 read AbsMaxCoolSetpointLimit
Expand All @@ -65,7 +65,7 @@ tests:
command: "readAttribute"
attribute: "MinCoolSetpointLimit"
response:
saveAs: MinCoolSetpointLimit
saveAs: MinCoolSetpointLimitValue

- label:
"Saving value for comparision in step 17 read MaxCoolSetpointLimit
Expand All @@ -74,7 +74,7 @@ tests:
command: "readAttribute"
attribute: "MaxCoolSetpointLimit"
response:
saveAs: MaxCoolSetpointLimit
saveAs: MaxCoolSetpointLimitValue

- label:
"Saving value for comparision in step 13 read attribute
Expand All @@ -83,7 +83,7 @@ tests:
command: "readAttribute"
attribute: "OccupiedCoolingSetpoint"
response:
saveAs: OccupiedCoolingSetpoint
saveAs: OccupiedCoolingSetpointValue

- label:
"Saving value for comparision in step 15 read attribute
Expand All @@ -92,7 +92,7 @@ tests:
command: "readAttribute"
attribute: "AbsMinHeatSetpointLimit"
response:
saveAs: AbsMinHeat
saveAs: AbsMinHeatValue

- label:
"Saving value for comparision in step 15 read attribute
Expand All @@ -101,7 +101,7 @@ tests:
command: "readAttribute"
attribute: "AbsMaxHeatSetpointLimit"
response:
saveAs: AbsMaxHeat
saveAs: AbsMaxHeatValue

- label:
"Saving value for comparision in step 16 read
Expand All @@ -110,7 +110,7 @@ tests:
command: "readAttribute"
attribute: "UnoccupiedCoolingSetpoint"
response:
saveAs: UnoccupiedCoolingSetpoint
saveAs: UnoccupiedCoolingSetpointValue

- label: "Reads mandatory attributes from DUT: LocalTemperature"
command: "readAttribute"
Expand Down Expand Up @@ -150,7 +150,7 @@ tests:
response:
constraints:
type: int16s
maxValue: AbsMinCoolSetpointLimitStep5 - MinSetpointDeadBand
maxValue: AbsMinCoolSetpointLimitStep5 - MinSetpointDeadBandValue

- label:
"Read attribute AbsMinHeatSetpointLimit if TSTAT.S.F05 feature is
Expand Down Expand Up @@ -250,8 +250,8 @@ tests:
response:
constraints:
type: int16s
minValue: MinCoolSetpointLimit
maxValue: MaxCoolSetpointLimit
minValue: MinCoolSetpointLimitValue
maxValue: MaxCoolSetpointLimitValue

- label: "Read attribute OccupiedCoolingSetpoint from the DUT"
PICS: TSTAT.S.F01 && !TSTAT.S.A0017 && !TSTAT.S.A0018
Expand All @@ -273,7 +273,7 @@ tests:
constraints:
type: int16s
minValue: AbsMinCoolSetpointLimitStep5
maxValue: OccupiedCoolingSetpoint - MinSetpointDeadBand
maxValue: OccupiedCoolingSetpointValue - MinSetpointDeadBandValue

- label: "Read attribute OccupiedHeatingSetpoint from the DUT"
PICS: TSTAT.S.F00 && !TSTAT.S.F05
Expand All @@ -292,8 +292,8 @@ tests:
response:
constraints:
type: int16s
minValue: AbsMinHeat
maxValue: AbsMaxHeat
minValue: AbsMinHeatValue
maxValue: AbsMaxHeatValue

- label: "Read UnoccupiedCoolingSetpoint attribute from the DUT"
PICS: TSTAT.S.F01 && TSTAT.S.F02 && !TSTAT.S.F05
Expand All @@ -313,7 +313,7 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: UnoccupiedCoolingSetpoint - MinSetpointDeadBand
maxValue: UnoccupiedCoolingSetpointValue - MinSetpointDeadBandValue

- label: "Read UnoccupiedHeatingSetpoint attribute from the DUT"
PICS: TSTAT.S.F00 && TSTAT.S.F02 && !TSTAT.S.F05
Expand All @@ -333,7 +333,7 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: MinCoolSetpointLimit - MinSetpointDeadBand
maxValue: MinCoolSetpointLimitValue - MinSetpointDeadBandValue

- label: "Read attribute MinHeatSetpointLimit from the DUT"
PICS: TSTAT.S.A0015 && !TSTAT.S.F05
Expand Down Expand Up @@ -363,7 +363,7 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: MaxCoolSetpointLimit - MinSetpointDeadBand
maxValue: MaxCoolSetpointLimitValue - MinSetpointDeadBandValue

- label: "Read attribute MinCoolSetpointLimit from DUT"
PICS: TSTAT.S.A0017 && TSTAT.S.A0018 && TSTAT.S.A0005
Expand All @@ -373,7 +373,7 @@ tests:
constraints:
type: int16s
minValue: AbsMinCoolSetpointLimitStep5
maxValue: MaxCoolSetpointLimit
maxValue: MaxCoolSetpointLimitValue

- label: "Read attribute MinCoolSetpointLimit from DUT"
PICS: TSTAT.S.A0017 && !TSTAT.S.A0018 && !TSTAT.S.A0005
Expand All @@ -392,7 +392,7 @@ tests:
response:
constraints:
type: int16s
minValue: MinCoolSetpointLimit
minValue: MinCoolSetpointLimitValue
maxValue: AbsMaxCoolSetpointLimitStep6

- label: "Read attribute MinSetpointDeadBand from DUT"
Expand Down
26 changes: 13 additions & 13 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cefd967

Please sign in to comment.