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