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 |
| 18 | assert(not get_option('tests').enabled(), |
| 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 | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 25 | # NOTE: We cannot link to `util_lib` because that is built without |
| 26 | # `-DTEST_TRACE` and any of the util functions that use `trace.hpp` will |
| 27 | # throw a linker error because we don't have access to phosphor-logging |
| 28 | # in test ... yet. |
| 29 | |
Zane Shelley | 0c44c2f | 2020-06-05 17:14:31 -0500 | [diff] [blame] | 30 | test_arg = [ |
| 31 | '-DTEST_TRACE', |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 32 | package_args, |
Zane Shelley | 0c44c2f | 2020-06-05 17:14:31 -0500 | [diff] [blame] | 33 | ] |
| 34 | |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 35 | # Compile the test dts into a binary for pdbg. |
| 36 | pdbg_test_dtb = custom_target('build_pdbg_test_dtb', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 37 | input : files('pdbg-test.dts'), |
| 38 | output : 'pdbg-test.dtb', |
Zane Shelley | afc6acd | 2022-01-12 14:32:56 -0600 | [diff] [blame] | 39 | command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', |
| 40 | '-o', '@OUTPUT@', '@INPUT@' ]) |
| 41 | |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 42 | pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() |
| 43 | |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 44 | # end2end code exerciser for experiment and testing |
| 45 | subdir('end2end') |
| 46 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 47 | ################################################################################ |
| 48 | |
| 49 | tc = 'test-bin-stream' |
| 50 | |
| 51 | src = [ |
| 52 | files( |
| 53 | tc + '.cpp', |
| 54 | ), |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 55 | ] |
| 56 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 57 | dep = [ gtest_dep ] |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 58 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 59 | var = [ ] |
| 60 | |
| 61 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 62 | cpp_args: test_arg, include_directories: incdir) |
| 63 | |
| 64 | test(tc, exe, env: var) |
| 65 | |
| 66 | ################################################################################ |
| 67 | |
| 68 | tc = 'test-ffdc-file' |
| 69 | |
| 70 | src = [ |
| 71 | files( |
| 72 | tc + '.cpp', |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 73 | '../util/ffdc_file.cpp', |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 74 | '../util/temporary_file.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 75 | ), |
| 76 | ] |
Zane Shelley | 979e287 | 2021-09-20 22:46:06 -0500 | [diff] [blame] | 77 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 78 | dep = [ gtest_dep ] |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 79 | |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 80 | var = [ ] |
| 81 | |
| 82 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 83 | cpp_args: test_arg, include_directories: incdir) |
| 84 | |
| 85 | test(tc, exe, env: var) |
| 86 | |
| 87 | ################################################################################ |
| 88 | |
| 89 | tc = 'test-lpc-timeout' |
| 90 | |
| 91 | src = [ |
| 92 | files( |
| 93 | tc + '.cpp', |
| 94 | '../analyzer/plugins/p10-plugins.cpp', |
| 95 | '../analyzer/service_data.cpp', |
| 96 | '../util/pdbg.cpp', |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 97 | 'dbus-sim-only.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 98 | 'pdbg-sim-only.cpp', |
| 99 | ), |
| 100 | pdbg_test_dtb, |
| 101 | ] |
| 102 | |
| 103 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 104 | |
| 105 | var = [ pdbg_env ] |
| 106 | |
| 107 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 108 | cpp_args: test_arg, include_directories: incdir) |
| 109 | |
| 110 | test(tc, exe, env: var) |
| 111 | |
| 112 | ################################################################################ |
| 113 | |
| 114 | tc = 'test-pdbg-dts' |
| 115 | |
| 116 | src = [ |
| 117 | files( |
| 118 | tc + '.cpp', |
| 119 | '../util/pdbg.cpp', |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 120 | 'dbus-sim-only.cpp', |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 121 | 'pdbg-sim-only.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 122 | ), |
| 123 | pdbg_test_dtb, |
| 124 | ] |
| 125 | |
| 126 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 127 | |
| 128 | var = [ pdbg_env ] |
| 129 | |
| 130 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 131 | cpp_args: test_arg, include_directories: incdir) |
| 132 | |
| 133 | test(tc, exe, env: var) |
| 134 | |
| 135 | ################################################################################ |
| 136 | |
| 137 | tc = 'test-pll-unlock' |
| 138 | |
| 139 | src = [ |
| 140 | files( |
| 141 | tc + '.cpp', |
| 142 | '../analyzer/plugins/p10-plugins.cpp', |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 143 | '../analyzer/ras-data/ras-data-parser.cpp', |
| 144 | '../analyzer/resolution.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 145 | '../analyzer/service_data.cpp', |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 146 | '../util/data_file.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 147 | '../util/pdbg.cpp', |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 148 | 'dbus-sim-only.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 149 | 'pdbg-sim-only.cpp', |
| 150 | ), |
| 151 | pdbg_test_dtb, |
| 152 | ] |
| 153 | |
| 154 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 155 | |
| 156 | var = [ pdbg_env ] |
| 157 | |
| 158 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 159 | cpp_args: test_arg, include_directories: incdir) |
| 160 | |
| 161 | test(tc, exe, env: var) |
| 162 | |
| 163 | ################################################################################ |
| 164 | |
| 165 | tc = 'test-resolution' |
| 166 | |
| 167 | src = [ |
| 168 | files( |
| 169 | tc + '.cpp', |
| 170 | '../analyzer/resolution.cpp', |
| 171 | '../analyzer/service_data.cpp', |
| 172 | '../util/pdbg.cpp', |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 173 | 'dbus-sim-only.cpp', |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 174 | 'pdbg-sim-only.cpp', |
Zane Shelley | 08c21c2 | 2022-01-26 16:58:18 -0600 | [diff] [blame] | 175 | ), |
| 176 | pdbg_test_dtb, |
| 177 | ] |
| 178 | |
| 179 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 180 | |
| 181 | var = [ pdbg_env ] |
| 182 | |
| 183 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 184 | cpp_args: test_arg, include_directories: incdir) |
| 185 | |
| 186 | test(tc, exe, env: var) |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 187 | |
| 188 | ################################################################################ |
| 189 | |
| 190 | tc = 'test-tod-step-check-fault' |
| 191 | |
| 192 | src = [ |
| 193 | files( |
| 194 | tc + '.cpp', |
| 195 | '../analyzer/plugins/p10-tod-plugins.cpp', |
| 196 | '../analyzer/service_data.cpp', |
| 197 | '../util/pdbg.cpp', |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 198 | 'dbus-sim-only.cpp', |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 199 | 'pdbg-sim-only.cpp', |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 200 | ), |
| 201 | pdbg_test_dtb, |
| 202 | ] |
| 203 | |
| 204 | dep = [ libhei_dep, libpdbg_dep, gtest_dep ] |
| 205 | |
| 206 | var = [ pdbg_env ] |
| 207 | |
| 208 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 209 | cpp_args: test_arg, include_directories: incdir) |
| 210 | |
| 211 | test(tc, exe, env: var) |
| 212 | |
austinfcui | 444fa1c | 2022-02-08 10:20:37 -0600 | [diff] [blame] | 213 | ################################################################################ |
| 214 | |
| 215 | tc = 'test-ti-handler' |
| 216 | |
| 217 | src = [ |
| 218 | files( |
| 219 | tc + '.cpp', |
| 220 | ), |
| 221 | ] |
| 222 | |
| 223 | dep = [ gtest_dep ] |
| 224 | |
| 225 | var = [ ] |
| 226 | |
| 227 | exe = executable(tc.underscorify(), src, dependencies: dep, |
| 228 | link_with : hwdiags_libs, |
| 229 | cpp_args: test_arg, include_directories: incdir) |
| 230 | |
| 231 | test(tc, exe, env: var) |