xref: /openbmc/phosphor-dbus-monitor/src/test/meson.build (revision 9c2f94e155b86ef234f2cc8aa39d4e18a15a0561)
17efd6f3cSGeorge Liugtest_dep = dependency('gtest', main: true, disabler: true, required: false)
27efd6f3cSGeorge Liugmock_dep = dependency('gmock', disabler: true, required: false)
37efd6f3cSGeorge Liuif not gtest_dep.found() or not gmock_dep.found()
47efd6f3cSGeorge Liu    gtest_proj = import('cmake').subproject('googletest', required: false)
57efd6f3cSGeorge Liu    if gtest_proj.found()
67efd6f3cSGeorge Liu        gtest_dep = declare_dependency(
77efd6f3cSGeorge Liu            dependencies: [
87efd6f3cSGeorge Liu                dependency('threads'),
97efd6f3cSGeorge Liu                gtest_proj.dependency('gtest'),
107efd6f3cSGeorge Liu                gtest_proj.dependency('gtest_main'),
11*9c2f94e1SPatrick Williams            ],
127efd6f3cSGeorge Liu        )
137efd6f3cSGeorge Liu        gmock_dep = gtest_proj.dependency('gmock')
147efd6f3cSGeorge Liu    else
157efd6f3cSGeorge Liu        assert(
167efd6f3cSGeorge Liu            not get_option('tests').enabled(),
17*9c2f94e1SPatrick Williams            'Googletest is required if tests are enabled',
187efd6f3cSGeorge Liu        )
197efd6f3cSGeorge Liu    endif
207efd6f3cSGeorge Liuendif
217efd6f3cSGeorge Liu
227efd6f3cSGeorge Liupathgentest_hpp = custom_target(
237efd6f3cSGeorge Liu    'pathgentest.hpp',
247efd6f3cSGeorge Liu    command: [
257efd6f3cSGeorge Liu        prog_python,
267efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
27*9c2f94e1SPatrick Williams        '-t',
28*9c2f94e1SPatrick Williams        'pathgentest.mako.hpp',
29*9c2f94e1SPatrick Williams        '-p',
30*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
31*9c2f94e1SPatrick Williams        '-d',
32*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/pathgentest',
33*9c2f94e1SPatrick Williams        '-o',
34*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/pathgentest.hpp',
35*9c2f94e1SPatrick Williams        '-e',
36*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/pathgentest-errors.hpp',
37*9c2f94e1SPatrick Williams        'generate-cpp',
387efd6f3cSGeorge Liu    ],
397efd6f3cSGeorge Liu    input: [
407efd6f3cSGeorge Liu        'templates/pathgentest.mako.hpp',
417efd6f3cSGeorge Liu        'yaml/pathgentest/groupone.yaml',
427efd6f3cSGeorge Liu        'yaml/pathgentest/grouptwo.yaml',
437efd6f3cSGeorge Liu    ],
44cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
457efd6f3cSGeorge Liu    output: 'pathgentest.hpp',
467efd6f3cSGeorge Liu)
477efd6f3cSGeorge Liu
48*9c2f94e1SPatrick Williamspathgentest_sources = [pathgentest_hpp, 'pathgentest.cpp']
497efd6f3cSGeorge Liu
50*9c2f94e1SPatrick Williamstest(
51*9c2f94e1SPatrick Williams    'pathgentest.cpp',
527efd6f3cSGeorge Liu    executable(
537efd6f3cSGeorge Liu        'pathgentest',
547efd6f3cSGeorge Liu        pathgentest_sources,
557efd6f3cSGeorge Liu        build_by_default: false,
567efd6f3cSGeorge Liu        include_directories: ['..'],
57*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
58*9c2f94e1SPatrick Williams    ),
59*9c2f94e1SPatrick Williams)
607efd6f3cSGeorge Liu
617efd6f3cSGeorge Liu
627efd6f3cSGeorge Liupropertygentest_hpp = custom_target(
637efd6f3cSGeorge Liu    'propertygentest.hpp',
647efd6f3cSGeorge Liu    command: [
657efd6f3cSGeorge Liu        prog_python,
667efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
67*9c2f94e1SPatrick Williams        '-t',
68*9c2f94e1SPatrick Williams        'propertygentest.mako.hpp',
69*9c2f94e1SPatrick Williams        '-p',
70*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
71*9c2f94e1SPatrick Williams        '-d',
72*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/propertygentest',
73*9c2f94e1SPatrick Williams        '-o',
74*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/propertygentest.hpp',
75*9c2f94e1SPatrick Williams        '-e',
76*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/propertygentest-errors.hpp',
77*9c2f94e1SPatrick Williams        'generate-cpp',
787efd6f3cSGeorge Liu    ],
797efd6f3cSGeorge Liu    input: [
807efd6f3cSGeorge Liu        'templates/propertygentest.mako.hpp',
817efd6f3cSGeorge Liu        'yaml/propertygentest/groupone.yaml',
827efd6f3cSGeorge Liu        'yaml/propertygentest/grouptwo.yaml',
837efd6f3cSGeorge Liu    ],
84cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
857efd6f3cSGeorge Liu    output: 'propertygentest.hpp',
867efd6f3cSGeorge Liu)
877efd6f3cSGeorge Liu
88*9c2f94e1SPatrick Williamspropertygentest_sources = [propertygentest_hpp, 'propertygentest.cpp']
897efd6f3cSGeorge Liu
90*9c2f94e1SPatrick Williamstest(
91*9c2f94e1SPatrick Williams    'propertygentest.cpp',
927efd6f3cSGeorge Liu    executable(
937efd6f3cSGeorge Liu        'propertygentest',
947efd6f3cSGeorge Liu        propertygentest_sources,
957efd6f3cSGeorge Liu        build_by_default: false,
967efd6f3cSGeorge Liu        include_directories: ['..'],
97*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
98*9c2f94e1SPatrick Williams    ),
99*9c2f94e1SPatrick Williams)
1007efd6f3cSGeorge Liu
1017efd6f3cSGeorge Liu
1027efd6f3cSGeorge Liupropertywatchgentest_hpp = custom_target(
1037efd6f3cSGeorge Liu    'propertywatchgentest.hpp',
1047efd6f3cSGeorge Liu    command: [
1057efd6f3cSGeorge Liu        prog_python,
1067efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
107*9c2f94e1SPatrick Williams        '-t',
108*9c2f94e1SPatrick Williams        'propertywatchgentest.mako.hpp',
109*9c2f94e1SPatrick Williams        '-p',
110*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
111*9c2f94e1SPatrick Williams        '-d',
112*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/propertywatchgentest',
113*9c2f94e1SPatrick Williams        '-o',
114*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/propertywatchgentest.hpp',
115*9c2f94e1SPatrick Williams        '-e',
116*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/propertywatchgentest-errors.hpp',
117*9c2f94e1SPatrick Williams        'generate-cpp',
1187efd6f3cSGeorge Liu    ],
1197efd6f3cSGeorge Liu    input: [
1207efd6f3cSGeorge Liu        'templates/propertywatchgentest.mako.hpp',
1217efd6f3cSGeorge Liu        'yaml/propertywatchgentest/watchone.yaml',
1227efd6f3cSGeorge Liu        'yaml/propertywatchgentest/watchtwo.yaml',
1237efd6f3cSGeorge Liu    ],
124cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
1257efd6f3cSGeorge Liu    output: 'propertywatchgentest.hpp',
1267efd6f3cSGeorge Liu)
1277efd6f3cSGeorge Liu
1287efd6f3cSGeorge Liupropertywatchgentest_sources = [
1297efd6f3cSGeorge Liu    propertywatchgentest_hpp,
1307efd6f3cSGeorge Liu    'propertywatchgentest.cpp',
1317efd6f3cSGeorge Liu]
1327efd6f3cSGeorge Liu
133*9c2f94e1SPatrick Williamstest(
134*9c2f94e1SPatrick Williams    'propertywatchgentest.cpp',
1357efd6f3cSGeorge Liu    executable(
1367efd6f3cSGeorge Liu        'propertywatchgentest',
1377efd6f3cSGeorge Liu        propertywatchgentest_sources,
1387efd6f3cSGeorge Liu        build_by_default: false,
1397efd6f3cSGeorge Liu        include_directories: ['..'],
140*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
141*9c2f94e1SPatrick Williams    ),
142*9c2f94e1SPatrick Williams)
1437efd6f3cSGeorge Liu
1447efd6f3cSGeorge Liu
1457efd6f3cSGeorge Liucallbackgentest_hpp = custom_target(
1467efd6f3cSGeorge Liu    'callbackgentest.hpp',
1477efd6f3cSGeorge Liu    command: [
1487efd6f3cSGeorge Liu        prog_python,
1497efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
150*9c2f94e1SPatrick Williams        '-t',
151*9c2f94e1SPatrick Williams        'callbackgentest.mako.hpp',
152*9c2f94e1SPatrick Williams        '-p',
153*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
154*9c2f94e1SPatrick Williams        '-d',
155*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/callbackgentest',
156*9c2f94e1SPatrick Williams        '-o',
157*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/callbackgentest.hpp',
158*9c2f94e1SPatrick Williams        '-e',
159*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/callbackgentest-errors.hpp',
160*9c2f94e1SPatrick Williams        'generate-cpp',
1617efd6f3cSGeorge Liu    ],
1627efd6f3cSGeorge Liu    input: [
1637efd6f3cSGeorge Liu        'templates/callbackgentest.mako.hpp',
1647efd6f3cSGeorge Liu        'yaml/callbackgentest/one.yaml',
1657efd6f3cSGeorge Liu        'yaml/callbackgentest/two.yaml',
1667efd6f3cSGeorge Liu    ],
167cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
1687efd6f3cSGeorge Liu    output: 'callbackgentest.hpp',
1697efd6f3cSGeorge Liu)
1707efd6f3cSGeorge Liu
171*9c2f94e1SPatrick Williamscallbackgentest_sources = [callbackgentest_hpp, 'callbackgentest.cpp']
1727efd6f3cSGeorge Liu
173*9c2f94e1SPatrick Williamstest(
174*9c2f94e1SPatrick Williams    'callbackgentest.cpp',
1757efd6f3cSGeorge Liu    executable(
1767efd6f3cSGeorge Liu        'callbackgentest',
1777efd6f3cSGeorge Liu        callbackgentest_sources,
1787efd6f3cSGeorge Liu        build_by_default: false,
1797efd6f3cSGeorge Liu        include_directories: ['..'],
180*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
181*9c2f94e1SPatrick Williams    ),
182*9c2f94e1SPatrick Williams)
1837efd6f3cSGeorge Liu
1847efd6f3cSGeorge Liu
1857efd6f3cSGeorge Liucallbackgroupgentest_hpp = custom_target(
1867efd6f3cSGeorge Liu    'callbackgroupgentest.hpp',
1877efd6f3cSGeorge Liu    command: [
1887efd6f3cSGeorge Liu        prog_python,
1897efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
190*9c2f94e1SPatrick Williams        '-t',
191*9c2f94e1SPatrick Williams        'callbackgroupgentest.mako.hpp',
192*9c2f94e1SPatrick Williams        '-p',
193*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
194*9c2f94e1SPatrick Williams        '-d',
195*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/callbackgroupgentest',
196*9c2f94e1SPatrick Williams        '-o',
197*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/callbackgroupgentest.hpp',
198*9c2f94e1SPatrick Williams        '-e',
199*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/callbackgroupgentest-errors.hpp',
200*9c2f94e1SPatrick Williams        'generate-cpp',
2017efd6f3cSGeorge Liu    ],
2027efd6f3cSGeorge Liu    input: [
2037efd6f3cSGeorge Liu        'templates/callbackgroupgentest.mako.hpp',
2047efd6f3cSGeorge Liu        'yaml/callbackgroupgentest/test.yaml',
2057efd6f3cSGeorge Liu    ],
206cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
2077efd6f3cSGeorge Liu    output: 'callbackgroupgentest.hpp',
2087efd6f3cSGeorge Liu)
2097efd6f3cSGeorge Liu
2107efd6f3cSGeorge Liucallbackgroupgentest_sources = [
2117efd6f3cSGeorge Liu    callbackgroupgentest_hpp,
2127efd6f3cSGeorge Liu    'callbackgroupgentest.cpp',
2137efd6f3cSGeorge Liu]
2147efd6f3cSGeorge Liu
215*9c2f94e1SPatrick Williamstest(
216*9c2f94e1SPatrick Williams    'callbackgroupgentest.cpp',
2177efd6f3cSGeorge Liu    executable(
2187efd6f3cSGeorge Liu        'callbackgroupgentest',
2197efd6f3cSGeorge Liu        callbackgroupgentest_sources,
2207efd6f3cSGeorge Liu        build_by_default: false,
2217efd6f3cSGeorge Liu        include_directories: ['..'],
222*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
223*9c2f94e1SPatrick Williams    ),
224*9c2f94e1SPatrick Williams)
2257efd6f3cSGeorge Liu
2267efd6f3cSGeorge Liu
2277efd6f3cSGeorge Liuconditiongentest_hpp = custom_target(
2287efd6f3cSGeorge Liu    'conditiongentest.hpp',
2297efd6f3cSGeorge Liu    command: [
2307efd6f3cSGeorge Liu        prog_python,
2317efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
232*9c2f94e1SPatrick Williams        '-t',
233*9c2f94e1SPatrick Williams        'conditiongentest.mako.hpp',
234*9c2f94e1SPatrick Williams        '-p',
235*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
236*9c2f94e1SPatrick Williams        '-d',
237*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/conditiongentest',
238*9c2f94e1SPatrick Williams        '-o',
239*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/conditiongentest.hpp',
240*9c2f94e1SPatrick Williams        '-e',
241*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/conditiongentest-errors.hpp',
242*9c2f94e1SPatrick Williams        'generate-cpp',
2437efd6f3cSGeorge Liu    ],
2447efd6f3cSGeorge Liu    input: [
2457efd6f3cSGeorge Liu        'templates/conditiongentest.mako.hpp',
2467efd6f3cSGeorge Liu        'yaml/conditiongentest/test.yaml',
2477efd6f3cSGeorge Liu    ],
248cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
2497efd6f3cSGeorge Liu    output: 'conditiongentest.hpp',
2507efd6f3cSGeorge Liu)
2517efd6f3cSGeorge Liu
252*9c2f94e1SPatrick Williamsconditiongentest_sources = [conditiongentest_hpp, 'conditiongentest.cpp']
2537efd6f3cSGeorge Liu
254*9c2f94e1SPatrick Williamstest(
255*9c2f94e1SPatrick Williams    'conditiongentest.cpp',
2567efd6f3cSGeorge Liu    executable(
2577efd6f3cSGeorge Liu        'conditiongentest',
2587efd6f3cSGeorge Liu        conditiongentest_sources,
2597efd6f3cSGeorge Liu        build_by_default: false,
2607efd6f3cSGeorge Liu        include_directories: ['..'],
261*9c2f94e1SPatrick Williams        dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep],
262*9c2f94e1SPatrick Williams    ),
263*9c2f94e1SPatrick Williams)
2647efd6f3cSGeorge Liu
2657efd6f3cSGeorge Liu
2667efd6f3cSGeorge Liucallbacktest_sources = [
2677efd6f3cSGeorge Liu    generated_hpp,
2687efd6f3cSGeorge Liu    'callbacktest.cpp',
2697efd6f3cSGeorge Liu    '../journal.cpp',
2707efd6f3cSGeorge Liu    '../elog.cpp',
2717efd6f3cSGeorge Liu    '../resolve_errors.cpp',
2727efd6f3cSGeorge Liu    '../event_manager.cpp',
2737efd6f3cSGeorge Liu    '../event_serialize.cpp',
2747efd6f3cSGeorge Liu]
2757efd6f3cSGeorge Liu
2767efd6f3cSGeorge Liucallbacktest_deps = [
277cd1e72a8SKonstantin Aladyshev    cereal_dep,
2787efd6f3cSGeorge Liu    sdbusplus_dep,
2797efd6f3cSGeorge Liu    sdeventplus_dep,
2807efd6f3cSGeorge Liu    phosphor_dbus_interfaces_dep,
2817efd6f3cSGeorge Liu    phosphor_logging_dep,
2827efd6f3cSGeorge Liu    gtest_dep,
2837efd6f3cSGeorge Liu    gmock_dep,
2847efd6f3cSGeorge Liu]
2857efd6f3cSGeorge Liu
286*9c2f94e1SPatrick Williamstest(
287*9c2f94e1SPatrick Williams    'callbacktest.cpp',
2887efd6f3cSGeorge Liu    executable(
2897efd6f3cSGeorge Liu        'callbacktest',
2907efd6f3cSGeorge Liu        callbacktest_sources,
2917efd6f3cSGeorge Liu        build_by_default: false,
2927efd6f3cSGeorge Liu        include_directories: ['..', '../../'],
2937efd6f3cSGeorge Liu        dependencies: callbacktest_deps,
294*9c2f94e1SPatrick Williams    ),
295*9c2f94e1SPatrick Williams)
2967efd6f3cSGeorge Liu
2977efd6f3cSGeorge Liu
2987efd6f3cSGeorge Liuinterfaceaddtest_hpp = custom_target(
2997efd6f3cSGeorge Liu    'interfaceaddtest.hpp',
3007efd6f3cSGeorge Liu    command: [
3017efd6f3cSGeorge Liu        prog_python,
3027efd6f3cSGeorge Liu        meson.project_source_root() + '/src/pdmgen.py',
303*9c2f94e1SPatrick Williams        '-t',
304*9c2f94e1SPatrick Williams        'interfaceaddtest.mako.hpp',
305*9c2f94e1SPatrick Williams        '-p',
306*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/templates',
307*9c2f94e1SPatrick Williams        '-d',
308*9c2f94e1SPatrick Williams        meson.project_source_root() + '/src/test/yaml/interfaceaddtest',
309*9c2f94e1SPatrick Williams        '-o',
310*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/interfaceaddtest.hpp',
311*9c2f94e1SPatrick Williams        '-e',
312*9c2f94e1SPatrick Williams        meson.current_build_dir() + '/interfaceaddtest-errors.hpp',
313*9c2f94e1SPatrick Williams        'generate-cpp',
3147efd6f3cSGeorge Liu    ],
3157efd6f3cSGeorge Liu    input: [
3167efd6f3cSGeorge Liu        'templates/interfaceaddtest.mako.hpp',
3177efd6f3cSGeorge Liu        'yaml/interfaceaddtest/one.yaml',
3187efd6f3cSGeorge Liu    ],
319cd1e72a8SKonstantin Aladyshev    env: sdbusplus_python_env,
3207efd6f3cSGeorge Liu    output: 'interfaceaddtest.hpp',
3217efd6f3cSGeorge Liu)
3227efd6f3cSGeorge Liu
323*9c2f94e1SPatrick Williamsinterfaceaddtest_sources = [interfaceaddtest_hpp, 'interfaceaddtest.cpp']
3247efd6f3cSGeorge Liu
325*9c2f94e1SPatrick Williamstest(
326*9c2f94e1SPatrick Williams    'interfaceaddtest.cpp',
3277efd6f3cSGeorge Liu    executable(
3287efd6f3cSGeorge Liu        'interfaceaddtest',
3297efd6f3cSGeorge Liu        interfaceaddtest_sources,
3307efd6f3cSGeorge Liu        build_by_default: false,
3317efd6f3cSGeorge Liu        include_directories: ['..'],
332*9c2f94e1SPatrick Williams        dependencies: [
333*9c2f94e1SPatrick Williams            gtest_dep,
334*9c2f94e1SPatrick Williams            gmock_dep,
335*9c2f94e1SPatrick Williams            phosphor_dbus_interfaces_dep,
336*9c2f94e1SPatrick Williams            sdeventplus_dep,
337*9c2f94e1SPatrick Williams        ],
338*9c2f94e1SPatrick Williams    ),
339*9c2f94e1SPatrick Williams)
340