blob: 0fa9c9e2b25966ef6899e32788c80d7e4d6ff585 [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 Shelley08c21c22022-01-26 16:58:18 -060023# NOTE: We cannot link to `util_lib` because that is built without
24# `-DTEST_TRACE` and any of the util functions that use `trace.hpp` will
25# throw a linker error because we don't have access to phosphor-logging
26# in test ... yet.
27
Zane Shelley0c44c2f2020-06-05 17:14:31 -050028test_arg = [
29 '-DTEST_TRACE',
30]
31
Zane Shelleyafc6acd2022-01-12 14:32:56 -060032# Compile the test dts into a binary for pdbg.
33pdbg_test_dtb = custom_target('build_pdbg_test_dtb',
Zane Shelley08c21c22022-01-26 16:58:18 -060034 input : files('pdbg-test.dts'),
35 output : 'pdbg-test.dtb',
Zane Shelleyafc6acd2022-01-12 14:32:56 -060036 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
37 '-o', '@OUTPUT@', '@INPUT@' ])
38
Zane Shelleyd195b712022-01-26 13:26:34 -060039pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
40
Ben Tyner9ae5ca42020-02-28 13:13:50 -060041# end2end code exerciser for experiment and testing
42subdir('end2end')
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',
94 'pdbg-sim-only.cpp',
95 ),
96 pdbg_test_dtb,
97]
98
99dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
100
101var = [ pdbg_env ]
102
103exe = executable(tc.underscorify(), src, dependencies: dep,
104 cpp_args: test_arg, include_directories: incdir)
105
106test(tc, exe, env: var)
107
108################################################################################
109
110tc = 'test-pdbg-dts'
111
112src = [
113 files(
114 tc + '.cpp',
115 '../util/pdbg.cpp',
116 ),
117 pdbg_test_dtb,
118]
119
120dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
121
122var = [ pdbg_env ]
123
124exe = executable(tc.underscorify(), src, dependencies: dep,
125 cpp_args: test_arg, include_directories: incdir)
126
127test(tc, exe, env: var)
128
129################################################################################
130
131tc = 'test-pll-unlock'
132
133src = [
134 files(
135 tc + '.cpp',
136 '../analyzer/plugins/p10-plugins.cpp',
137 '../analyzer/service_data.cpp',
138 '../util/pdbg.cpp',
139 'pdbg-sim-only.cpp',
140 ),
141 pdbg_test_dtb,
142]
143
144dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
145
146var = [ pdbg_env ]
147
148exe = executable(tc.underscorify(), src, dependencies: dep,
149 cpp_args: test_arg, include_directories: incdir)
150
151test(tc, exe, env: var)
152
153################################################################################
154
155tc = 'test-resolution'
156
157src = [
158 files(
159 tc + '.cpp',
160 '../analyzer/resolution.cpp',
161 '../analyzer/service_data.cpp',
162 '../util/pdbg.cpp',
163 ),
164 pdbg_test_dtb,
165]
166
167dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
168
169var = [ pdbg_env ]
170
171exe = executable(tc.underscorify(), src, dependencies: dep,
172 cpp_args: test_arg, include_directories: incdir)
173
174test(tc, exe, env: var)
Zane Shelleyd195b712022-01-26 13:26:34 -0600175
176################################################################################
177
178tc = 'test-tod-step-check-fault'
179
180src = [
181 files(
182 tc + '.cpp',
183 '../analyzer/plugins/p10-tod-plugins.cpp',
184 '../analyzer/service_data.cpp',
185 '../util/pdbg.cpp',
186 ),
187 pdbg_test_dtb,
188]
189
190dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
191
192var = [ pdbg_env ]
193
194exe = executable(tc.underscorify(), src, dependencies: dep,
195 cpp_args: test_arg, include_directories: incdir)
196
197test(tc, exe, env: var)
198