1gtest_dep = dependency('gtest', main: true, disabler: true, required: false) 2gmock_dep = dependency('gmock', disabler: true, required: false) 3if not gtest_dep.found() or not gmock_dep.found() 4 gtest_proj = import('cmake').subproject('googletest', required: false) 5 if gtest_proj.found() 6 gtest_dep = declare_dependency( 7 dependencies: [ 8 dependency('threads'), 9 gtest_proj.dependency('gtest'), 10 gtest_proj.dependency('gtest_main'), 11 ] 12 ) 13 gmock_dep = gtest_proj.dependency('gmock') 14 else 15 assert( 16 not get_option('tests').enabled(), 17 'Googletest is required if tests are enabled' 18 ) 19 endif 20endif 21 22pathgentest_hpp = custom_target( 23 'pathgentest.hpp', 24 command: [ 25 prog_python, 26 meson.project_source_root() + '/src/pdmgen.py', 27 '-t', 'pathgentest.mako.hpp', 28 '-p', meson.project_source_root() + '/src/test/templates', 29 '-d', meson.project_source_root() + '/src/test/yaml/pathgentest', 30 '-o', meson.current_build_dir() + '/pathgentest.hpp', 31 '-e', meson.current_build_dir() + '/pathgentest-errors.hpp', 32 'generate-cpp' 33 ], 34 input: [ 35 'templates/pathgentest.mako.hpp', 36 'yaml/pathgentest/groupone.yaml', 37 'yaml/pathgentest/grouptwo.yaml', 38 ], 39 env: sdbusplus_python_env, 40 output: 'pathgentest.hpp', 41) 42 43pathgentest_sources = [ 44 pathgentest_hpp, 45 'pathgentest.cpp', 46] 47 48test('pathgentest.cpp', 49 executable( 50 'pathgentest', 51 pathgentest_sources, 52 build_by_default: false, 53 include_directories: ['..'], 54 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 55 )) 56 57 58propertygentest_hpp = custom_target( 59 'propertygentest.hpp', 60 command: [ 61 prog_python, 62 meson.project_source_root() + '/src/pdmgen.py', 63 '-t', 'propertygentest.mako.hpp', 64 '-p', meson.project_source_root() + '/src/test/templates', 65 '-d', meson.project_source_root() + '/src/test/yaml/propertygentest', 66 '-o', meson.current_build_dir() + '/propertygentest.hpp', 67 '-e', meson.current_build_dir() + '/propertygentest-errors.hpp', 68 'generate-cpp' 69 ], 70 input: [ 71 'templates/propertygentest.mako.hpp', 72 'yaml/propertygentest/groupone.yaml', 73 'yaml/propertygentest/grouptwo.yaml', 74 ], 75 env: sdbusplus_python_env, 76 output: 'propertygentest.hpp', 77) 78 79propertygentest_sources = [ 80 propertygentest_hpp, 81 'propertygentest.cpp', 82] 83 84test('propertygentest.cpp', 85 executable( 86 'propertygentest', 87 propertygentest_sources, 88 build_by_default: false, 89 include_directories: ['..'], 90 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 91 )) 92 93 94propertywatchgentest_hpp = custom_target( 95 'propertywatchgentest.hpp', 96 command: [ 97 prog_python, 98 meson.project_source_root() + '/src/pdmgen.py', 99 '-t', 'propertywatchgentest.mako.hpp', 100 '-p', meson.project_source_root() + '/src/test/templates', 101 '-d', meson.project_source_root() + '/src/test/yaml/propertywatchgentest', 102 '-o', meson.current_build_dir() + '/propertywatchgentest.hpp', 103 '-e', meson.current_build_dir() + '/propertywatchgentest-errors.hpp', 104 'generate-cpp' 105 ], 106 input: [ 107 'templates/propertywatchgentest.mako.hpp', 108 'yaml/propertywatchgentest/watchone.yaml', 109 'yaml/propertywatchgentest/watchtwo.yaml', 110 ], 111 env: sdbusplus_python_env, 112 output: 'propertywatchgentest.hpp', 113) 114 115propertywatchgentest_sources = [ 116 propertywatchgentest_hpp, 117 'propertywatchgentest.cpp', 118] 119 120test('propertywatchgentest.cpp', 121 executable( 122 'propertywatchgentest', 123 propertywatchgentest_sources, 124 build_by_default: false, 125 include_directories: ['..'], 126 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 127 )) 128 129 130callbackgentest_hpp = custom_target( 131 'callbackgentest.hpp', 132 command: [ 133 prog_python, 134 meson.project_source_root() + '/src/pdmgen.py', 135 '-t', 'callbackgentest.mako.hpp', 136 '-p', meson.project_source_root() + '/src/test/templates', 137 '-d', meson.project_source_root() + '/src/test/yaml/callbackgentest', 138 '-o', meson.current_build_dir() + '/callbackgentest.hpp', 139 '-e', meson.current_build_dir() + '/callbackgentest-errors.hpp', 140 'generate-cpp' 141 ], 142 input: [ 143 'templates/callbackgentest.mako.hpp', 144 'yaml/callbackgentest/one.yaml', 145 'yaml/callbackgentest/two.yaml', 146 ], 147 env: sdbusplus_python_env, 148 output: 'callbackgentest.hpp', 149) 150 151callbackgentest_sources = [ 152 callbackgentest_hpp, 153 'callbackgentest.cpp', 154] 155 156test('callbackgentest.cpp', 157 executable( 158 'callbackgentest', 159 callbackgentest_sources, 160 build_by_default: false, 161 include_directories: ['..'], 162 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 163 )) 164 165 166callbackgroupgentest_hpp = custom_target( 167 'callbackgroupgentest.hpp', 168 command: [ 169 prog_python, 170 meson.project_source_root() + '/src/pdmgen.py', 171 '-t', 'callbackgroupgentest.mako.hpp', 172 '-p', meson.project_source_root() + '/src/test/templates', 173 '-d', meson.project_source_root() + '/src/test/yaml/callbackgroupgentest', 174 '-o', meson.current_build_dir() + '/callbackgroupgentest.hpp', 175 '-e', meson.current_build_dir() + '/callbackgroupgentest-errors.hpp', 176 'generate-cpp' 177 ], 178 input: [ 179 'templates/callbackgroupgentest.mako.hpp', 180 'yaml/callbackgroupgentest/test.yaml', 181 ], 182 env: sdbusplus_python_env, 183 output: 'callbackgroupgentest.hpp', 184) 185 186callbackgroupgentest_sources = [ 187 callbackgroupgentest_hpp, 188 'callbackgroupgentest.cpp', 189] 190 191test('callbackgroupgentest.cpp', 192 executable( 193 'callbackgroupgentest', 194 callbackgroupgentest_sources, 195 build_by_default: false, 196 include_directories: ['..'], 197 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 198 )) 199 200 201conditiongentest_hpp = custom_target( 202 'conditiongentest.hpp', 203 command: [ 204 prog_python, 205 meson.project_source_root() + '/src/pdmgen.py', 206 '-t', 'conditiongentest.mako.hpp', 207 '-p', meson.project_source_root() + '/src/test/templates', 208 '-d', meson.project_source_root() + '/src/test/yaml/conditiongentest', 209 '-o', meson.current_build_dir() + '/conditiongentest.hpp', 210 '-e', meson.current_build_dir() + '/conditiongentest-errors.hpp', 211 'generate-cpp' 212 ], 213 input: [ 214 'templates/conditiongentest.mako.hpp', 215 'yaml/conditiongentest/test.yaml', 216 ], 217 env: sdbusplus_python_env, 218 output: 'conditiongentest.hpp', 219) 220 221conditiongentest_sources = [ 222 conditiongentest_hpp, 223 'conditiongentest.cpp', 224] 225 226test('conditiongentest.cpp', 227 executable( 228 'conditiongentest', 229 conditiongentest_sources, 230 build_by_default: false, 231 include_directories: ['..'], 232 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] 233 )) 234 235 236callbacktest_sources = [ 237 generated_hpp, 238 'callbacktest.cpp', 239 '../journal.cpp', 240 '../elog.cpp', 241 '../resolve_errors.cpp', 242 '../event_manager.cpp', 243 '../event_serialize.cpp', 244] 245 246callbacktest_deps = [ 247 cereal_dep, 248 sdbusplus_dep, 249 sdeventplus_dep, 250 phosphor_dbus_interfaces_dep, 251 phosphor_logging_dep, 252 gtest_dep, 253 gmock_dep, 254] 255 256test('callbacktest.cpp', 257 executable( 258 'callbacktest', 259 callbacktest_sources, 260 build_by_default: false, 261 include_directories: ['..', '../../'], 262 dependencies: callbacktest_deps, 263 )) 264 265 266interfaceaddtest_hpp = custom_target( 267 'interfaceaddtest.hpp', 268 command: [ 269 prog_python, 270 meson.project_source_root() + '/src/pdmgen.py', 271 '-t', 'interfaceaddtest.mako.hpp', 272 '-p', meson.project_source_root() + '/src/test/templates', 273 '-d', meson.project_source_root() + '/src/test/yaml/interfaceaddtest', 274 '-o', meson.current_build_dir() + '/interfaceaddtest.hpp', 275 '-e', meson.current_build_dir() + '/interfaceaddtest-errors.hpp', 276 'generate-cpp' 277 ], 278 input: [ 279 'templates/interfaceaddtest.mako.hpp', 280 'yaml/interfaceaddtest/one.yaml', 281 ], 282 env: sdbusplus_python_env, 283 output: 'interfaceaddtest.hpp', 284) 285 286interfaceaddtest_sources = [ 287 interfaceaddtest_hpp, 288 'interfaceaddtest.cpp', 289] 290 291test('interfaceaddtest.cpp', 292 executable( 293 'interfaceaddtest', 294 interfaceaddtest_sources, 295 build_by_default: false, 296 include_directories: ['..'], 297 dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep, sdeventplus_dep] 298 )) 299