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', 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 21endif 22 23################################################################################ 24 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 30test_arg = [ 31 '-DTEST_TRACE', 32 package_args, 33] 34 35# Compile the test dts into a binary for pdbg. 36pdbg_test_dtb = custom_target('build_pdbg_test_dtb', 37 input : files('pdbg-test.dts'), 38 output : 'pdbg-test.dtb', 39 command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb', 40 '-o', '@OUTPUT@', '@INPUT@' ]) 41 42pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path() 43 44# end2end code exerciser for experiment and testing 45subdir('end2end') 46 47################################################################################ 48 49tc = 'test-bin-stream' 50 51src = [ 52 files( 53 tc + '.cpp', 54 ), 55] 56 57dep = [ gtest_dep ] 58 59var = [ ] 60 61exe = executable(tc.underscorify(), src, dependencies: dep, 62 cpp_args: test_arg, include_directories: incdir) 63 64test(tc, exe, env: var) 65 66################################################################################ 67 68tc = 'test-ffdc-file' 69 70src = [ 71 files( 72 tc + '.cpp', 73 '../util/ffdc_file.cpp', 74 '../util/temporary_file.cpp', 75 ), 76] 77 78dep = [ gtest_dep ] 79 80var = [ ] 81 82exe = executable(tc.underscorify(), src, dependencies: dep, 83 cpp_args: test_arg, include_directories: incdir) 84 85test(tc, exe, env: var) 86 87################################################################################ 88 89tc = 'test-lpc-timeout' 90 91src = [ 92 files( 93 tc + '.cpp', 94 '../analyzer/plugins/p10-plugins.cpp', 95 '../analyzer/service_data.cpp', 96 '../util/pdbg.cpp', 97 'pdbg-sim-only.cpp', 98 ), 99 pdbg_test_dtb, 100] 101 102dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 103 104var = [ pdbg_env ] 105 106exe = executable(tc.underscorify(), src, dependencies: dep, 107 cpp_args: test_arg, include_directories: incdir) 108 109test(tc, exe, env: var) 110 111################################################################################ 112 113tc = 'test-pdbg-dts' 114 115src = [ 116 files( 117 tc + '.cpp', 118 '../util/pdbg.cpp', 119 'pdbg-sim-only.cpp', 120 ), 121 pdbg_test_dtb, 122] 123 124dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 125 126var = [ pdbg_env ] 127 128exe = executable(tc.underscorify(), src, dependencies: dep, 129 cpp_args: test_arg, include_directories: incdir) 130 131test(tc, exe, env: var) 132 133################################################################################ 134 135tc = 'test-pll-unlock' 136 137src = [ 138 files( 139 tc + '.cpp', 140 '../analyzer/plugins/p10-plugins.cpp', 141 '../analyzer/ras-data/ras-data-parser.cpp', 142 '../analyzer/resolution.cpp', 143 '../analyzer/service_data.cpp', 144 '../util/data_file.cpp', 145 '../util/pdbg.cpp', 146 'pdbg-sim-only.cpp', 147 ), 148 pdbg_test_dtb, 149] 150 151dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 152 153var = [ pdbg_env ] 154 155exe = executable(tc.underscorify(), src, dependencies: dep, 156 cpp_args: test_arg, include_directories: incdir) 157 158test(tc, exe, env: var) 159 160################################################################################ 161 162tc = 'test-resolution' 163 164src = [ 165 files( 166 tc + '.cpp', 167 '../analyzer/resolution.cpp', 168 '../analyzer/service_data.cpp', 169 '../util/pdbg.cpp', 170 'pdbg-sim-only.cpp', 171 ), 172 pdbg_test_dtb, 173] 174 175dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 176 177var = [ pdbg_env ] 178 179exe = executable(tc.underscorify(), src, dependencies: dep, 180 cpp_args: test_arg, include_directories: incdir) 181 182test(tc, exe, env: var) 183 184################################################################################ 185 186tc = 'test-tod-step-check-fault' 187 188src = [ 189 files( 190 tc + '.cpp', 191 '../analyzer/plugins/p10-tod-plugins.cpp', 192 '../analyzer/service_data.cpp', 193 '../util/pdbg.cpp', 194 'pdbg-sim-only.cpp', 195 ), 196 pdbg_test_dtb, 197] 198 199dep = [ libhei_dep, libpdbg_dep, gtest_dep ] 200 201var = [ pdbg_env ] 202 203exe = executable(tc.underscorify(), src, dependencies: dep, 204 cpp_args: test_arg, include_directories: incdir) 205 206test(tc, exe, env: var) 207 208################################################################################ 209 210tc = 'test-ti-handler' 211 212src = [ 213 files( 214 tc + '.cpp', 215 ), 216] 217 218dep = [ gtest_dep ] 219 220var = [ ] 221 222exe = executable(tc.underscorify(), src, dependencies: dep, 223 link_with : hwdiags_libs, 224 cpp_args: test_arg, include_directories: incdir) 225 226test(tc, exe, env: var) 227