xref: /openbmc/sdbusplus/test/meson.build (revision fcff6763)
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
22tests = [
23    'bus/list_names',
24    'bus/match',
25    'exception/sdbus_error',
26    'message/append',
27    'message/read',
28    'message/native_types',
29    'message/types',
30    'timer',
31    'unpack_properties',
32    'utility/tuple_to_array',
33    'utility/type_traits',
34]
35
36foreach t : tests
37    test(
38        'test_' + t.underscorify(),
39        executable(
40            'test-' + t.underscorify(),
41            t + '.cpp',
42            dependencies: [
43                gtest_dep,
44                gmock_dep,
45                sdbusplus_dep,
46            ],
47        )
48    )
49endforeach
50
51assert(
52    not get_option('tests').enabled() or boost_dep.found(),
53    'Boost is required when tests are enabled'
54)
55
56test(
57    'test-bus_aio',
58    executable(
59        'test-bus_aio',
60        'bus/aio.cpp',
61        dependencies: [
62            boost_dep,
63            gmock_dep,
64            gtest_dep,
65            sdbusplus_dep,
66        ],
67    )
68)
69
70test(
71    'test-vtable',
72    executable(
73        'test-vtable',
74        'vtable/vtable.cpp',
75        'vtable/vtable_c.c',
76        dependencies: [
77            gtest_dep,
78            sdbusplus_dep,
79        ],
80    ),
81)
82
83server_buildroot = meson.current_build_dir()
84server_files = files(
85    run_command(
86        sdbusgen_prog,
87        '--tool', sdbusplusplus_prog,
88        '--output', server_buildroot,
89        'server',
90        check: true
91    ).stdout().strip().split('\n')
92)
93
94test(
95    'test-server',
96    executable(
97        'test-server',
98        'server/object.cpp',
99        server_files,
100        include_directories: include_directories('server'),
101        dependencies: [
102            gmock_dep,
103            gtest_dep,
104            sdbusplus_dep,
105        ],
106    ),
107)
108