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 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( 51*1a4f0e70SCaleb Palmer '../analyzer/filter-root-cause.cpp', 522c228cdcSZane Shelley '../analyzer/plugins/p10-plugins.cpp', 53d195b716SZane Shelley '../analyzer/plugins/p10-tod-plugins.cpp', 54edfcbc38SZane Shelley '../cli.cpp', 555dbebde0Saustinfcui ), 565dbebde0Saustinfcui pdbg_test_dtb 57edfcbc38SZane Shelley] 58edfcbc38SZane Shelley 5969e3771fSZane Shelley################################################################################ 60edfcbc38SZane Shelley 6169e3771fSZane Shelleytestcases = [ 6269e3771fSZane Shelley 'test-bin-stream', 6369e3771fSZane Shelley 'test-ffdc-file', 6469e3771fSZane Shelley 'test-lpc-timeout', 6569e3771fSZane Shelley 'test-pdbg-dts', 6669e3771fSZane Shelley 'test-pll-unlock', 6769e3771fSZane Shelley 'test-resolution', 68*1a4f0e70SCaleb Palmer 'test-root-cause-filter', 6969e3771fSZane Shelley 'test-tod-step-check-fault', 70d28d5f8bSaustinfcui 'test-cli', 7169e3771fSZane Shelley] 72edfcbc38SZane Shelley 7369e3771fSZane Shelleyforeach tc : testcases 7469e3771fSZane Shelley 7569e3771fSZane Shelley exe = executable(tc.underscorify(), 7669e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 7769e3771fSZane Shelley include_directories : incdir, 7869e3771fSZane Shelley dependencies : test_deps, 7969e3771fSZane Shelley cpp_args : test_args, 8069e3771fSZane Shelley link_with : test_libs, 8169e3771fSZane Shelley ) 8269e3771fSZane Shelley 8369e3771fSZane Shelley test(tc, exe, env: test_vars) 8469e3771fSZane Shelley 8569e3771fSZane Shelleyendforeach 8669e3771fSZane Shelley 8769e3771fSZane Shelley################################################################################ 8869e3771fSZane Shelley 8969e3771fSZane Shelleytestcases = [ 9069e3771fSZane Shelley 'test-attention', 9169e3771fSZane Shelley 'test-end2end', 9269e3771fSZane Shelley 'test-util-data-file', 9369e3771fSZane Shelley 'test-ti-handler', 9469e3771fSZane Shelley] 9569e3771fSZane Shelley 963a80c983SBen Tyner# allow more time for long running tests 973a80c983SBen Tynerlongtests = { 983a80c983SBen Tyner 'test-end2end': 2, 993a80c983SBen Tyner} 1003a80c983SBen Tyner 10169e3771fSZane Shelleyforeach tc : testcases 10269e3771fSZane Shelley 10369e3771fSZane Shelley exe = executable(tc.underscorify(), 10469e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 10569e3771fSZane Shelley include_directories : incdir, 10669e3771fSZane Shelley dependencies : test_deps, 10769e3771fSZane Shelley cpp_args : test_args, 108985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 10969e3771fSZane Shelley ) 110edfcbc38SZane Shelley 1113a80c983SBen Tyner test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 11269e3771fSZane Shelley 11369e3771fSZane Shelleyendforeach 114edfcbc38SZane Shelley 115