1# 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 23################################################################################ 24 25# Compile the test dts into a binary for pdbg. 26pdbg_test_dtb = custom_target('build_pdbg_test_dtb', 27 input : files('pdbg-test.dts'), 28 output : 'pdbg-test.dtb', 29 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', 30 '-o', '@OUTPUT@', '@INPUT@' ]) 31 32pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() 33 34################################################################################ 35 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 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 88tc = 'test-bin-stream' 89 90src = [ 91 files( 92 tc + '.cpp', 93 ), 94] 95 96dep = [ gtest_dep ] 97 98var = [ ] 99 100exe = executable(tc.underscorify(), src, dependencies: dep, 101 link_with: test_libs, 102 cpp_args: test_args, include_directories: incdir) 103 104test(tc, exe, env: var) 105 106################################################################################ 107 108tc = 'test-ffdc-file' 109 110src = [ 111 files( 112 tc + '.cpp', 113 ), 114] 115 116dep = [ gtest_dep ] 117 118var = [ ] 119 120exe = executable(tc.underscorify(), src, dependencies: dep, 121 link_with: test_libs, 122 cpp_args: test_args, include_directories: incdir) 123 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', 134 ), 135] 136 137dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 138 139var = [ pdbg_env ] 140 141exe = executable(tc.underscorify(), src, dependencies: dep, 142 link_with: test_libs, 143 cpp_args: test_args, include_directories: incdir) 144 145test(tc, exe, env: var) 146 147################################################################################ 148 149tc = 'test-pdbg-dts' 150 151src = [ 152 files( 153 tc + '.cpp', 154 ), 155] 156 157dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 158 159var = [ pdbg_env ] 160 161exe = executable(tc.underscorify(), src, dependencies: dep, 162 link_with: test_libs, 163 cpp_args: test_args, include_directories: incdir) 164 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', 175 ), 176] 177 178dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 179 180var = [ pdbg_env ] 181 182exe = executable(tc.underscorify(), src, dependencies: dep, 183 link_with: test_libs, 184 cpp_args: test_args, include_directories: incdir) 185 186test(tc, exe, env: var) 187 188################################################################################ 189 190tc = 'test-resolution' 191 192src = [ 193 files( 194 tc + '.cpp', 195 ), 196] 197 198dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 199 200var = [ pdbg_env ] 201 202exe = executable(tc.underscorify(), src, dependencies: dep, 203 link_with: test_libs, 204 cpp_args: test_args, include_directories: incdir) 205 206test(tc, exe, env: var) 207 208################################################################################ 209 210tc = 'test-tod-step-check-fault' 211 212src = [ 213 files( 214 tc + '.cpp', 215 '../analyzer/plugins/p10-tod-plugins.cpp', 216 ), 217] 218 219dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 220 221var = [ pdbg_env ] 222 223exe = executable(tc.underscorify(), src, dependencies: dep, 224 link_with: test_libs, 225 cpp_args: test_args, include_directories: incdir) 226 227test(tc, exe, env: var) 228 229################################################################################ 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, 244 link_with : hwdiags_libs, # TODO: should use test_libs instead 245 cpp_args: test_args, include_directories: incdir) 246 247test(tc, exe, env: var) 248 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, 265 link_with : hwdiags_libs, # TODO: should use test_libs instead 266 cpp_args: test_args, include_directories: incdir) 267 268test(tc, exe, env: var) 269 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, 285 link_with : hwdiags_libs, # TODO: should use test_libs instead 286 cpp_args: test_args, include_directories: incdir) 287 288test(tc, exe, env: var) 289 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, 307 link_with : hwdiags_libs, # TODO: should use test_libs instead 308 cpp_args: test_args, include_directories: incdir) 309 310test(tc, exe, env: var) 311 312