blob: ba4ff6e5e983bf6cca4981a0070522a7b31f8f9b [file] [log] [blame]
George Liu7efd6f32022-06-22 10:42:56 +08001gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2gmock_dep = dependency('gmock', disabler: true, required: false)
3if not gtest_dep.found() or not gmock_dep.found()
4 gtest_proj = import('cmake').subproject('googletest', required: false)
5 if gtest_proj.found()
6 gtest_dep = declare_dependency(
7 dependencies: [
8 dependency('threads'),
9 gtest_proj.dependency('gtest'),
10 gtest_proj.dependency('gtest_main'),
11 ]
12 )
13 gmock_dep = gtest_proj.dependency('gmock')
14 else
15 assert(
16 not get_option('tests').enabled(),
17 'Googletest is required if tests are enabled'
18 )
19 endif
20endif
21
22pathgentest_hpp = custom_target(
23 'pathgentest.hpp',
24 command: [
25 prog_python,
26 meson.project_source_root() + '/src/pdmgen.py',
27 '-t', 'pathgentest.mako.hpp',
28 '-p', meson.project_source_root() + '/src/test/templates',
29 '-d', meson.project_source_root() + '/src/test/yaml/pathgentest',
30 '-o', meson.current_build_dir() + '/pathgentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +080031 '-e', meson.current_build_dir() + '/pathgentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +080032 'generate-cpp'
33 ],
34 input: [
35 'templates/pathgentest.mako.hpp',
36 'yaml/pathgentest/groupone.yaml',
37 'yaml/pathgentest/grouptwo.yaml',
38 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +030039 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +080040 output: 'pathgentest.hpp',
41)
42
43pathgentest_sources = [
44 pathgentest_hpp,
45 'pathgentest.cpp',
46]
47
48test('pathgentest.cpp',
49 executable(
50 'pathgentest',
51 pathgentest_sources,
52 build_by_default: false,
53 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +030054 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +080055 ))
56
57
58propertygentest_hpp = custom_target(
59 'propertygentest.hpp',
60 command: [
61 prog_python,
62 meson.project_source_root() + '/src/pdmgen.py',
63 '-t', 'propertygentest.mako.hpp',
64 '-p', meson.project_source_root() + '/src/test/templates',
65 '-d', meson.project_source_root() + '/src/test/yaml/propertygentest',
66 '-o', meson.current_build_dir() + '/propertygentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +080067 '-e', meson.current_build_dir() + '/propertygentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +080068 'generate-cpp'
69 ],
70 input: [
71 'templates/propertygentest.mako.hpp',
72 'yaml/propertygentest/groupone.yaml',
73 'yaml/propertygentest/grouptwo.yaml',
74 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +030075 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +080076 output: 'propertygentest.hpp',
77)
78
79propertygentest_sources = [
80 propertygentest_hpp,
81 'propertygentest.cpp',
82]
83
84test('propertygentest.cpp',
85 executable(
86 'propertygentest',
87 propertygentest_sources,
88 build_by_default: false,
89 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +030090 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +080091 ))
92
93
94propertywatchgentest_hpp = custom_target(
95 'propertywatchgentest.hpp',
96 command: [
97 prog_python,
98 meson.project_source_root() + '/src/pdmgen.py',
99 '-t', 'propertywatchgentest.mako.hpp',
100 '-p', meson.project_source_root() + '/src/test/templates',
101 '-d', meson.project_source_root() + '/src/test/yaml/propertywatchgentest',
102 '-o', meson.current_build_dir() + '/propertywatchgentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +0800103 '-e', meson.current_build_dir() + '/propertywatchgentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +0800104 'generate-cpp'
105 ],
106 input: [
107 'templates/propertywatchgentest.mako.hpp',
108 'yaml/propertywatchgentest/watchone.yaml',
109 'yaml/propertywatchgentest/watchtwo.yaml',
110 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300111 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +0800112 output: 'propertywatchgentest.hpp',
113)
114
115propertywatchgentest_sources = [
116 propertywatchgentest_hpp,
117 'propertywatchgentest.cpp',
118]
119
120test('propertywatchgentest.cpp',
121 executable(
122 'propertywatchgentest',
123 propertywatchgentest_sources,
124 build_by_default: false,
125 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300126 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +0800127 ))
128
129
130callbackgentest_hpp = custom_target(
131 'callbackgentest.hpp',
132 command: [
133 prog_python,
134 meson.project_source_root() + '/src/pdmgen.py',
135 '-t', 'callbackgentest.mako.hpp',
136 '-p', meson.project_source_root() + '/src/test/templates',
137 '-d', meson.project_source_root() + '/src/test/yaml/callbackgentest',
138 '-o', meson.current_build_dir() + '/callbackgentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +0800139 '-e', meson.current_build_dir() + '/callbackgentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +0800140 'generate-cpp'
141 ],
142 input: [
143 'templates/callbackgentest.mako.hpp',
144 'yaml/callbackgentest/one.yaml',
145 'yaml/callbackgentest/two.yaml',
146 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300147 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +0800148 output: 'callbackgentest.hpp',
149)
150
151callbackgentest_sources = [
152 callbackgentest_hpp,
153 'callbackgentest.cpp',
154]
155
156test('callbackgentest.cpp',
157 executable(
158 'callbackgentest',
159 callbackgentest_sources,
160 build_by_default: false,
161 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300162 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +0800163 ))
164
165
166callbackgroupgentest_hpp = custom_target(
167 'callbackgroupgentest.hpp',
168 command: [
169 prog_python,
170 meson.project_source_root() + '/src/pdmgen.py',
171 '-t', 'callbackgroupgentest.mako.hpp',
172 '-p', meson.project_source_root() + '/src/test/templates',
173 '-d', meson.project_source_root() + '/src/test/yaml/callbackgroupgentest',
174 '-o', meson.current_build_dir() + '/callbackgroupgentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +0800175 '-e', meson.current_build_dir() + '/callbackgroupgentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +0800176 'generate-cpp'
177 ],
178 input: [
179 'templates/callbackgroupgentest.mako.hpp',
180 'yaml/callbackgroupgentest/test.yaml',
181 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300182 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +0800183 output: 'callbackgroupgentest.hpp',
184)
185
186callbackgroupgentest_sources = [
187 callbackgroupgentest_hpp,
188 'callbackgroupgentest.cpp',
189]
190
191test('callbackgroupgentest.cpp',
192 executable(
193 'callbackgroupgentest',
194 callbackgroupgentest_sources,
195 build_by_default: false,
196 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300197 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +0800198 ))
199
200
201conditiongentest_hpp = custom_target(
202 'conditiongentest.hpp',
203 command: [
204 prog_python,
205 meson.project_source_root() + '/src/pdmgen.py',
206 '-t', 'conditiongentest.mako.hpp',
207 '-p', meson.project_source_root() + '/src/test/templates',
208 '-d', meson.project_source_root() + '/src/test/yaml/conditiongentest',
209 '-o', meson.current_build_dir() + '/conditiongentest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +0800210 '-e', meson.current_build_dir() + '/conditiongentest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +0800211 'generate-cpp'
212 ],
213 input: [
214 'templates/conditiongentest.mako.hpp',
215 'yaml/conditiongentest/test.yaml',
216 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300217 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +0800218 output: 'conditiongentest.hpp',
219)
220
221conditiongentest_sources = [
222 conditiongentest_hpp,
223 'conditiongentest.cpp',
224]
225
226test('conditiongentest.cpp',
227 executable(
228 'conditiongentest',
229 conditiongentest_sources,
230 build_by_default: false,
231 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300232 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
George Liu7efd6f32022-06-22 10:42:56 +0800233 ))
234
235
236callbacktest_sources = [
237 generated_hpp,
238 'callbacktest.cpp',
239 '../journal.cpp',
240 '../elog.cpp',
241 '../resolve_errors.cpp',
242 '../event_manager.cpp',
243 '../event_serialize.cpp',
244]
245
246callbacktest_deps = [
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300247 cereal_dep,
George Liu7efd6f32022-06-22 10:42:56 +0800248 sdbusplus_dep,
249 sdeventplus_dep,
250 phosphor_dbus_interfaces_dep,
251 phosphor_logging_dep,
252 gtest_dep,
253 gmock_dep,
254]
255
256test('callbacktest.cpp',
257 executable(
258 'callbacktest',
259 callbacktest_sources,
260 build_by_default: false,
261 include_directories: ['..', '../../'],
262 dependencies: callbacktest_deps,
263 ))
264
265
266interfaceaddtest_hpp = custom_target(
267 'interfaceaddtest.hpp',
268 command: [
269 prog_python,
270 meson.project_source_root() + '/src/pdmgen.py',
271 '-t', 'interfaceaddtest.mako.hpp',
272 '-p', meson.project_source_root() + '/src/test/templates',
273 '-d', meson.project_source_root() + '/src/test/yaml/interfaceaddtest',
274 '-o', meson.current_build_dir() + '/interfaceaddtest.hpp',
Matt Johnston04267b42022-08-04 15:05:11 +0800275 '-e', meson.current_build_dir() + '/interfaceaddtest-errors.hpp',
George Liu7efd6f32022-06-22 10:42:56 +0800276 'generate-cpp'
277 ],
278 input: [
279 'templates/interfaceaddtest.mako.hpp',
280 'yaml/interfaceaddtest/one.yaml',
281 ],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300282 env: sdbusplus_python_env,
George Liu7efd6f32022-06-22 10:42:56 +0800283 output: 'interfaceaddtest.hpp',
284)
285
286interfaceaddtest_sources = [
287 interfaceaddtest_hpp,
288 'interfaceaddtest.cpp',
289]
290
291test('interfaceaddtest.cpp',
292 executable(
293 'interfaceaddtest',
294 interfaceaddtest_sources,
295 build_by_default: false,
296 include_directories: ['..'],
Konstantin Aladyshevcd1e72a2024-10-10 17:22:19 +0300297 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep, sdeventplus_dep]
George Liu7efd6f32022-06-22 10:42:56 +0800298 ))