|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +# Copyright (c) 2024 Project CHIP Authors |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +import os |
| 17 | +import re |
| 18 | +import sys |
| 19 | +from pathlib import Path |
| 20 | + |
| 21 | +from chiptest import AllChipToolYamlTests |
| 22 | + |
| 23 | +DEFAULT_CHIP_ROOT = os.path.abspath( |
| 24 | + os.path.join(os.path.dirname(__file__), '..', '..')) |
| 25 | + |
| 26 | +# TODO: These tests need to be re-written. Please see https://github.com/project-chip/connectedhomeip/issues/32620 |
| 27 | +KNOWN_BAD_UNIT_TESTING = set(('Test_TC_S_2_2.yaml', 'Test_TC_S_2_3.yaml')) |
| 28 | + |
| 29 | + |
| 30 | +def _is_cert_test(path): |
| 31 | + return "certification" in os.path.dirname(path) |
| 32 | + |
| 33 | + |
| 34 | +def main(): |
| 35 | + bad_tests = set() |
| 36 | + for test in AllChipToolYamlTests(use_short_run_name=False): |
| 37 | + with open(test.run_name, "r") as f: |
| 38 | + # Unit testing cluster is disallowed in cert tests, but permissible in general integration tests |
| 39 | + unit_test_lines = {} |
| 40 | + if _is_cert_test(test.run_name): |
| 41 | + unit_test_lines = {lineno: line.strip() for lineno, line in enumerate( |
| 42 | + f) if re.search('cluster: "Unit Testing"', line)} |
| 43 | + if unit_test_lines: |
| 44 | + print( |
| 45 | + f'Found certification test using Unit Testing cluster: {test.name}') |
| 46 | + for line, val in unit_test_lines.items(): |
| 47 | + print(f'\t{line+1}: {val}') |
| 48 | + bad_tests.add(Path(test.run_name).name) |
| 49 | + |
| 50 | + if bad_tests - KNOWN_BAD_UNIT_TESTING: |
| 51 | + return 1 |
| 52 | + return 0 |
| 53 | + |
| 54 | + |
| 55 | +if __name__ == '__main__': |
| 56 | + sys.exit(main()) |
0 commit comments