blob: ed7ef5c59a111db71ad16d2467a6fa702e016096 [file] [log] [blame]
Zane Shelley80183912021-12-21 11:52:25 -06001# Get the gtest/gmock dependencies.
2gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
3gmock_dep = dependency('gmock', disabler: true, required: false)
4if not gtest_dep.found() or not gmock_dep.found()
5 cmake = import('cmake')
6 gtest_proj = cmake.subproject('googletest',
7 required: false)
8 if gtest_proj.found()
9 gtest_dep = declare_dependency(
10 dependencies: [
11 dependency('threads'),
12 gtest_proj.dependency('gtest'),
13 gtest_proj.dependency('gtest_main'),
14 ]
15 )
16 gmock_dep = gtest_proj.dependency('gmock')
17 else
18 assert(not get_option('tests').enabled(),
19 'Googletest is required if tests are enabled')
20 endif
21endif
22
Zane Shelley9491cdb2022-02-01 10:40:45 -060023################################################################################
24
Zane Shelley08c21c22022-01-26 16:58:18 -060025# NOTE: We cannot link to `util_lib` because that is built without
26# `-DTEST_TRACE` and any of the util functions that use `trace.hpp` will
27# throw a linker error because we don't have access to phosphor-logging
28# in test ... yet.
29
Zane Shelley0c44c2f2020-06-05 17:14:31 -050030test_arg = [
31 '-DTEST_TRACE',
Zane Shelley9491cdb2022-02-01 10:40:45 -060032 package_args,
Zane Shelley0c44c2f2020-06-05 17:14:31 -050033]
34
Zane Shelleyafc6acd2022-01-12 14:32:56 -060035# Compile the test dts into a binary for pdbg.
36pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
Zane Shelley08c21c22022-01-26 16:58:18 -060037 input : files('pdbg-test.dts'),
38 output : 'pdbg-test.dtb',
Zane Shelleyafc6acd2022-01-12 14:32:56 -060039 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
40 '-o', '@OUTPUT@', '@INPUT@' ])
41
Zane Shelleyd195b712022-01-26 13:26:34 -060042pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
43
Zane Shelley08c21c22022-01-26 16:58:18 -060044################################################################################
45
46tc = 'test-bin-stream'
47
48src = [
49 files(
50 tc + '.cpp',
51 ),
Zane Shelley248cbf82019-05-03 17:07:18 -050052]
53
Zane Shelley08c21c22022-01-26 16:58:18 -060054dep = [ gtest_dep ]
Zane Shelleycb766a42022-01-12 17:50:23 -060055
Zane Shelley08c21c22022-01-26 16:58:18 -060056var = [ ]
57
58exe = executable(tc.underscorify(), src, dependencies: dep,
59 cpp_args: test_arg, include_directories: incdir)
60
61test(tc, exe, env: var)
62
63################################################################################
64
65tc = 'test-ffdc-file'
66
67src = [
68 files(
69 tc + '.cpp',
Zane Shelleycb766a42022-01-12 17:50:23 -060070 '../util/ffdc_file.cpp',
Zane Shelleycb766a42022-01-12 17:50:23 -060071 '../util/temporary_file.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -060072 ),
73]
Zane Shelley979e2872021-09-20 22:46:06 -050074
Zane Shelley08c21c22022-01-26 16:58:18 -060075dep = [ gtest_dep ]
Zane Shelleye90b85d2021-12-17 17:24:49 -060076
Zane Shelley08c21c22022-01-26 16:58:18 -060077var = [ ]
78
79exe = executable(tc.underscorify(), src, dependencies: dep,
80 cpp_args: test_arg, include_directories: incdir)
81
82test(tc, exe, env: var)
83
84################################################################################
85
86tc = 'test-lpc-timeout'
87
88src = [
89 files(
90 tc + '.cpp',
91 '../analyzer/plugins/p10-plugins.cpp',
92 '../analyzer/service_data.cpp',
93 '../util/pdbg.cpp',
Caleb Palmer626270a2022-02-21 11:05:08 -060094 'dbus-sim-only.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -060095 'pdbg-sim-only.cpp',
96 ),
97 pdbg_test_dtb,
98]
99
100dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
101
102var = [ pdbg_env ]
103
104exe = executable(tc.underscorify(), src, dependencies: dep,
105 cpp_args: test_arg, include_directories: incdir)
106
107test(tc, exe, env: var)
108
109################################################################################
110
111tc = 'test-pdbg-dts'
112
113src = [
114 files(
115 tc + '.cpp',
116 '../util/pdbg.cpp',
Caleb Palmer626270a2022-02-21 11:05:08 -0600117 'dbus-sim-only.cpp',
Zane Shelleyc7026262022-02-22 16:37:36 -0600118 'pdbg-sim-only.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600119 ),
120 pdbg_test_dtb,
121]
122
123dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
124
125var = [ pdbg_env ]
126
127exe = executable(tc.underscorify(), src, dependencies: dep,
128 cpp_args: test_arg, include_directories: incdir)
129
130test(tc, exe, env: var)
131
132################################################################################
133
134tc = 'test-pll-unlock'
135
136src = [
137 files(
138 tc + '.cpp',
139 '../analyzer/plugins/p10-plugins.cpp',
Zane Shelley9491cdb2022-02-01 10:40:45 -0600140 '../analyzer/ras-data/ras-data-parser.cpp',
141 '../analyzer/resolution.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600142 '../analyzer/service_data.cpp',
Zane Shelley9491cdb2022-02-01 10:40:45 -0600143 '../util/data_file.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600144 '../util/pdbg.cpp',
Caleb Palmer626270a2022-02-21 11:05:08 -0600145 'dbus-sim-only.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600146 'pdbg-sim-only.cpp',
147 ),
148 pdbg_test_dtb,
149]
150
151dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
152
153var = [ pdbg_env ]
154
155exe = executable(tc.underscorify(), src, dependencies: dep,
156 cpp_args: test_arg, include_directories: incdir)
157
158test(tc, exe, env: var)
159
160################################################################################
161
162tc = 'test-resolution'
163
164src = [
165 files(
166 tc + '.cpp',
167 '../analyzer/resolution.cpp',
168 '../analyzer/service_data.cpp',
169 '../util/pdbg.cpp',
Caleb Palmer626270a2022-02-21 11:05:08 -0600170 'dbus-sim-only.cpp',
Zane Shelleyc7026262022-02-22 16:37:36 -0600171 'pdbg-sim-only.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600172 ),
173 pdbg_test_dtb,
174]
175
176dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
177
178var = [ pdbg_env ]
179
180exe = executable(tc.underscorify(), src, dependencies: dep,
181 cpp_args: test_arg, include_directories: incdir)
182
183test(tc, exe, env: var)
Zane Shelleyd195b712022-01-26 13:26:34 -0600184
185################################################################################
186
187tc = 'test-tod-step-check-fault'
188
189src = [
190 files(
191 tc + '.cpp',
192 '../analyzer/plugins/p10-tod-plugins.cpp',
193 '../analyzer/service_data.cpp',
194 '../util/pdbg.cpp',
Caleb Palmer626270a2022-02-21 11:05:08 -0600195 'dbus-sim-only.cpp',
Zane Shelleyc7026262022-02-22 16:37:36 -0600196 'pdbg-sim-only.cpp',
Zane Shelleyd195b712022-01-26 13:26:34 -0600197 ),
198 pdbg_test_dtb,
199]
200
201dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
202
203var = [ pdbg_env ]
204
205exe = executable(tc.underscorify(), src, dependencies: dep,
206 cpp_args: test_arg, include_directories: incdir)
207
208test(tc, exe, env: var)
209
austinfcui444fa1c2022-02-08 10:20:37 -0600210################################################################################
211
212tc = 'test-ti-handler'
213
214src = [
215 files(
216 tc + '.cpp',
217 ),
218]
219
220dep = [ gtest_dep ]
221
222var = [ ]
223
224exe = executable(tc.underscorify(), src, dependencies: dep,
225 link_with : hwdiags_libs,
226 cpp_args: test_arg, include_directories: incdir)
227
228test(tc, exe, env: var)
austinfcuibb742802022-03-10 08:12:22 -0600229
230################################################################################
231
232tc = 'test-attention'
233
234src = [
235 files(
236 tc + '.cpp',
237 ),
238 pdbg_test_dtb,
239]
240
241dep = [ gtest_dep ]
242
243var = [ pdbg_env ]
244
245exe = executable(tc.underscorify(), src, dependencies: dep,
246 link_with : hwdiags_libs,
247 cpp_args: test_arg, include_directories: incdir)
248
249test(tc, exe, env: var)
austinfcuiab1e4dd2022-03-14 22:34:47 -0500250
251################################################################################
252
253tc = 'test-util-data-file'
254
255src = [
256 files(
257 tc + '.cpp',
258 ),
259]
260
261dep = [ gtest_dep ]
262
263var = [ ]
264
265exe = executable(tc.underscorify(), src, dependencies: dep,
266 link_with : hwdiags_libs,
267 cpp_args: test_arg, include_directories: incdir)
268
269test(tc, exe, env: var)
Zane Shelleyedfcbc32022-03-24 15:56:52 -0500270
271################################################################################
272
273tc = 'test-end2end'
274
275src = [
276 files(
277 tc + '.cpp',
278 '../cli.cpp',
279 ),
280 pdbg_test_dtb,
281]
282
283dep = [ gtest_dep ]
284
285var = [ pdbg_env ]
286
287exe = executable(tc.underscorify(), src, dependencies: dep,
288 link_with : hwdiags_libs,
289 cpp_args: test_arg, include_directories: incdir)
290
291test(tc, exe, env: var)
292