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 187619ab78SPatrick Williams assert(not get_option('tests').allowed(), 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 365dbebde0Saustinfcui# Add gtest/gmock dependency to the list of test dependencies. 37985388a8SZane Shelleytest_deps = [ 385dbebde0Saustinfcui test_util_deps, 39985388a8SZane Shelley gtest_dep, 40985388a8SZane Shelley] 41985388a8SZane Shelley 42985388a8SZane Shelleytest_vars = [ 43985388a8SZane Shelley pdbg_env, 4420ed74dbSZane Shelley 'LG2_FORCE_STDERR=true', 45985388a8SZane Shelley] 46985388a8SZane Shelley 4769e3771fSZane Shelley# Additional SRCs that are not (or should not be) included in libraries. 4869e3771fSZane Shelley# NOTE: Try to limit this, if possible, to prevent duplicate compilation. 4969e3771fSZane Shelleytest_additional_srcs = [ 505dbebde0Saustinfcui files( 511a4f0e70SCaleb Palmer '../analyzer/filter-root-cause.cpp', 52c62813d4SZane Shelley '../analyzer/plugins/ody-plugins.cpp', 532c228cdcSZane Shelley '../analyzer/plugins/p10-plugins.cpp', 54d195b716SZane Shelley '../analyzer/plugins/p10-tod-plugins.cpp', 55edfcbc38SZane Shelley '../cli.cpp', 565dbebde0Saustinfcui ), 575dbebde0Saustinfcui pdbg_test_dtb 58edfcbc38SZane Shelley] 59edfcbc38SZane Shelley 6069e3771fSZane Shelley################################################################################ 61edfcbc38SZane Shelley 6269e3771fSZane Shelleytestcases = [ 6369e3771fSZane Shelley 'test-bin-stream', 6469e3771fSZane Shelley 'test-ffdc-file', 6569e3771fSZane Shelley 'test-lpc-timeout', 6669e3771fSZane Shelley 'test-pdbg-dts', 6769e3771fSZane Shelley 'test-pll-unlock', 6869e3771fSZane Shelley 'test-resolution', 691a4f0e70SCaleb Palmer 'test-root-cause-filter', 7069e3771fSZane Shelley 'test-tod-step-check-fault', 71d28d5f8bSaustinfcui 'test-cli', 7269e3771fSZane Shelley] 73edfcbc38SZane Shelley 74*b1ef8c42SCaleb Palmer# allow more time for long running tests 75*b1ef8c42SCaleb Palmerlongtests = { 76*b1ef8c42SCaleb Palmer 'test-pll-unlock': 2, 77*b1ef8c42SCaleb Palmer} 78*b1ef8c42SCaleb Palmer 7969e3771fSZane Shelleyforeach tc : testcases 8069e3771fSZane Shelley 8169e3771fSZane Shelley exe = executable(tc.underscorify(), 8269e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 8369e3771fSZane Shelley include_directories : incdir, 8469e3771fSZane Shelley dependencies : test_deps, 8569e3771fSZane Shelley cpp_args : test_args, 8669e3771fSZane Shelley link_with : test_libs, 8769e3771fSZane Shelley ) 8869e3771fSZane Shelley 89*b1ef8c42SCaleb Palmer test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 9069e3771fSZane Shelley 9169e3771fSZane Shelleyendforeach 9269e3771fSZane Shelley 9369e3771fSZane Shelley################################################################################ 9469e3771fSZane Shelley 9569e3771fSZane Shelleytestcases = [ 9669e3771fSZane Shelley 'test-attention', 9769e3771fSZane Shelley 'test-end2end', 9869e3771fSZane Shelley 'test-util-data-file', 9969e3771fSZane Shelley 'test-ti-handler', 10069e3771fSZane Shelley] 10169e3771fSZane Shelley 1023a80c983SBen Tyner# allow more time for long running tests 1033a80c983SBen Tynerlongtests = { 1043a80c983SBen Tyner 'test-end2end': 2, 1053a80c983SBen Tyner} 1063a80c983SBen Tyner 10769e3771fSZane Shelleyforeach tc : testcases 10869e3771fSZane Shelley 10969e3771fSZane Shelley exe = executable(tc.underscorify(), 11069e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 11169e3771fSZane Shelley include_directories : incdir, 11269e3771fSZane Shelley dependencies : test_deps, 11369e3771fSZane Shelley cpp_args : test_args, 114985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 11569e3771fSZane Shelley ) 116edfcbc38SZane Shelley 1173a80c983SBen Tyner test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 11869e3771fSZane Shelley 11969e3771fSZane Shelleyendforeach 120edfcbc38SZane Shelley 121