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') |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 6 | gtest_proj = cmake.subproject('googletest', required: false) |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 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'), |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 13 | ], |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 14 | ) |
| 15 | gmock_dep = gtest_proj.dependency('gmock') |
| 16 | else |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 17 | assert( |
| 18 | not get_option('tests').allowed(), |
| 19 | 'Googletest is required if tests are enabled', |
| 20 | ) |
Zane Shelley | 8018391 | 2021-12-21 11:52:25 -0600 | [diff] [blame] | 21 | endif |
| 22 | endif |
| 23 | |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 24 | ################################################################################ |
| 25 | |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 26 | # Compile the test dts into a binary for pdbg. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 27 | pdbg_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 | ) |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 42 | |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 43 | pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() |
| 44 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 45 | ################################################################################ |
| 46 | |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 47 | # Add gtest/gmock dependency to the list of test dependencies. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 48 | test_deps = [test_util_deps, gtest_dep] |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame] | 49 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 50 | test_vars = [pdbg_env, 'LG2_FORCE_STDERR=true'] |
Zane Shelley | 985388a | 2022-03-24 16:35:46 -0500 | [diff] [blame] | 51 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 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. |
| 54 | test_additional_srcs = [ |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 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, |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 63 | ] |
| 64 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 65 | ################################################################################ |
| 66 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 67 | testcases = [ |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 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', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 77 | ] |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 78 | |
Caleb Palmer | b1ef8c4 | 2024-04-04 12:07:16 -0500 | [diff] [blame] | 79 | # allow more time for long running tests |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 80 | longtests = {'test-pll-unlock': 2} |
Caleb Palmer | b1ef8c4 | 2024-04-04 12:07:16 -0500 | [diff] [blame] | 81 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 82 | foreach tc : testcases |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 83 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 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 | ) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 92 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 93 | test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 94 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 95 | endforeach |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 96 | |
| 97 | ################################################################################ |
| 98 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 99 | testcases = [ |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 100 | 'test-attention', |
| 101 | 'test-end2end', |
| 102 | 'test-util-data-file', |
| 103 | 'test-ti-handler', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 104 | ] |
| 105 | |
Ben Tyner | 3a80c98 | 2022-10-21 12:49:41 -0500 | [diff] [blame] | 106 | # allow more time for long running tests |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 107 | longtests = {'test-end2end': 2} |
Ben Tyner | 3a80c98 | 2022-10-21 12:49:41 -0500 | [diff] [blame] | 108 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 109 | foreach tc : testcases |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 110 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 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 | ) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 119 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame^] | 120 | test(tc, exe, env: test_vars, timeout: 30 * longtests.get(tc, 1)) |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 121 | |
Zane Shelley | 69e3771 | 2022-03-24 16:43:03 -0500 | [diff] [blame] | 122 | endforeach |
Zane Shelley | edfcbc3 | 2022-03-24 15:56:52 -0500 | [diff] [blame] | 123 | |