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