4 # Copyright (c) 2020 Project CHIP Authors
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
22 TEMPLATE_PREFIX = '''/*
24 * Copyright (c) 2020 Project CHIP Authors
25 * All rights reserved.
27 * Licensed under the Apache License, Version 2.0 (the \"License\");
28 * you may not use this file except in compliance with the License.
29 * You may obtain a copy of the License at
31 * http://www.apache.org/licenses/LICENSE-2.0
33 * Unless required by applicable law or agreed to in writing, software
34 * distributed under the License is distributed on an \"AS IS\" BASIS,
35 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 * See the License for the specific language governing permissions and
37 * limitations under the License.
39 * THIS FILE WAS GENERATED AUTOMATICALLY BY THE BUILD SYSTEM.
42 #include <nlunit-test.h>
46 ### Forward declarations will be added here
48 TEMPLATE_MAIN_START = '''
53 nlTestSetOutputStyle(OUTPUT_CSV);
57 ### Test invokation will be added here
64 parser = optparse.OptionParser()
66 parser.add_option('--input_file')
67 parser.add_option('--output_file')
69 options, _ = parser.parse_args(argv)
73 TEST_SUITE_RE = re.compile(r'\s*CHIP_REGISTER_TEST_SUITE\(([^)]*)\)')
75 with open(options.input_file, 'r') as input_file:
76 for l in input_file.readlines():
77 match = TEST_SUITE_RE.match(l)
81 tests.append(match.group(1))
84 print("ERROR: no tests found in '%s'" % input_file);
85 print("Did you forget to CHIP_REGISTER_TEST_SUITE?");
88 with open(options.output_file, 'w') as output_file:
89 output_file.write(TEMPLATE_PREFIX)
92 output_file.write("int %s();\n" % test)
93 output_file.write("\n");
95 output_file.write(TEMPLATE_MAIN_START)
98 output_file.write(" code = code | (%s());\n" % test)
99 output_file.write("\n");
102 output_file.write(TEMPLATE_SUFFIX)
108 if __name__ == '__main__':
109 sys.exit(main(sys.argv[1:]))