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( 512c228cdcSZane Shelley '../analyzer/plugins/p10-plugins.cpp', 52d195b716SZane Shelley '../analyzer/plugins/p10-tod-plugins.cpp', 53edfcbc38SZane Shelley '../cli.cpp', 545dbebde0Saustinfcui ), 555dbebde0Saustinfcui pdbg_test_dtb 56edfcbc38SZane Shelley] 57edfcbc38SZane Shelley 5869e3771fSZane Shelley################################################################################ 59edfcbc38SZane Shelley 6069e3771fSZane Shelleytestcases = [ 6169e3771fSZane Shelley 'test-bin-stream', 6269e3771fSZane Shelley 'test-ffdc-file', 6369e3771fSZane Shelley 'test-lpc-timeout', 6469e3771fSZane Shelley 'test-pdbg-dts', 6569e3771fSZane Shelley 'test-pll-unlock', 6669e3771fSZane Shelley 'test-resolution', 6769e3771fSZane Shelley 'test-tod-step-check-fault', 68d28d5f8bSaustinfcui 'test-cli', 6969e3771fSZane Shelley] 70edfcbc38SZane Shelley 7169e3771fSZane Shelleyforeach tc : testcases 7269e3771fSZane Shelley 7369e3771fSZane Shelley exe = executable(tc.underscorify(), 7469e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 7569e3771fSZane Shelley include_directories : incdir, 7669e3771fSZane Shelley dependencies : test_deps, 7769e3771fSZane Shelley cpp_args : test_args, 7869e3771fSZane Shelley link_with : test_libs, 7969e3771fSZane Shelley ) 8069e3771fSZane Shelley 8169e3771fSZane Shelley test(tc, exe, env: test_vars) 8269e3771fSZane Shelley 8369e3771fSZane Shelleyendforeach 8469e3771fSZane Shelley 8569e3771fSZane Shelley################################################################################ 8669e3771fSZane Shelley 8769e3771fSZane Shelleytestcases = [ 8869e3771fSZane Shelley 'test-attention', 8969e3771fSZane Shelley 'test-end2end', 9069e3771fSZane Shelley 'test-util-data-file', 9169e3771fSZane Shelley 'test-ti-handler', 9269e3771fSZane Shelley] 9369e3771fSZane Shelley 94*3a80c983SBen Tyner# allow more time for long running tests 95*3a80c983SBen Tynerlongtests = { 96*3a80c983SBen Tyner 'test-end2end': 2, 97*3a80c983SBen Tyner} 98*3a80c983SBen Tyner 9969e3771fSZane Shelleyforeach tc : testcases 10069e3771fSZane Shelley 10169e3771fSZane Shelley exe = executable(tc.underscorify(), 10269e3771fSZane Shelley sources : [ files(tc + '.cpp'), test_additional_srcs ], 10369e3771fSZane Shelley include_directories : incdir, 10469e3771fSZane Shelley dependencies : test_deps, 10569e3771fSZane Shelley cpp_args : test_args, 106985388a8SZane Shelley link_with : hwdiags_libs, # TODO: should use test_libs instead 10769e3771fSZane Shelley ) 108edfcbc38SZane Shelley 109*3a80c983SBen Tyner test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 11069e3771fSZane Shelley 11169e3771fSZane Shelleyendforeach 112edfcbc38SZane Shelley 113