blob: 87449a708f49af139b3a6b07453aa2c64de8f1fd [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
Ben Tyner9ae5ca42020-02-28 13:13:50 -060044# end2end code exerciser for experiment and testing
45subdir('end2end')
46
Zane Shelley08c21c22022-01-26 16:58:18 -060047################################################################################
48
49tc = 'test-bin-stream'
50
51src = [
52 files(
53 tc + '.cpp',
54 ),
Zane Shelley248cbf82019-05-03 17:07:18 -050055]
56
Zane Shelley08c21c22022-01-26 16:58:18 -060057dep = [ gtest_dep ]
Zane Shelleycb766a42022-01-12 17:50:23 -060058
Zane Shelley08c21c22022-01-26 16:58:18 -060059var = [ ]
60
61exe = executable(tc.underscorify(), src, dependencies: dep,
62 cpp_args: test_arg, include_directories: incdir)
63
64test(tc, exe, env: var)
65
66################################################################################
67
68tc = 'test-ffdc-file'
69
70src = [
71 files(
72 tc + '.cpp',
Zane Shelleycb766a42022-01-12 17:50:23 -060073 '../util/ffdc_file.cpp',
Zane Shelleycb766a42022-01-12 17:50:23 -060074 '../util/temporary_file.cpp',
Zane Shelley08c21c22022-01-26 16:58:18 -060075 ),
76]
Zane Shelley979e2872021-09-20 22:46:06 -050077
Zane Shelley08c21c22022-01-26 16:58:18 -060078dep = [ gtest_dep ]
Zane Shelleye90b85d2021-12-17 17:24:49 -060079
Zane Shelley08c21c22022-01-26 16:58:18 -060080var = [ ]
81
82exe = executable(tc.underscorify(), src, dependencies: dep,
83 cpp_args: test_arg, include_directories: incdir)
84
85test(tc, exe, env: var)
86
87################################################################################
88
89tc = 'test-lpc-timeout'
90
91src = [
92 files(
93 tc + '.cpp',
94 '../analyzer/plugins/p10-plugins.cpp',
95 '../analyzer/service_data.cpp',
96 '../util/pdbg.cpp',
97 'pdbg-sim-only.cpp',
98 ),
99 pdbg_test_dtb,
100]
101
102dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
103
104var = [ pdbg_env ]
105
106exe = executable(tc.underscorify(), src, dependencies: dep,
107 cpp_args: test_arg, include_directories: incdir)
108
109test(tc, exe, env: var)
110
111################################################################################
112
113tc = 'test-pdbg-dts'
114
115src = [
116 files(
117 tc + '.cpp',
118 '../util/pdbg.cpp',
119 ),
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',
145 'pdbg-sim-only.cpp',
146 ),
147 pdbg_test_dtb,
148]
149
150dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
151
152var = [ pdbg_env ]
153
154exe = executable(tc.underscorify(), src, dependencies: dep,
155 cpp_args: test_arg, include_directories: incdir)
156
157test(tc, exe, env: var)
158
159################################################################################
160
161tc = 'test-resolution'
162
163src = [
164 files(
165 tc + '.cpp',
166 '../analyzer/resolution.cpp',
167 '../analyzer/service_data.cpp',
168 '../util/pdbg.cpp',
169 ),
170 pdbg_test_dtb,
171]
172
173dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
174
175var = [ pdbg_env ]
176
177exe = executable(tc.underscorify(), src, dependencies: dep,
178 cpp_args: test_arg, include_directories: incdir)
179
180test(tc, exe, env: var)
Zane Shelleyd195b712022-01-26 13:26:34 -0600181
182################################################################################
183
184tc = 'test-tod-step-check-fault'
185
186src = [
187 files(
188 tc + '.cpp',
189 '../analyzer/plugins/p10-tod-plugins.cpp',
190 '../analyzer/service_data.cpp',
191 '../util/pdbg.cpp',
192 ),
193 pdbg_test_dtb,
194]
195
196dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
197
198var = [ pdbg_env ]
199
200exe = executable(tc.underscorify(), src, dependencies: dep,
201 cpp_args: test_arg, include_directories: incdir)
202
203test(tc, exe, env: var)
204