xref: /openbmc/dbus-sensors/src/tests/meson.build (revision 275f7c39190bab69efa11218b68587e8955cc588)
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').allowed(),
17            'Googletest is required if tests are enabled',
18        )
19    endif
20endif
21
22ut_deps_list = [
23    gtest_dep,
24]
25
26ut_deps_list += default_deps
27src_inc = include_directories('..')
28
29test(
30    'test_utils',
31    executable(
32        'test_utils',
33        'test_Utils.cpp',
34        '../Utils.cpp',
35        dependencies: ut_deps_list,
36        implicit_include_directories: false,
37        include_directories: src_inc,
38    ),
39)
40
41test(
42    'test_ipmb',
43    executable(
44        'test_ipmb',
45        '../ipmb/IpmbSensor.cpp',
46        '../Utils.cpp',
47        '../ipmb/IpmbSDRSensor.cpp',
48        'test_IpmbSensor.cpp',
49        dependencies: ut_deps_list,
50        link_with: [
51            utils_a,
52            thresholds_a,
53            devicemgmt_a
54        ],
55        implicit_include_directories: false,
56        include_directories: src_inc,
57    ),
58)
59
60test(
61    'MCTPReactor',
62    executable(
63        'test_MCTPReactor',
64        'test_MCTPReactor.cpp',
65        '../mctp/MCTPReactor.cpp',
66        '../mctp/MCTPEndpoint.cpp',
67        dependencies: [ gmock_dep, ut_deps_list, utils_dep ],
68        implicit_include_directories: false,
69        include_directories: '../mctp'
70    )
71)
72
73test(
74    'MCTPEndpoint',
75    executable(
76        'test_MCTPEndpoint',
77        'test_MCTPEndpoint.cpp',
78        '../mctp/MCTPEndpoint.cpp',
79        dependencies: [ gmock_dep, ut_deps_list, utils_dep ],
80        implicit_include_directories: false,
81        include_directories: '../mctp'
82    )
83)
84