1# Get the gtest/gmock dependencies. 2gtest_dep = dependency('gtest', main: true, disabler: true, required: false) 3gmock_dep = dependency('gmock', disabler: true, required: false) 4if not gtest_dep.found() or not gmock_dep.found() 5 cmake = import('cmake') 6 gtest_proj = cmake.subproject('googletest', 7 required: false) 8 if gtest_proj.found() 9 gtest_dep = declare_dependency( 10 dependencies: [ 11 dependency('threads'), 12 gtest_proj.dependency('gtest'), 13 gtest_proj.dependency('gtest_main'), 14 ] 15 ) 16 gmock_dep = gtest_proj.dependency('gmock') 17 else 18 assert(not get_option('tests').allowed(), 19 'Googletest is required if tests are enabled') 20 endif 21endif 22 23################################################################################ 24 25# Compile the test dts into a binary for pdbg. 26pdbg_test_dtb = custom_target('build_pdbg_test_dtb', 27 input : files('pdbg-test.dts'), 28 output : 'pdbg-test.dtb', 29 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', 30 '-o', '@OUTPUT@', '@INPUT@' ]) 31 32pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() 33 34################################################################################ 35 36# Add gtest/gmock dependency to the list of test dependencies. 37test_deps = [ 38 test_util_deps, 39 gtest_dep, 40] 41 42test_vars = [ 43 pdbg_env, 44 'LG2_FORCE_STDERR=true', 45] 46 47# Additional SRCs that are not (or should not be) included in libraries. 48# NOTE: Try to limit this, if possible, to prevent duplicate compilation. 49test_additional_srcs = [ 50 files( 51 '../analyzer/filter-root-cause.cpp', 52 '../analyzer/plugins/ody-plugins.cpp', 53 '../analyzer/plugins/p10-plugins.cpp', 54 '../analyzer/plugins/p10-tod-plugins.cpp', 55 '../cli.cpp', 56 ), 57 pdbg_test_dtb 58] 59 60################################################################################ 61 62testcases = [ 63 'test-bin-stream', 64 'test-ffdc-file', 65 'test-lpc-timeout', 66 'test-pdbg-dts', 67 'test-pll-unlock', 68 'test-resolution', 69 'test-root-cause-filter', 70 'test-tod-step-check-fault', 71 'test-cli', 72] 73 74# allow more time for long running tests 75longtests = { 76 'test-pll-unlock': 2, 77} 78 79foreach tc : testcases 80 81 exe = executable(tc.underscorify(), 82 sources : [ files(tc + '.cpp'), test_additional_srcs ], 83 include_directories : incdir, 84 dependencies : test_deps, 85 cpp_args : test_args, 86 link_with : test_libs, 87 ) 88 89 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 90 91endforeach 92 93################################################################################ 94 95testcases = [ 96 'test-attention', 97 'test-end2end', 98 'test-util-data-file', 99 'test-ti-handler', 100] 101 102# allow more time for long running tests 103longtests = { 104 'test-end2end': 2, 105} 106 107foreach tc : testcases 108 109 exe = executable(tc.underscorify(), 110 sources : [ files(tc + '.cpp'), test_additional_srcs ], 111 include_directories : incdir, 112 dependencies : test_deps, 113 cpp_args : test_args, 114 link_with : hwdiags_libs, # TODO: should use test_libs instead 115 ) 116 117 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 118 119endforeach 120 121