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 'generate-cpp' 32 ], 33 input: [ 34 'templates/pathgentest.mako.hpp', 35 'yaml/pathgentest/groupone.yaml', 36 'yaml/pathgentest/grouptwo.yaml', 37 ], 38 output: 'pathgentest.hpp', 39) 40 41pathgentest_sources = [ 42 pathgentest_hpp, 43 'pathgentest.cpp', 44] 45 46test('pathgentest.cpp', 47 executable( 48 'pathgentest', 49 pathgentest_sources, 50 build_by_default: false, 51 include_directories: ['..'], 52 dependencies: [gtest_dep, gmock_dep] 53 )) 54 55 56propertygentest_hpp = custom_target( 57 'propertygentest.hpp', 58 command: [ 59 prog_python, 60 meson.project_source_root() + '/src/pdmgen.py', 61 '-t', 'propertygentest.mako.hpp', 62 '-p', meson.project_source_root() + '/src/test/templates', 63 '-d', meson.project_source_root() + '/src/test/yaml/propertygentest', 64 '-o', meson.current_build_dir() + '/propertygentest.hpp', 65 'generate-cpp' 66 ], 67 input: [ 68 'templates/propertygentest.mako.hpp', 69 'yaml/propertygentest/groupone.yaml', 70 'yaml/propertygentest/grouptwo.yaml', 71 ], 72 output: 'propertygentest.hpp', 73) 74 75propertygentest_sources = [ 76 propertygentest_hpp, 77 'propertygentest.cpp', 78] 79 80test('propertygentest.cpp', 81 executable( 82 'propertygentest', 83 propertygentest_sources, 84 build_by_default: false, 85 include_directories: ['..'], 86 dependencies: [gtest_dep, gmock_dep] 87 )) 88 89 90propertywatchgentest_hpp = custom_target( 91 'propertywatchgentest.hpp', 92 command: [ 93 prog_python, 94 meson.project_source_root() + '/src/pdmgen.py', 95 '-t', 'propertywatchgentest.mako.hpp', 96 '-p', meson.project_source_root() + '/src/test/templates', 97 '-d', meson.project_source_root() + '/src/test/yaml/propertywatchgentest', 98 '-o', meson.current_build_dir() + '/propertywatchgentest.hpp', 99 'generate-cpp' 100 ], 101 input: [ 102 'templates/propertywatchgentest.mako.hpp', 103 'yaml/propertywatchgentest/watchone.yaml', 104 'yaml/propertywatchgentest/watchtwo.yaml', 105 ], 106 output: 'propertywatchgentest.hpp', 107) 108 109propertywatchgentest_sources = [ 110 propertywatchgentest_hpp, 111 'propertywatchgentest.cpp', 112] 113 114test('propertywatchgentest.cpp', 115 executable( 116 'propertywatchgentest', 117 propertywatchgentest_sources, 118 build_by_default: false, 119 include_directories: ['..'], 120 dependencies: [gtest_dep, gmock_dep] 121 )) 122 123 124callbackgentest_hpp = custom_target( 125 'callbackgentest.hpp', 126 command: [ 127 prog_python, 128 meson.project_source_root() + '/src/pdmgen.py', 129 '-t', 'callbackgentest.mako.hpp', 130 '-p', meson.project_source_root() + '/src/test/templates', 131 '-d', meson.project_source_root() + '/src/test/yaml/callbackgentest', 132 '-o', meson.current_build_dir() + '/callbackgentest.hpp', 133 'generate-cpp' 134 ], 135 input: [ 136 'templates/callbackgentest.mako.hpp', 137 'yaml/callbackgentest/one.yaml', 138 'yaml/callbackgentest/two.yaml', 139 ], 140 output: 'callbackgentest.hpp', 141) 142 143callbackgentest_sources = [ 144 callbackgentest_hpp, 145 'callbackgentest.cpp', 146] 147 148test('callbackgentest.cpp', 149 executable( 150 'callbackgentest', 151 callbackgentest_sources, 152 build_by_default: false, 153 include_directories: ['..'], 154 dependencies: [gtest_dep, gmock_dep] 155 )) 156 157 158callbackgroupgentest_hpp = custom_target( 159 'callbackgroupgentest.hpp', 160 command: [ 161 prog_python, 162 meson.project_source_root() + '/src/pdmgen.py', 163 '-t', 'callbackgroupgentest.mako.hpp', 164 '-p', meson.project_source_root() + '/src/test/templates', 165 '-d', meson.project_source_root() + '/src/test/yaml/callbackgroupgentest', 166 '-o', meson.current_build_dir() + '/callbackgroupgentest.hpp', 167 'generate-cpp' 168 ], 169 input: [ 170 'templates/callbackgroupgentest.mako.hpp', 171 'yaml/callbackgroupgentest/test.yaml', 172 ], 173 output: 'callbackgroupgentest.hpp', 174) 175 176callbackgroupgentest_sources = [ 177 callbackgroupgentest_hpp, 178 'callbackgroupgentest.cpp', 179] 180 181test('callbackgroupgentest.cpp', 182 executable( 183 'callbackgroupgentest', 184 callbackgroupgentest_sources, 185 build_by_default: false, 186 include_directories: ['..'], 187 dependencies: [gtest_dep, gmock_dep] 188 )) 189 190 191conditiongentest_hpp = custom_target( 192 'conditiongentest.hpp', 193 command: [ 194 prog_python, 195 meson.project_source_root() + '/src/pdmgen.py', 196 '-t', 'conditiongentest.mako.hpp', 197 '-p', meson.project_source_root() + '/src/test/templates', 198 '-d', meson.project_source_root() + '/src/test/yaml/conditiongentest', 199 '-o', meson.current_build_dir() + '/conditiongentest.hpp', 200 'generate-cpp' 201 ], 202 input: [ 203 'templates/conditiongentest.mako.hpp', 204 'yaml/conditiongentest/test.yaml', 205 ], 206 output: 'conditiongentest.hpp', 207) 208 209conditiongentest_sources = [ 210 conditiongentest_hpp, 211 'conditiongentest.cpp', 212] 213 214test('conditiongentest.cpp', 215 executable( 216 'conditiongentest', 217 conditiongentest_sources, 218 build_by_default: false, 219 include_directories: ['..'], 220 dependencies: [gtest_dep, gmock_dep] 221 )) 222 223 224callbacktest_sources = [ 225 generated_hpp, 226 'callbacktest.cpp', 227 '../journal.cpp', 228 '../elog.cpp', 229 '../resolve_errors.cpp', 230 '../event_manager.cpp', 231 '../event_serialize.cpp', 232] 233 234callbacktest_deps = [ 235 sdbusplus_dep, 236 sdeventplus_dep, 237 phosphor_dbus_interfaces_dep, 238 phosphor_logging_dep, 239 gtest_dep, 240 gmock_dep, 241] 242 243test('callbacktest.cpp', 244 executable( 245 'callbacktest', 246 callbacktest_sources, 247 build_by_default: false, 248 include_directories: ['..', '../../'], 249 dependencies: callbacktest_deps, 250 )) 251 252 253interfaceaddtest_hpp = custom_target( 254 'interfaceaddtest.hpp', 255 command: [ 256 prog_python, 257 meson.project_source_root() + '/src/pdmgen.py', 258 '-t', 'interfaceaddtest.mako.hpp', 259 '-p', meson.project_source_root() + '/src/test/templates', 260 '-d', meson.project_source_root() + '/src/test/yaml/interfaceaddtest', 261 '-o', meson.current_build_dir() + '/interfaceaddtest.hpp', 262 'generate-cpp' 263 ], 264 input: [ 265 'templates/interfaceaddtest.mako.hpp', 266 'yaml/interfaceaddtest/one.yaml', 267 ], 268 output: 'interfaceaddtest.hpp', 269) 270 271interfaceaddtest_sources = [ 272 interfaceaddtest_hpp, 273 'interfaceaddtest.cpp', 274] 275 276test('interfaceaddtest.cpp', 277 executable( 278 'interfaceaddtest', 279 interfaceaddtest_sources, 280 build_by_default: false, 281 include_directories: ['..'], 282 dependencies: [gtest_dep, gmock_dep] 283 )) 284