xref: /openbmc/sdbusplus/test/meson.build (revision 74eea5191eb7a37272ebfc68cc775fa6d289d7f5)
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    'async/context',
24    'async/task',
25    'async/timer',
26    'async/fdio',
27    'bus/exception',
28    'bus/list_names',
29    'bus/match',
30    'event/event',
31    'exception/sdbus_error',
32    'message/append',
33    'message/call',
34    'message/native_types',
35    'message/read',
36    'message/types',
37    'timer',
38    'unpack_properties',
39    'utility/tuple_to_array',
40    'utility/type_traits',
41]
42
43foreach t : tests
44    test(
45        'test_' + t.underscorify(),
46        executable(
47            'test-' + t.underscorify(),
48            t + '.cpp',
49            dependencies: [
50                gtest_dep,
51                gmock_dep,
52                sdbusplus_dep,
53            ],
54        )
55    )
56endforeach
57
58assert(
59    not get_option('tests').allowed() or boost_dep.found(),
60    'Boost is required when tests are enabled'
61)
62
63test(
64    'test-bus_aio',
65    executable(
66        'test-bus_aio',
67        'bus/aio.cpp',
68        dependencies: [
69            boost_dep,
70            gmock_dep,
71            gtest_dep,
72            sdbusplus_dep,
73        ],
74    )
75)
76
77test(
78    'test-vtable',
79    executable(
80        'test-vtable',
81        'vtable/vtable.cpp',
82        'vtable/vtable_c.c',
83        dependencies: [
84            gtest_dep,
85            sdbusplus_dep,
86        ],
87    ),
88)
89
90yaml_selected_subdirs = ['server']
91subdir('gen')
92
93server_test_pre = declare_dependency(
94    include_directories: include_directories('gen'),
95    dependencies: sdbusplus_dep)
96
97server_test_lib = static_library(
98    'server-test',
99    generated_sources,
100    implicit_include_directories: false,
101    dependencies: server_test_pre)
102
103server_test_dep = declare_dependency(
104  sources: generated_headers,
105  link_with: server_test_lib,
106  dependencies: server_test_pre)
107
108test(
109    'test-server',
110    executable(
111        'test-server',
112        'server/object.cpp',
113        dependencies: [
114            gmock_dep,
115            gtest_dep,
116            server_test_dep,
117        ],
118    ),
119)
120
121test(
122    'test-server-message-variant',
123    executable(
124        'test-server-message-variant',
125        'server/message_variant.cpp',
126        dependencies: [
127            gmock_dep,
128            gtest_dep,
129            server_test_dep,
130        ],
131    ),
132)
133