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'), |
| 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 |
| 20 | endif |
| 21 | |
| 22 | pathgentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 31 | '-e', meson.current_build_dir() + '/pathgentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 32 | 'generate-cpp' |
| 33 | ], |
| 34 | input: [ |
| 35 | 'templates/pathgentest.mako.hpp', |
| 36 | 'yaml/pathgentest/groupone.yaml', |
| 37 | 'yaml/pathgentest/grouptwo.yaml', |
| 38 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 39 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 40 | output: 'pathgentest.hpp', |
| 41 | ) |
| 42 | |
| 43 | pathgentest_sources = [ |
| 44 | pathgentest_hpp, |
| 45 | 'pathgentest.cpp', |
| 46 | ] |
| 47 | |
| 48 | test('pathgentest.cpp', |
| 49 | executable( |
| 50 | 'pathgentest', |
| 51 | pathgentest_sources, |
| 52 | build_by_default: false, |
| 53 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 54 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 55 | )) |
| 56 | |
| 57 | |
| 58 | propertygentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 67 | '-e', meson.current_build_dir() + '/propertygentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 68 | 'generate-cpp' |
| 69 | ], |
| 70 | input: [ |
| 71 | 'templates/propertygentest.mako.hpp', |
| 72 | 'yaml/propertygentest/groupone.yaml', |
| 73 | 'yaml/propertygentest/grouptwo.yaml', |
| 74 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 75 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 76 | output: 'propertygentest.hpp', |
| 77 | ) |
| 78 | |
| 79 | propertygentest_sources = [ |
| 80 | propertygentest_hpp, |
| 81 | 'propertygentest.cpp', |
| 82 | ] |
| 83 | |
| 84 | test('propertygentest.cpp', |
| 85 | executable( |
| 86 | 'propertygentest', |
| 87 | propertygentest_sources, |
| 88 | build_by_default: false, |
| 89 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 90 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 91 | )) |
| 92 | |
| 93 | |
| 94 | propertywatchgentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 103 | '-e', meson.current_build_dir() + '/propertywatchgentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 104 | 'generate-cpp' |
| 105 | ], |
| 106 | input: [ |
| 107 | 'templates/propertywatchgentest.mako.hpp', |
| 108 | 'yaml/propertywatchgentest/watchone.yaml', |
| 109 | 'yaml/propertywatchgentest/watchtwo.yaml', |
| 110 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 111 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 112 | output: 'propertywatchgentest.hpp', |
| 113 | ) |
| 114 | |
| 115 | propertywatchgentest_sources = [ |
| 116 | propertywatchgentest_hpp, |
| 117 | 'propertywatchgentest.cpp', |
| 118 | ] |
| 119 | |
| 120 | test('propertywatchgentest.cpp', |
| 121 | executable( |
| 122 | 'propertywatchgentest', |
| 123 | propertywatchgentest_sources, |
| 124 | build_by_default: false, |
| 125 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 126 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 127 | )) |
| 128 | |
| 129 | |
| 130 | callbackgentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 139 | '-e', meson.current_build_dir() + '/callbackgentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 140 | 'generate-cpp' |
| 141 | ], |
| 142 | input: [ |
| 143 | 'templates/callbackgentest.mako.hpp', |
| 144 | 'yaml/callbackgentest/one.yaml', |
| 145 | 'yaml/callbackgentest/two.yaml', |
| 146 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 147 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 148 | output: 'callbackgentest.hpp', |
| 149 | ) |
| 150 | |
| 151 | callbackgentest_sources = [ |
| 152 | callbackgentest_hpp, |
| 153 | 'callbackgentest.cpp', |
| 154 | ] |
| 155 | |
| 156 | test('callbackgentest.cpp', |
| 157 | executable( |
| 158 | 'callbackgentest', |
| 159 | callbackgentest_sources, |
| 160 | build_by_default: false, |
| 161 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 162 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 163 | )) |
| 164 | |
| 165 | |
| 166 | callbackgroupgentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 175 | '-e', meson.current_build_dir() + '/callbackgroupgentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 176 | 'generate-cpp' |
| 177 | ], |
| 178 | input: [ |
| 179 | 'templates/callbackgroupgentest.mako.hpp', |
| 180 | 'yaml/callbackgroupgentest/test.yaml', |
| 181 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 182 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 183 | output: 'callbackgroupgentest.hpp', |
| 184 | ) |
| 185 | |
| 186 | callbackgroupgentest_sources = [ |
| 187 | callbackgroupgentest_hpp, |
| 188 | 'callbackgroupgentest.cpp', |
| 189 | ] |
| 190 | |
| 191 | test('callbackgroupgentest.cpp', |
| 192 | executable( |
| 193 | 'callbackgroupgentest', |
| 194 | callbackgroupgentest_sources, |
| 195 | build_by_default: false, |
| 196 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 197 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 198 | )) |
| 199 | |
| 200 | |
| 201 | conditiongentest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 210 | '-e', meson.current_build_dir() + '/conditiongentest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 211 | 'generate-cpp' |
| 212 | ], |
| 213 | input: [ |
| 214 | 'templates/conditiongentest.mako.hpp', |
| 215 | 'yaml/conditiongentest/test.yaml', |
| 216 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 217 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 218 | output: 'conditiongentest.hpp', |
| 219 | ) |
| 220 | |
| 221 | conditiongentest_sources = [ |
| 222 | conditiongentest_hpp, |
| 223 | 'conditiongentest.cpp', |
| 224 | ] |
| 225 | |
| 226 | test('conditiongentest.cpp', |
| 227 | executable( |
| 228 | 'conditiongentest', |
| 229 | conditiongentest_sources, |
| 230 | build_by_default: false, |
| 231 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 232 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 233 | )) |
| 234 | |
| 235 | |
| 236 | callbacktest_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 | |
| 246 | callbacktest_deps = [ |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 247 | cereal_dep, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 248 | sdbusplus_dep, |
| 249 | sdeventplus_dep, |
| 250 | phosphor_dbus_interfaces_dep, |
| 251 | phosphor_logging_dep, |
| 252 | gtest_dep, |
| 253 | gmock_dep, |
| 254 | ] |
| 255 | |
| 256 | test('callbacktest.cpp', |
| 257 | executable( |
| 258 | 'callbacktest', |
| 259 | callbacktest_sources, |
| 260 | build_by_default: false, |
| 261 | include_directories: ['..', '../../'], |
| 262 | dependencies: callbacktest_deps, |
| 263 | )) |
| 264 | |
| 265 | |
| 266 | interfaceaddtest_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', |
Matt Johnston | 04267b4 | 2022-08-04 15:05:11 +0800 | [diff] [blame] | 275 | '-e', meson.current_build_dir() + '/interfaceaddtest-errors.hpp', |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 276 | 'generate-cpp' |
| 277 | ], |
| 278 | input: [ |
| 279 | 'templates/interfaceaddtest.mako.hpp', |
| 280 | 'yaml/interfaceaddtest/one.yaml', |
| 281 | ], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 282 | env: sdbusplus_python_env, |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 283 | output: 'interfaceaddtest.hpp', |
| 284 | ) |
| 285 | |
| 286 | interfaceaddtest_sources = [ |
| 287 | interfaceaddtest_hpp, |
| 288 | 'interfaceaddtest.cpp', |
| 289 | ] |
| 290 | |
| 291 | test('interfaceaddtest.cpp', |
| 292 | executable( |
| 293 | 'interfaceaddtest', |
| 294 | interfaceaddtest_sources, |
| 295 | build_by_default: false, |
| 296 | include_directories: ['..'], |
Konstantin Aladyshev | cd1e72a | 2024-10-10 17:22:19 +0300 | [diff] [blame] | 297 | dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep, sdeventplus_dep] |
George Liu | 7efd6f3 | 2022-06-22 10:42:56 +0800 | [diff] [blame] | 298 | )) |