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