forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICD] Fix ICDM 2.1 Cert test when the UAT feature map isn't present (p…
…roject-chip#36907) * Fix icdm 2.1 test case without uat * update CI * Restyled by isort --------- Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
1 parent
b02badf
commit d64768e
Showing
5 changed files
with
117 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env -S python3 -B | ||
# | ||
# Copyright (c) 2024 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import string | ||
from dataclasses import dataclass | ||
|
||
import chip.clusters as Clusters | ||
from chip.clusters import Attribute | ||
from MockTestRunner import MockTestRunner | ||
|
||
c = Clusters.IcdManagement | ||
attr = c.Attributes | ||
uat = c.Bitmaps.UserActiveModeTriggerBitmap | ||
|
||
|
||
@dataclass | ||
class ICDMData(): | ||
FeatureMap: int | ||
IdleModeDuration: int | ||
ActiveModeDuration: int | ||
ActiveModeThreshold: int | ||
RegisteredClients: list | ||
ICDCounter: int | ||
ClientsSupportedPerFabric: int | ||
UserActiveModeTriggerHint: int | ||
UserActiveModeTriggerInstruction: string | ||
OperatingMode: c.Enums.OperatingModeEnum | ||
MaximumCheckInBackOff: int | ||
expect_pass: bool | ||
|
||
|
||
def test_spec_to_attribute_cache(test_icdm: ICDMData) -> Attribute.AsyncReadTransaction.ReadResponse: | ||
resp = Attribute.AsyncReadTransaction.ReadResponse({}, [], {}) | ||
resp.attributes = {0: {c: {attr.FeatureMap: test_icdm.FeatureMap, attr.IdleModeDuration: test_icdm.IdleModeDuration, attr.ActiveModeDuration: test_icdm.ActiveModeDuration, attr.ActiveModeThreshold: test_icdm.ActiveModeThreshold, | ||
attr.RegisteredClients: test_icdm.RegisteredClients, attr.ICDCounter: test_icdm.ICDCounter, | ||
attr.ClientsSupportedPerFabric: test_icdm.ClientsSupportedPerFabric, attr.UserActiveModeTriggerHint: test_icdm.UserActiveModeTriggerHint, | ||
attr.UserActiveModeTriggerInstruction: test_icdm.UserActiveModeTriggerInstruction, attr.OperatingMode: test_icdm.OperatingMode, attr.MaximumCheckInBackOff: test_icdm.MaximumCheckInBackOff}}} | ||
return resp | ||
|
||
|
||
def run_tests(pics, label, test_cases, test_name): | ||
test_runner = MockTestRunner( | ||
label, label, test_name, 0, pics) | ||
failures = [] | ||
for idx, t in enumerate(test_cases): | ||
ok = test_runner.run_test_with_mock_read( | ||
test_spec_to_attribute_cache(t)) == t.expect_pass | ||
if not ok: | ||
failures.append(f"Measured test case failure: {idx} {t}") | ||
|
||
test_runner.Shutdown() | ||
print( | ||
f"Test of tests: run {len(test_cases)}, test response correct: {len(test_cases) - len(failures)} | test response incorrect: {len(failures)}") | ||
for f in failures: | ||
print(f) | ||
|
||
return 1 if failures else 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/python_testing/test_testing/test_TC_ICDM_2_1_min_pics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env -S python3 -B | ||
# | ||
# Copyright (c) 2024 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import sys | ||
|
||
from common_icdm_data import ICDMData, c, run_tests | ||
|
||
TEST_CASES = [ | ||
# Validate that the test script can succeed with the minimum set of PICS | ||
ICDMData(0, 1, 0, 100, [], 0, 2, 0, "", | ||
c.Enums.OperatingModeEnum.kSit, 64800, True), | ||
] | ||
|
||
|
||
def main(): | ||
pics = {"ICDM.S.A0000": True, "ICDM.S.A0001": True, "ICDM.S.A0002": True, "ICDM.S.A0003": False, "ICDM.S.A0004": False, | ||
"ICDM.S.A0005": False, "ICDM.S.A0006": False, "ICDM.S.A0007": False, "ICDM.S.A0008": False, "ICDM.S.A0009": False, } | ||
|
||
return run_tests(pics, 'TC_ICDM_2_1', TEST_CASES, 'test_TC_ICDM_2_1') | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |