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 2508c21c25SZane Shelley# NOTE: We cannot link to `util_lib` because that is built without 2608c21c25SZane Shelley# `-DTEST_TRACE` and any of the util functions that use `trace.hpp` will 2708c21c25SZane Shelley# throw a linker error because we don't have access to phosphor-logging 2808c21c25SZane Shelley# in test ... yet. 2908c21c25SZane Shelley 300c44c2feSZane Shelleytest_arg = [ 310c44c2feSZane Shelley '-DTEST_TRACE', 329491cdb4SZane Shelley package_args, 330c44c2feSZane Shelley] 340c44c2feSZane Shelley 35afc6acdaSZane Shelley# Compile the test dts into a binary for pdbg. 36afc6acdaSZane Shelleypdbg_test_dtb = custom_target('build_pdbg_test_dtb', 3708c21c25SZane Shelley input : files('pdbg-test.dts'), 3808c21c25SZane Shelley output : 'pdbg-test.dtb', 39afc6acdaSZane Shelley command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', 40afc6acdaSZane Shelley '-o', '@OUTPUT@', '@INPUT@' ]) 41afc6acdaSZane Shelley 42d195b716SZane Shelleypdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() 43d195b716SZane Shelley 4408c21c25SZane Shelley################################################################################ 4508c21c25SZane Shelley 4608c21c25SZane Shelleytc = 'test-bin-stream' 4708c21c25SZane Shelley 4808c21c25SZane Shelleysrc = [ 4908c21c25SZane Shelley files( 5008c21c25SZane Shelley tc + '.cpp', 5108c21c25SZane Shelley ), 52248cbf83SZane Shelley] 53248cbf83SZane Shelley 5408c21c25SZane Shelleydep = [ gtest_dep ] 5508c21c25SZane Shelley 5608c21c25SZane Shelleyvar = [ ] 5708c21c25SZane Shelley 5808c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 5908c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 6008c21c25SZane Shelley 6108c21c25SZane Shelleytest(tc, exe, env: var) 6208c21c25SZane Shelley 6308c21c25SZane Shelley################################################################################ 6408c21c25SZane Shelley 6508c21c25SZane Shelleytc = 'test-ffdc-file' 6608c21c25SZane Shelley 6708c21c25SZane Shelleysrc = [ 6808c21c25SZane Shelley files( 6908c21c25SZane Shelley tc + '.cpp', 7008c21c25SZane Shelley '../util/ffdc_file.cpp', 7108c21c25SZane Shelley '../util/temporary_file.cpp', 7208c21c25SZane Shelley ), 7308c21c25SZane Shelley] 7408c21c25SZane Shelley 7508c21c25SZane Shelleydep = [ gtest_dep ] 7608c21c25SZane Shelley 7708c21c25SZane Shelleyvar = [ ] 7808c21c25SZane Shelley 7908c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 8008c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 8108c21c25SZane Shelley 8208c21c25SZane Shelleytest(tc, exe, env: var) 8308c21c25SZane Shelley 8408c21c25SZane Shelley################################################################################ 8508c21c25SZane Shelley 8608c21c25SZane Shelleytc = 'test-lpc-timeout' 8708c21c25SZane Shelley 8808c21c25SZane Shelleysrc = [ 8908c21c25SZane Shelley files( 9008c21c25SZane Shelley tc + '.cpp', 912c228cdcSZane Shelley '../analyzer/plugins/p10-plugins.cpp', 92979e2871SZane Shelley '../analyzer/service_data.cpp', 93cb766a45SZane Shelley '../util/pdbg.cpp', 94626270afSCaleb Palmer 'dbus-sim-only.cpp', 95e90b85dcSZane Shelley 'pdbg-sim-only.cpp', 9608c21c25SZane Shelley ), 9708c21c25SZane Shelley pdbg_test_dtb, 9808c21c25SZane Shelley] 99e90b85dcSZane Shelley 10008c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 10108c21c25SZane Shelley 10208c21c25SZane Shelleyvar = [ pdbg_env ] 10308c21c25SZane Shelley 10408c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 10508c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 10608c21c25SZane Shelley 10708c21c25SZane Shelleytest(tc, exe, env: var) 10808c21c25SZane Shelley 10908c21c25SZane Shelley################################################################################ 11008c21c25SZane Shelley 11108c21c25SZane Shelleytc = 'test-pdbg-dts' 11208c21c25SZane Shelley 11308c21c25SZane Shelleysrc = [ 11408c21c25SZane Shelley files( 11508c21c25SZane Shelley tc + '.cpp', 11608c21c25SZane Shelley '../util/pdbg.cpp', 117626270afSCaleb Palmer 'dbus-sim-only.cpp', 118c7026261SZane Shelley 'pdbg-sim-only.cpp', 11908c21c25SZane Shelley ), 12008c21c25SZane Shelley pdbg_test_dtb, 12108c21c25SZane Shelley] 12208c21c25SZane Shelley 12308c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 12408c21c25SZane Shelley 12508c21c25SZane Shelleyvar = [ pdbg_env ] 12608c21c25SZane Shelley 12708c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 12808c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 12908c21c25SZane Shelley 13008c21c25SZane Shelleytest(tc, exe, env: var) 13108c21c25SZane Shelley 13208c21c25SZane Shelley################################################################################ 13308c21c25SZane Shelley 13408c21c25SZane Shelleytc = 'test-pll-unlock' 13508c21c25SZane Shelley 13608c21c25SZane Shelleysrc = [ 13708c21c25SZane Shelley files( 13808c21c25SZane Shelley tc + '.cpp', 13908c21c25SZane Shelley '../analyzer/plugins/p10-plugins.cpp', 1409491cdb4SZane Shelley '../analyzer/ras-data/ras-data-parser.cpp', 1419491cdb4SZane Shelley '../analyzer/resolution.cpp', 14208c21c25SZane Shelley '../analyzer/service_data.cpp', 1439491cdb4SZane Shelley '../util/data_file.cpp', 14408c21c25SZane Shelley '../util/pdbg.cpp', 145626270afSCaleb Palmer 'dbus-sim-only.cpp', 14608c21c25SZane Shelley 'pdbg-sim-only.cpp', 14708c21c25SZane Shelley ), 14808c21c25SZane Shelley pdbg_test_dtb, 14908c21c25SZane Shelley] 15008c21c25SZane Shelley 15108c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 15208c21c25SZane Shelley 15308c21c25SZane Shelleyvar = [ pdbg_env ] 15408c21c25SZane Shelley 15508c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 15608c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 15708c21c25SZane Shelley 15808c21c25SZane Shelleytest(tc, exe, env: var) 15908c21c25SZane Shelley 16008c21c25SZane Shelley################################################################################ 16108c21c25SZane Shelley 16208c21c25SZane Shelleytc = 'test-resolution' 16308c21c25SZane Shelley 16408c21c25SZane Shelleysrc = [ 16508c21c25SZane Shelley files( 16608c21c25SZane Shelley tc + '.cpp', 16708c21c25SZane Shelley '../analyzer/resolution.cpp', 16808c21c25SZane Shelley '../analyzer/service_data.cpp', 16908c21c25SZane Shelley '../util/pdbg.cpp', 170626270afSCaleb Palmer 'dbus-sim-only.cpp', 171c7026261SZane Shelley 'pdbg-sim-only.cpp', 17208c21c25SZane Shelley ), 17308c21c25SZane Shelley pdbg_test_dtb, 17408c21c25SZane Shelley] 17508c21c25SZane Shelley 17608c21c25SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 17708c21c25SZane Shelley 17808c21c25SZane Shelleyvar = [ pdbg_env ] 17908c21c25SZane Shelley 18008c21c25SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 18108c21c25SZane Shelley cpp_args: test_arg, include_directories: incdir) 18208c21c25SZane Shelley 18308c21c25SZane Shelleytest(tc, exe, env: var) 184d195b716SZane Shelley 185d195b716SZane Shelley################################################################################ 186d195b716SZane Shelley 187d195b716SZane Shelleytc = 'test-tod-step-check-fault' 188d195b716SZane Shelley 189d195b716SZane Shelleysrc = [ 190d195b716SZane Shelley files( 191d195b716SZane Shelley tc + '.cpp', 192d195b716SZane Shelley '../analyzer/plugins/p10-tod-plugins.cpp', 193d195b716SZane Shelley '../analyzer/service_data.cpp', 194d195b716SZane Shelley '../util/pdbg.cpp', 195626270afSCaleb Palmer 'dbus-sim-only.cpp', 196c7026261SZane Shelley 'pdbg-sim-only.cpp', 197d195b716SZane Shelley ), 198d195b716SZane Shelley pdbg_test_dtb, 199d195b716SZane Shelley] 200d195b716SZane Shelley 201d195b716SZane Shelleydep = [ libhei_dep, libpdbg_dep, gtest_dep ] 202d195b716SZane Shelley 203d195b716SZane Shelleyvar = [ pdbg_env ] 204d195b716SZane Shelley 205d195b716SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 206d195b716SZane Shelley cpp_args: test_arg, include_directories: incdir) 207d195b716SZane Shelley 208d195b716SZane Shelleytest(tc, exe, env: var) 209d195b716SZane Shelley 210444fa1c0Saustinfcui################################################################################ 211444fa1c0Saustinfcui 212444fa1c0Saustinfcuitc = 'test-ti-handler' 213444fa1c0Saustinfcui 214444fa1c0Saustinfcuisrc = [ 215444fa1c0Saustinfcui files( 216444fa1c0Saustinfcui tc + '.cpp', 217444fa1c0Saustinfcui ), 218444fa1c0Saustinfcui] 219444fa1c0Saustinfcui 220444fa1c0Saustinfcuidep = [ gtest_dep ] 221444fa1c0Saustinfcui 222444fa1c0Saustinfcuivar = [ ] 223444fa1c0Saustinfcui 224444fa1c0Saustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 225444fa1c0Saustinfcui link_with : hwdiags_libs, 226444fa1c0Saustinfcui cpp_args: test_arg, include_directories: incdir) 227444fa1c0Saustinfcui 228444fa1c0Saustinfcuitest(tc, exe, env: var) 229bb742807Saustinfcui 230bb742807Saustinfcui################################################################################ 231bb742807Saustinfcui 232bb742807Saustinfcuitc = 'test-attention' 233bb742807Saustinfcui 234bb742807Saustinfcuisrc = [ 235bb742807Saustinfcui files( 236bb742807Saustinfcui tc + '.cpp', 237bb742807Saustinfcui ), 238bb742807Saustinfcui pdbg_test_dtb, 239bb742807Saustinfcui] 240bb742807Saustinfcui 241bb742807Saustinfcuidep = [ gtest_dep ] 242bb742807Saustinfcui 243bb742807Saustinfcuivar = [ pdbg_env ] 244bb742807Saustinfcui 245bb742807Saustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 246bb742807Saustinfcui link_with : hwdiags_libs, 247bb742807Saustinfcui cpp_args: test_arg, include_directories: incdir) 248bb742807Saustinfcui 249bb742807Saustinfcuitest(tc, exe, env: var) 250ab1e4ddaSaustinfcui 251ab1e4ddaSaustinfcui################################################################################ 252ab1e4ddaSaustinfcui 253ab1e4ddaSaustinfcuitc = 'test-util-data-file' 254ab1e4ddaSaustinfcui 255ab1e4ddaSaustinfcuisrc = [ 256ab1e4ddaSaustinfcui files( 257ab1e4ddaSaustinfcui tc + '.cpp', 258ab1e4ddaSaustinfcui ), 259ab1e4ddaSaustinfcui] 260ab1e4ddaSaustinfcui 261ab1e4ddaSaustinfcuidep = [ gtest_dep ] 262ab1e4ddaSaustinfcui 263ab1e4ddaSaustinfcuivar = [ ] 264ab1e4ddaSaustinfcui 265ab1e4ddaSaustinfcuiexe = executable(tc.underscorify(), src, dependencies: dep, 266ab1e4ddaSaustinfcui link_with : hwdiags_libs, 267ab1e4ddaSaustinfcui cpp_args: test_arg, include_directories: incdir) 268ab1e4ddaSaustinfcui 269ab1e4ddaSaustinfcuitest(tc, exe, env: var) 270*edfcbc38SZane Shelley 271*edfcbc38SZane Shelley################################################################################ 272*edfcbc38SZane Shelley 273*edfcbc38SZane Shelleytc = 'test-end2end' 274*edfcbc38SZane Shelley 275*edfcbc38SZane Shelleysrc = [ 276*edfcbc38SZane Shelley files( 277*edfcbc38SZane Shelley tc + '.cpp', 278*edfcbc38SZane Shelley '../cli.cpp', 279*edfcbc38SZane Shelley ), 280*edfcbc38SZane Shelley pdbg_test_dtb, 281*edfcbc38SZane Shelley] 282*edfcbc38SZane Shelley 283*edfcbc38SZane Shelleydep = [ gtest_dep ] 284*edfcbc38SZane Shelley 285*edfcbc38SZane Shelleyvar = [ pdbg_env ] 286*edfcbc38SZane Shelley 287*edfcbc38SZane Shelleyexe = executable(tc.underscorify(), src, dependencies: dep, 288*edfcbc38SZane Shelley link_with : hwdiags_libs, 289*edfcbc38SZane Shelley cpp_args: test_arg, include_directories: incdir) 290*edfcbc38SZane Shelley 291*edfcbc38SZane Shelleytest(tc, exe, env: var) 292*edfcbc38SZane Shelley 293