18018391dSZane Shelley# Get the gtest/gmock dependencies. 28018391dSZane Shelleygtest_dep = dependency('gtest', main: true, disabler: true, required: false) 38018391dSZane Shelleygmock_dep = dependency('gmock', disabler: true, required: false) 48018391dSZane Shelleyif not gtest_dep.found() or not gmock_dep.found() 58018391dSZane Shelley cmake = import('cmake') 68018391dSZane Shelley gtest_proj = cmake.subproject('googletest', 78018391dSZane Shelley required: false) 88018391dSZane Shelley if gtest_proj.found() 98018391dSZane Shelley gtest_dep = declare_dependency( 108018391dSZane Shelley dependencies: [ 118018391dSZane Shelley dependency('threads'), 128018391dSZane Shelley gtest_proj.dependency('gtest'), 138018391dSZane Shelley gtest_proj.dependency('gtest_main'), 148018391dSZane Shelley ] 158018391dSZane Shelley ) 168018391dSZane Shelley gmock_dep = gtest_proj.dependency('gmock') 178018391dSZane Shelley else 188018391dSZane Shelley assert(not get_option('tests').enabled(), 198018391dSZane Shelley 'Googletest is required if tests are enabled') 208018391dSZane Shelley endif 218018391dSZane Shelleyendif 228018391dSZane Shelley 239491cdb4SZane Shelley################################################################################ 249491cdb4SZane Shelley 25afc6acdaSZane Shelley# Compile the test dts into a binary for pdbg. 26afc6acdaSZane Shelleypdbg_test_dtb = custom_target('build_pdbg_test_dtb', 2708c21c25SZane Shelley input : files('pdbg-test.dts'), 2808c21c25SZane Shelley output : 'pdbg-test.dtb', 29afc6acdaSZane Shelley command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', 30afc6acdaSZane Shelley '-o', '@OUTPUT@', '@INPUT@' ]) 31afc6acdaSZane Shelley 32d195b716SZane Shelleypdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() 33d195b716SZane Shelley 3408c21c25SZane Shelley################################################################################ 3508c21c25SZane Shelley 36*985388a8SZane Shelley# IMPORTANT NOTE: 37*985388a8SZane Shelley# We cannot link to `util_lib` because: 38*985388a8SZane Shelley# - It is built without `-DTEST_TRACE` and any of the util functions that use 39*985388a8SZane Shelley# `trace.hpp` will throw a linker error because we don't have access to 40*985388a8SZane Shelley# phosphor-logging in test ... yet. 41*985388a8SZane Shelley# - Some functions related to pdbg and dbus simply cannot be built in the test 42*985388a8SZane Shelley# environment. Instead, there are alternate implementation of those 43*985388a8SZane Shelley# functions to simulate them for testing. 44*985388a8SZane Shelley 45*985388a8SZane Shelleytest_args = [ 46*985388a8SZane Shelley '-DTEST_TRACE', 47*985388a8SZane Shelley package_args, 48*985388a8SZane Shelley] 49*985388a8SZane Shelley 50*985388a8SZane Shelleytest_util_srcs = [ 51*985388a8SZane Shelley files( 52*985388a8SZane Shelley '../util/data_file.cpp', 53*985388a8SZane Shelley '../util/ffdc_file.cpp', 54*985388a8SZane Shelley '../util/pdbg.cpp', 55*985388a8SZane Shelley '../util/temporary_file.cpp', 56*985388a8SZane Shelley 'dbus-sim-only.cpp', 57*985388a8SZane Shelley 'pdbg-sim-only.cpp', 58*985388a8SZane Shelley ), 59*985388a8SZane Shelley pdbg_test_dtb 60*985388a8SZane Shelley] 61*985388a8SZane Shelley 62*985388a8SZane Shelleytest_deps = [ 63*985388a8SZane Shelley libhei_dep, 64*985388a8SZane Shelley libpdbg_dep, 65*985388a8SZane Shelley gtest_dep, 66*985388a8SZane Shelley] 67*985388a8SZane Shelley 68*985388a8SZane Shelleytest_vars = [ 69*985388a8SZane Shelley pdbg_env, 70*985388a8SZane Shelley] 71*985388a8SZane Shelley 72*985388a8SZane Shelleytest_util_lib = static_library('test_util_lib', 73*985388a8SZane Shelley sources : test_util_srcs, 74*985388a8SZane Shelley include_directories : incdir, 75*985388a8SZane Shelley dependencies : test_deps, 76*985388a8SZane Shelley cpp_args : test_args, 77*985388a8SZane Shelley install : false, 78*985388a8SZane Shelley) 79*985388a8SZane Shelley 80*985388a8SZane Shelleytest_libs = [ 81*985388a8SZane Shelley analyzer_lib, 82*985388a8SZane Shelley attn_lib, 83*985388a8SZane Shelley test_util_lib, 84*985388a8SZane Shelley] 85*985388a8SZane Shelley 86*985388a8SZane Shelley################################################################################ 87*985388a8SZane Shelley 8808c21c25SZane Shelleytc = 'test-bin-stream' 8908c21c25SZane Shelley 9008c21c25SZane Shelleysrc = [ 9108c21c25SZane Shelley files( 9208c21c25SZane Shelley tc + '.cpp', 9308c21c25SZane Shelley ), 94248cbf83SZane Shelley] 95248cbf83SZane Shelley 9608c21c25SZane Shelleydep = [ gtest_dep ] 9708c21c25SZane Shelley 9808c21c25SZane Shelleyvar = [ ] 9908c21c25SZane Shelley 10008c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 101*985388a8SZane Shelley link_with: test_libs, 102*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 10308c21c25SZane Shelley 10408c21c25SZane Shelleytest(tc, exe, env: var) 10508c21c25SZane Shelley 10608c21c25SZane Shelley################################################################################ 10708c21c25SZane Shelley 10808c21c25SZane Shelleytc = 'test-ffdc-file' 10908c21c25SZane Shelley 11008c21c25SZane Shelleysrc = [ 11108c21c25SZane Shelley files( 11208c21c25SZane Shelley tc + '.cpp', 11308c21c25SZane Shelley ), 11408c21c25SZane Shelley] 11508c21c25SZane Shelley 11608c21c25SZane Shelleydep = [ gtest_dep ] 11708c21c25SZane Shelley 11808c21c25SZane Shelleyvar = [ ] 11908c21c25SZane Shelley 12008c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 121*985388a8SZane Shelley link_with: test_libs, 122*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 12308c21c25SZane Shelley 12408c21c25SZane Shelleytest(tc, exe, env: var) 12508c21c25SZane Shelley 12608c21c25SZane Shelley################################################################################ 12708c21c25SZane Shelley 12808c21c25SZane Shelleytc = 'test-lpc-timeout' 12908c21c25SZane Shelley 13008c21c25SZane Shelleysrc = [ 13108c21c25SZane Shelley files( 13208c21c25SZane Shelley tc + '.cpp', 1332c228cdcSZane Shelley '../analyzer/plugins/p10-plugins.cpp', 13408c21c25SZane Shelley ), 13508c21c25SZane Shelley] 136e90b85dcSZane Shelley 13708c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 13808c21c25SZane Shelley 13908c21c25SZane Shelleyvar = [ pdbg_env ] 14008c21c25SZane Shelley 14108c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 142*985388a8SZane Shelley link_with: test_libs, 143*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 14408c21c25SZane Shelley 14508c21c25SZane Shelleytest(tc, exe, env: var) 14608c21c25SZane Shelley 14708c21c25SZane Shelley################################################################################ 14808c21c25SZane Shelley 14908c21c25SZane Shelleytc = 'test-pdbg-dts' 15008c21c25SZane Shelley 15108c21c25SZane Shelleysrc = [ 15208c21c25SZane Shelley files( 15308c21c25SZane Shelley tc + '.cpp', 15408c21c25SZane Shelley ), 15508c21c25SZane Shelley] 15608c21c25SZane Shelley 15708c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 15808c21c25SZane Shelley 15908c21c25SZane Shelleyvar = [ pdbg_env ] 16008c21c25SZane Shelley 16108c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 162*985388a8SZane Shelley link_with: test_libs, 163*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 16408c21c25SZane Shelley 16508c21c25SZane Shelleytest(tc, exe, env: var) 16608c21c25SZane Shelley 16708c21c25SZane Shelley################################################################################ 16808c21c25SZane Shelley 16908c21c25SZane Shelleytc = 'test-pll-unlock' 17008c21c25SZane Shelley 17108c21c25SZane Shelleysrc = [ 17208c21c25SZane Shelley files( 17308c21c25SZane Shelley tc + '.cpp', 17408c21c25SZane Shelley '../analyzer/plugins/p10-plugins.cpp', 17508c21c25SZane Shelley ), 17608c21c25SZane Shelley] 17708c21c25SZane Shelley 17808c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 17908c21c25SZane Shelley 18008c21c25SZane Shelleyvar = [ pdbg_env ] 18108c21c25SZane Shelley 18208c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 183*985388a8SZane Shelley link_with: test_libs, 184*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 18508c21c25SZane Shelley 18608c21c25SZane Shelleytest(tc, exe, env: var) 18708c21c25SZane Shelley 18808c21c25SZane Shelley################################################################################ 18908c21c25SZane Shelley 19008c21c25SZane Shelleytc = 'test-resolution' 19108c21c25SZane Shelley 19208c21c25SZane Shelleysrc = [ 19308c21c25SZane Shelley files( 19408c21c25SZane Shelley tc + '.cpp', 19508c21c25SZane Shelley ), 19608c21c25SZane Shelley] 19708c21c25SZane Shelley 19808c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 19908c21c25SZane Shelley 20008c21c25SZane Shelleyvar = [ pdbg_env ] 20108c21c25SZane Shelley 20208c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 203*985388a8SZane Shelley link_with: test_libs, 204*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 20508c21c25SZane Shelley 20608c21c25SZane Shelleytest(tc, exe, env: var) 207d195b716SZane Shelley 208d195b716SZane Shelley################################################################################ 209d195b716SZane Shelley 210d195b716SZane Shelleytc = 'test-tod-step-check-fault' 211d195b716SZane Shelley 212d195b716SZane Shelleysrc = [ 213d195b716SZane Shelley files( 214d195b716SZane Shelley tc + '.cpp', 215d195b716SZane Shelley '../analyzer/plugins/p10-tod-plugins.cpp', 216d195b716SZane Shelley ), 217d195b716SZane Shelley] 218d195b716SZane Shelley 219d195b716SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 220d195b716SZane Shelley 221d195b716SZane Shelleyvar = [ pdbg_env ] 222d195b716SZane Shelley 223d195b716SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 224*985388a8SZane Shelley link_with: test_libs, 225*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 226d195b716SZane Shelley 227d195b716SZane Shelleytest(tc, exe, env: var) 228d195b716SZane Shelley 229444fa1c0Saustinfcui################################################################################ 230444fa1c0Saustinfcui 231444fa1c0Saustinfcuitc = 'test-ti-handler' 232444fa1c0Saustinfcui 233444fa1c0Saustinfcuisrc = [ 234444fa1c0Saustinfcui files( 235444fa1c0Saustinfcui tc + '.cpp', 236444fa1c0Saustinfcui ), 237444fa1c0Saustinfcui] 238444fa1c0Saustinfcui 239444fa1c0Saustinfcuidep = [ gtest_dep ] 240444fa1c0Saustinfcui 241444fa1c0Saustinfcuivar = [ ] 242444fa1c0Saustinfcui 243444fa1c0Saustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 244*985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 245*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 246444fa1c0Saustinfcui 247444fa1c0Saustinfcuitest(tc, exe, env: var) 248bb742807Saustinfcui 249bb742807Saustinfcui################################################################################ 250bb742807Saustinfcui 251bb742807Saustinfcuitc = 'test-attention' 252bb742807Saustinfcui 253bb742807Saustinfcuisrc = [ 254bb742807Saustinfcui files( 255bb742807Saustinfcui tc + '.cpp', 256bb742807Saustinfcui ), 257bb742807Saustinfcui pdbg_test_dtb, 258bb742807Saustinfcui] 259bb742807Saustinfcui 260bb742807Saustinfcuidep = [ gtest_dep ] 261bb742807Saustinfcui 262bb742807Saustinfcuivar = [ pdbg_env ] 263bb742807Saustinfcui 264bb742807Saustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 265*985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 266*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 267bb742807Saustinfcui 268bb742807Saustinfcuitest(tc, exe, env: var) 269ab1e4ddaSaustinfcui 270ab1e4ddaSaustinfcui################################################################################ 271ab1e4ddaSaustinfcui 272ab1e4ddaSaustinfcuitc = 'test-util-data-file' 273ab1e4ddaSaustinfcui 274ab1e4ddaSaustinfcuisrc = [ 275ab1e4ddaSaustinfcui files( 276ab1e4ddaSaustinfcui tc + '.cpp', 277ab1e4ddaSaustinfcui ), 278ab1e4ddaSaustinfcui] 279ab1e4ddaSaustinfcui 280ab1e4ddaSaustinfcuidep = [ gtest_dep ] 281ab1e4ddaSaustinfcui 282ab1e4ddaSaustinfcuivar = [ ] 283ab1e4ddaSaustinfcui 284ab1e4ddaSaustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 285*985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 286*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 287ab1e4ddaSaustinfcui 288ab1e4ddaSaustinfcuitest(tc, exe, env: var) 289edfcbc38SZane Shelley 290edfcbc38SZane Shelley################################################################################ 291edfcbc38SZane Shelley 292edfcbc38SZane Shelleytc = 'test-end2end' 293edfcbc38SZane Shelley 294edfcbc38SZane Shelleysrc = [ 295edfcbc38SZane Shelley files( 296edfcbc38SZane Shelley tc + '.cpp', 297edfcbc38SZane Shelley '../cli.cpp', 298edfcbc38SZane Shelley ), 299edfcbc38SZane Shelley pdbg_test_dtb, 300edfcbc38SZane Shelley] 301edfcbc38SZane Shelley 302edfcbc38SZane Shelleydep = [ gtest_dep ] 303edfcbc38SZane Shelley 304edfcbc38SZane Shelleyvar = [ pdbg_env ] 305edfcbc38SZane Shelley 306edfcbc38SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 307*985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 308*985388a8SZane Shelley cpp_args: test_args, include_directories: incdir) 309edfcbc38SZane Shelley 310edfcbc38SZane Shelleytest(tc, exe, env: var) 311edfcbc38SZane Shelley 312