blob: d34e59b2c927022e25ece8364de48e940b7bab98 [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 Shelleyafc6acd2022-01-12 14:32:56 -060025# Compile the test dts into a binary for pdbg.
26pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
Zane Shelley08c21c22022-01-26 16:58:18 -060027 input : files('pdbg-test.dts'),
28 output : 'pdbg-test.dtb',
Zane Shelleyafc6acd2022-01-12 14:32:56 -060029 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
30 '-o', '@OUTPUT@', '@INPUT@' ])
31
Zane Shelleyd195b712022-01-26 13:26:34 -060032pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
33
Zane Shelley08c21c22022-01-26 16:58:18 -060034################################################################################
35
Zane Shelley985388a2022-03-24 16:35:46 -050036# IMPORTANT NOTE:
37# We cannot link to `util_lib` because:
38# - It is built without `-DTEST_TRACE` and any of the util functions that use
39# `trace.hpp` will throw a linker error because we don't have access to
40# phosphor-logging in test ... yet.
41# - Some functions related to pdbg and dbus simply cannot be built in the test
42# environment. Instead, there are alternate implementation of those
43# functions to simulate them for testing.
44
45test_args = [
46 '-DTEST_TRACE',
47 package_args,
48]
49
50test_util_srcs = [
51 files(
52 '../util/data_file.cpp',
53 '../util/ffdc_file.cpp',
54 '../util/pdbg.cpp',
55 '../util/temporary_file.cpp',
56 'dbus-sim-only.cpp',
57 'pdbg-sim-only.cpp',
58 ),
59 pdbg_test_dtb
60]
61
62test_deps = [
63 libhei_dep,
64 libpdbg_dep,
65 gtest_dep,
66]
67
68test_vars = [
69 pdbg_env,
70]
71
72test_util_lib = static_library('test_util_lib',
73 sources : test_util_srcs,
74 include_directories : incdir,
75 dependencies : test_deps,
76 cpp_args : test_args,
77 install : false,
78)
79
80test_libs = [
81 analyzer_lib,
82 attn_lib,
83 test_util_lib,
84]
85
86################################################################################
87
Zane Shelley08c21c22022-01-26 16:58:18 -060088tc = 'test-bin-stream'
89
90src = [
91 files(
92 tc + '.cpp',
93 ),
Zane Shelley248cbf82019-05-03 17:07:18 -050094]
95
Zane Shelley08c21c22022-01-26 16:58:18 -060096dep = [ gtest_dep ]
Zane Shelleycb766a42022-01-12 17:50:23 -060097
Zane Shelley08c21c22022-01-26 16:58:18 -060098var = [ ]
99
100exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500101 link_with: test_libs,
102 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600103
104test(tc, exe, env: var)
105
106################################################################################
107
108tc = 'test-ffdc-file'
109
110src = [
111 files(
112 tc + '.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600113 ),
114]
Zane Shelley979e2872021-09-20 22:46:06 -0500115
Zane Shelley08c21c22022-01-26 16:58:18 -0600116dep = [ gtest_dep ]
Zane Shelleye90b85d2021-12-17 17:24:49 -0600117
Zane Shelley08c21c22022-01-26 16:58:18 -0600118var = [ ]
119
120exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500121 link_with: test_libs,
122 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600123
124test(tc, exe, env: var)
125
126################################################################################
127
128tc = 'test-lpc-timeout'
129
130src = [
131 files(
132 tc + '.cpp',
133 '../analyzer/plugins/p10-plugins.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600134 ),
Zane Shelley08c21c22022-01-26 16:58:18 -0600135]
136
137dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
138
139var = [ pdbg_env ]
140
141exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500142 link_with: test_libs,
143 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600144
145test(tc, exe, env: var)
146
147################################################################################
148
149tc = 'test-pdbg-dts'
150
151src = [
152 files(
153 tc + '.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600154 ),
Zane Shelley08c21c22022-01-26 16:58:18 -0600155]
156
157dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
158
159var = [ pdbg_env ]
160
161exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500162 link_with: test_libs,
163 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600164
165test(tc, exe, env: var)
166
167################################################################################
168
169tc = 'test-pll-unlock'
170
171src = [
172 files(
173 tc + '.cpp',
174 '../analyzer/plugins/p10-plugins.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600175 ),
Zane Shelley08c21c22022-01-26 16:58:18 -0600176]
177
178dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
179
180var = [ pdbg_env ]
181
182exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500183 link_with: test_libs,
184 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600185
186test(tc, exe, env: var)
187
188################################################################################
189
190tc = 'test-resolution'
191
192src = [
193 files(
194 tc + '.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -0600195 ),
Zane Shelley08c21c22022-01-26 16:58:18 -0600196]
197
198dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
199
200var = [ pdbg_env ]
201
202exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500203 link_with: test_libs,
204 cpp_args: test_args, include_directories: incdir)
Zane Shelley08c21c22022-01-26 16:58:18 -0600205
206test(tc, exe, env: var)
Zane Shelleyd195b712022-01-26 13:26:34 -0600207
208################################################################################
209
210tc = 'test-tod-step-check-fault'
211
212src = [
213 files(
214 tc + '.cpp',
215 '../analyzer/plugins/p10-tod-plugins.cpp',
Zane Shelleyd195b712022-01-26 13:26:34 -0600216 ),
Zane Shelleyd195b712022-01-26 13:26:34 -0600217]
218
219dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
220
221var = [ pdbg_env ]
222
223exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500224 link_with: test_libs,
225 cpp_args: test_args, include_directories: incdir)
Zane Shelleyd195b712022-01-26 13:26:34 -0600226
227test(tc, exe, env: var)
228
austinfcui444fa1c2022-02-08 10:20:37 -0600229################################################################################
230
231tc = 'test-ti-handler'
232
233src = [
234 files(
235 tc + '.cpp',
236 ),
237]
238
239dep = [ gtest_dep ]
240
241var = [ ]
242
243exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500244 link_with : hwdiags_libs, # TODO: should use test_libs instead
245 cpp_args: test_args, include_directories: incdir)
austinfcui444fa1c2022-02-08 10:20:37 -0600246
247test(tc, exe, env: var)
austinfcuibb742802022-03-10 08:12:22 -0600248
249################################################################################
250
251tc = 'test-attention'
252
253src = [
254 files(
255 tc + '.cpp',
256 ),
257 pdbg_test_dtb,
258]
259
260dep = [ gtest_dep ]
261
262var = [ pdbg_env ]
263
264exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500265 link_with : hwdiags_libs, # TODO: should use test_libs instead
266 cpp_args: test_args, include_directories: incdir)
austinfcuibb742802022-03-10 08:12:22 -0600267
268test(tc, exe, env: var)
austinfcuiab1e4dd2022-03-14 22:34:47 -0500269
270################################################################################
271
272tc = 'test-util-data-file'
273
274src = [
275 files(
276 tc + '.cpp',
277 ),
278]
279
280dep = [ gtest_dep ]
281
282var = [ ]
283
284exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500285 link_with : hwdiags_libs, # TODO: should use test_libs instead
286 cpp_args: test_args, include_directories: incdir)
austinfcuiab1e4dd2022-03-14 22:34:47 -0500287
288test(tc, exe, env: var)
Zane Shelleyedfcbc32022-03-24 15:56:52 -0500289
290################################################################################
291
292tc = 'test-end2end'
293
294src = [
295 files(
296 tc + '.cpp',
297 '../cli.cpp',
298 ),
299 pdbg_test_dtb,
300]
301
302dep = [ gtest_dep ]
303
304var = [ pdbg_env ]
305
306exe = executable(tc.underscorify(), src, dependencies: dep,
Zane Shelley985388a2022-03-24 16:35:46 -0500307 link_with : hwdiags_libs, # TODO: should use test_libs instead
308 cpp_args: test_args, include_directories: incdir)
Zane Shelleyedfcbc32022-03-24 15:56:52 -0500309
310test(tc, exe, env: var)
311