Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 1 | # Get the gtest/gmock dependencies. |
| 2 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 3 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 4 | if 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 |
Patrick Williams | 7619ab7 | 2023-11-29 06:44:58 -0600 | [diff] [blame] | 18 | assert(not get_option('tests').allowed(), |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 19 | 'Googletest is required if tests are enabled') |
| 20 | endif |
| 21 | endif |
| 22 | |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 23 | ################################################################################ |
| 24 | |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 25 | # Compile the test dts into a binary for pdbg. |
| 26 | pdbg_test_dtb = custom_target('build_pdbg_test_dtb', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 27 | input : files('pdbg-test.dts'), |
| 28 | output : 'pdbg-test.dtb', |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 29 | command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', |
| 30 | '-o', '@OUTPUT@', '@INPUT@' ]) |
| 31 | |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 32 | pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() |
| 33 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 34 | ################################################################################ |
| 35 | |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 36 | # Add gtest/gmock dependency to the list of test dependencies. |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame] | 37 | test_deps = [ |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 38 | test_util_deps, |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame] | 39 | gtest_dep, |
| 40 | ] |
| 41 | |
| 42 | test_vars = [ |
| 43 | pdbg_env, |
Zane Shelley | 20ed74d | 2022-03-26 13:50:57 -0500 | [diff] [blame] | 44 | 'LG2_FORCE_STDERR=true', |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame] | 45 | ] |
| 46 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 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. |
| 49 | test_additional_srcs = [ |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 50 | files( |
Caleb Palmer | 1a4f0e7 | 2022-11-07 15:08:01 -0600 | [diff] [blame] | 51 | '../analyzer/filter-root-cause.cpp', |
Zane Shelley | c62813d | 2023-08-22 16:52:19 -0500 | [diff] [blame] | 52 | '../analyzer/plugins/ody-plugins.cpp', |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 53 | '../analyzer/plugins/p10-plugins.cpp', |
| 54 | '../analyzer/plugins/p10-tod-plugins.cpp', |
| 55 | '../cli.cpp', |
| 56 | ), |
| 57 | pdbg_test_dtb |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 58 | ] |
| 59 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 60 | ################################################################################ |
| 61 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 62 | testcases = [ |
| 63 | 'test-bin-stream', |
| 64 | 'test-ffdc-file', |
| 65 | 'test-lpc-timeout', |
| 66 | 'test-pdbg-dts', |
| 67 | 'test-pll-unlock', |
| 68 | 'test-resolution', |
Caleb Palmer | 1a4f0e7 | 2022-11-07 15:08:01 -0600 | [diff] [blame] | 69 | 'test-root-cause-filter', |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 70 | 'test-tod-step-check-fault', |
austinfcui | d28d5f8 | 2022-04-28 16:20:39 -0500 | [diff] [blame] | 71 | 'test-cli', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 72 | ] |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 73 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 74 | foreach tc : testcases |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 75 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 76 | exe = executable(tc.underscorify(), |
| 77 | sources : [ files(tc + '.cpp'), test_additional_srcs ], |
| 78 | include_directories : incdir, |
| 79 | dependencies : test_deps, |
| 80 | cpp_args : test_args, |
| 81 | link_with : test_libs, |
| 82 | ) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 83 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 84 | test(tc, exe, env: test_vars) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 85 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 86 | endforeach |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 87 | |
| 88 | ################################################################################ |
| 89 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 90 | testcases = [ |
| 91 | 'test-attention', |
| 92 | 'test-end2end', |
| 93 | 'test-util-data-file', |
| 94 | 'test-ti-handler', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 95 | ] |
| 96 | |
Ben Tyner | 3a80c98 | 2022-10-21 12:49:41 -0500 | [diff] [blame] | 97 | # allow more time for long running tests |
| 98 | longtests = { |
| 99 | 'test-end2end': 2, |
| 100 | } |
| 101 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 102 | foreach tc : testcases |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 103 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 104 | exe = executable(tc.underscorify(), |
| 105 | sources : [ files(tc + '.cpp'), test_additional_srcs ], |
| 106 | include_directories : incdir, |
| 107 | dependencies : test_deps, |
| 108 | cpp_args : test_args, |
| 109 | link_with : hwdiags_libs, # TODO: should use test_libs instead |
| 110 | ) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 111 | |
Ben Tyner | 3a80c98 | 2022-10-21 12:49:41 -0500 | [diff] [blame] | 112 | test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 113 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 114 | endforeach |
Zane Shelley | edfcbc3 | 2022-03-24 15:56:52 -0500 | [diff] [blame] | 115 | |