Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 1 | # Get the gtest/gmock dependencies. |
| 2 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 3 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 4 | if 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 |
| 21 | endif |
| 22 | |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 23 | ################################################################################ |
| 24 | |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 25 | # Compile the test dts into a binary for pdbg. |
| 26 | pdbg_test_dtb = custom_target('build_pdbg_test_dtb', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 27 | input : files('pdbg-test.dts'), |
| 28 | output : 'pdbg-test.dtb', |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 29 | command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', |
| 30 | '-o', '@OUTPUT@', '@INPUT@' ]) |
| 31 | |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 32 | pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() |
| 33 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 34 | ################################################################################ |
| 35 | |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 36 | # 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 | |
| 45 | test_args = [ |
| 46 | '-DTEST_TRACE', |
| 47 | package_args, |
| 48 | ] |
| 49 | |
| 50 | test_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 | |
| 62 | test_deps = [ |
| 63 | libhei_dep, |
| 64 | libpdbg_dep, |
| 65 | gtest_dep, |
| 66 | ] |
| 67 | |
| 68 | test_vars = [ |
| 69 | pdbg_env, |
| 70 | ] |
| 71 | |
| 72 | test_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 | |
| 80 | test_libs = [ |
| 81 | analyzer_lib, |
| 82 | attn_lib, |
| 83 | test_util_lib, |
| 84 | ] |
| 85 | |
| 86 | ################################################################################ |
| 87 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 88 | tc = 'test-bin-stream' |
| 89 | |
| 90 | src = [ |
| 91 | files( |
| 92 | tc + '.cpp', |
| 93 | ), |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 94 | ] |
| 95 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 96 | dep = [ gtest_dep ] |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 97 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 98 | var = [ ] |
| 99 | |
| 100 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 101 | link_with: test_libs, |
| 102 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 103 | |
| 104 | test(tc, exe, env: var) |
| 105 | |
| 106 | ################################################################################ |
| 107 | |
| 108 | tc = 'test-ffdc-file' |
| 109 | |
| 110 | src = [ |
| 111 | files( |
| 112 | tc + '.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 113 | ), |
| 114 | ] |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 115 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 116 | dep = [ gtest_dep ] |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 117 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 118 | var = [ ] |
| 119 | |
| 120 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 121 | link_with: test_libs, |
| 122 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 123 | |
| 124 | test(tc, exe, env: var) |
| 125 | |
| 126 | ################################################################################ |
| 127 | |
| 128 | tc = 'test-lpc-timeout' |
| 129 | |
| 130 | src = [ |
| 131 | files( |
| 132 | tc + '.cpp', |
| 133 | '../analyzer/plugins/p10-plugins.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 134 | ), |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 135 | ] |
| 136 | |
| 137 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 138 | |
| 139 | var = [ pdbg_env ] |
| 140 | |
| 141 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 142 | link_with: test_libs, |
| 143 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 144 | |
| 145 | test(tc, exe, env: var) |
| 146 | |
| 147 | ################################################################################ |
| 148 | |
| 149 | tc = 'test-pdbg-dts' |
| 150 | |
| 151 | src = [ |
| 152 | files( |
| 153 | tc + '.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 154 | ), |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 155 | ] |
| 156 | |
| 157 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 158 | |
| 159 | var = [ pdbg_env ] |
| 160 | |
| 161 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 162 | link_with: test_libs, |
| 163 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 164 | |
| 165 | test(tc, exe, env: var) |
| 166 | |
| 167 | ################################################################################ |
| 168 | |
| 169 | tc = 'test-pll-unlock' |
| 170 | |
| 171 | src = [ |
| 172 | files( |
| 173 | tc + '.cpp', |
| 174 | '../analyzer/plugins/p10-plugins.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 175 | ), |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 176 | ] |
| 177 | |
| 178 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 179 | |
| 180 | var = [ pdbg_env ] |
| 181 | |
| 182 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 183 | link_with: test_libs, |
| 184 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 185 | |
| 186 | test(tc, exe, env: var) |
| 187 | |
| 188 | ################################################################################ |
| 189 | |
| 190 | tc = 'test-resolution' |
| 191 | |
| 192 | src = [ |
| 193 | files( |
| 194 | tc + '.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 195 | ), |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 196 | ] |
| 197 | |
| 198 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 199 | |
| 200 | var = [ pdbg_env ] |
| 201 | |
| 202 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 203 | link_with: test_libs, |
| 204 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 205 | |
| 206 | test(tc, exe, env: var) |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 207 | |
| 208 | ################################################################################ |
| 209 | |
| 210 | tc = 'test-tod-step-check-fault' |
| 211 | |
| 212 | src = [ |
| 213 | files( |
| 214 | tc + '.cpp', |
| 215 | '../analyzer/plugins/p10-tod-plugins.cpp', |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 216 | ), |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 217 | ] |
| 218 | |
| 219 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 220 | |
| 221 | var = [ pdbg_env ] |
| 222 | |
| 223 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 224 | link_with: test_libs, |
| 225 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 226 | |
| 227 | test(tc, exe, env: var) |
| 228 | |
austinfcui | 444fa1c | 2022-02-08 10:20:37 -0600 | [diff] [blame] | 229 | ################################################################################ |
| 230 | |
| 231 | tc = 'test-ti-handler' |
| 232 | |
| 233 | src = [ |
| 234 | files( |
| 235 | tc + '.cpp', |
| 236 | ), |
| 237 | ] |
| 238 | |
| 239 | dep = [ gtest_dep ] |
| 240 | |
| 241 | var = [ ] |
| 242 | |
| 243 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 244 | link_with : hwdiags_libs, # TODO: should use test_libs instead |
| 245 | cpp_args: test_args, include_directories: incdir) |
austinfcui | 444fa1c | 2022-02-08 10:20:37 -0600 | [diff] [blame] | 246 | |
| 247 | test(tc, exe, env: var) |
austinfcui | bb74280 | 2022-03-10 08:12:22 -0600 | [diff] [blame] | 248 | |
| 249 | ################################################################################ |
| 250 | |
| 251 | tc = 'test-attention' |
| 252 | |
| 253 | src = [ |
| 254 | files( |
| 255 | tc + '.cpp', |
| 256 | ), |
| 257 | pdbg_test_dtb, |
| 258 | ] |
| 259 | |
| 260 | dep = [ gtest_dep ] |
| 261 | |
| 262 | var = [ pdbg_env ] |
| 263 | |
| 264 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 265 | link_with : hwdiags_libs, # TODO: should use test_libs instead |
| 266 | cpp_args: test_args, include_directories: incdir) |
austinfcui | bb74280 | 2022-03-10 08:12:22 -0600 | [diff] [blame] | 267 | |
| 268 | test(tc, exe, env: var) |
austinfcui | ab1e4dd | 2022-03-14 22:34:47 -0500 | [diff] [blame] | 269 | |
| 270 | ################################################################################ |
| 271 | |
| 272 | tc = 'test-util-data-file' |
| 273 | |
| 274 | src = [ |
| 275 | files( |
| 276 | tc + '.cpp', |
| 277 | ), |
| 278 | ] |
| 279 | |
| 280 | dep = [ gtest_dep ] |
| 281 | |
| 282 | var = [ ] |
| 283 | |
| 284 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 285 | link_with : hwdiags_libs, # TODO: should use test_libs instead |
| 286 | cpp_args: test_args, include_directories: incdir) |
austinfcui | ab1e4dd | 2022-03-14 22:34:47 -0500 | [diff] [blame] | 287 | |
| 288 | test(tc, exe, env: var) |
Zane Shelley | edfcbc3 | 2022-03-24 15:56:52 -0500 | [diff] [blame] | 289 | |
| 290 | ################################################################################ |
| 291 | |
| 292 | tc = 'test-end2end' |
| 293 | |
| 294 | src = [ |
| 295 | files( |
| 296 | tc + '.cpp', |
| 297 | '../cli.cpp', |
| 298 | ), |
| 299 | pdbg_test_dtb, |
| 300 | ] |
| 301 | |
| 302 | dep = [ gtest_dep ] |
| 303 | |
| 304 | var = [ pdbg_env ] |
| 305 | |
| 306 | exe = executable(tc.underscorify(), src, dependencies: dep, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame^] | 307 | link_with : hwdiags_libs, # TODO: should use test_libs instead |
| 308 | cpp_args: test_args, include_directories: incdir) |
Zane Shelley | edfcbc3 | 2022-03-24 15:56:52 -0500 | [diff] [blame] | 309 | |
| 310 | test(tc, exe, env: var) |
| 311 | |