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 'test-chnl-timeout', 78] 79 80# allow more time for long running tests 81longtests = {'test-pll-unlock': 2, 'test-chnl-timeout': 2} 82 83foreach tc : testcases 84 85 exe = executable( 86 tc.underscorify(), 87 sources: [files(tc + '.cpp'), test_additional_srcs], 88 include_directories: incdir, 89 dependencies: test_deps, 90 cpp_args: test_args, 91 link_with: test_libs, 92 ) 93 94 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 95 96endforeach 97 98################################################################################ 99 100testcases = [ 101 'test-attention', 102 'test-end2end', 103 'test-util-data-file', 104 'test-ti-handler', 105] 106 107# allow more time for long running tests 108longtests = {'test-end2end': 2} 109 110foreach tc : testcases 111 112 exe = executable( 113 tc.underscorify(), 114 sources: [files(tc + '.cpp'), test_additional_srcs], 115 include_directories: incdir, 116 dependencies: test_deps, 117 cpp_args: test_args, 118 link_with: hwdiags_libs, # TODO: should use test_libs instead 119 ) 120 121 test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) 122 123endforeach 124 125