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