xref: /openbmc/phosphor-pid-control/test/meson.build (revision 5d678da3d692c37fbf4900f7f60d8bff2f097b16)
1b1225b26SHarvey.Wugtest = dependency('gtest', main: true, disabler: true, required: false)
2b1225b26SHarvey.Wugmock = dependency('gmock', disabler: true, required: false)
3b1225b26SHarvey.Wu
4b1225b26SHarvey.Wuif not gtest.found() or not gmock.found()
5b1225b26SHarvey.Wu    gtest_proj = import('cmake').subproject('googletest', required: false)
6b1225b26SHarvey.Wu    if gtest_proj.found()
7b1225b26SHarvey.Wu        gtest = declare_dependency(
8b1225b26SHarvey.Wu        dependencies: [
9b1225b26SHarvey.Wu            dependency('threads'),
10b1225b26SHarvey.Wu            gtest_proj.dependency('gtest'),
11b1225b26SHarvey.Wu            gtest_proj.dependency('gtest_main'),
12b1225b26SHarvey.Wu        ])
13b1225b26SHarvey.Wu        gmock = gtest_proj.dependency('gmock')
14b1225b26SHarvey.Wu    else
15b1225b26SHarvey.Wu        assert(not get_option('tests').enabled(), 'Googletest is required')
16b1225b26SHarvey.Wu    endif
17b1225b26SHarvey.Wuendif
18b1225b26SHarvey.Wu
19b1225b26SHarvey.Wuswampd_sources = include_directories('../')
20b1225b26SHarvey.Wu
21b1225b26SHarvey.Wuunit_tests = [
22b1225b26SHarvey.Wu    'dbus_active_unittest',
23b1225b26SHarvey.Wu    'dbus_passive_unittest',
24b1225b26SHarvey.Wu    'dbus_util_unittest',
25b1225b26SHarvey.Wu    'json_parse_unittest',
26b1225b26SHarvey.Wu    'pid_json_unittest',
27b1225b26SHarvey.Wu    'pid_fancontroller_unittest',
28b1225b26SHarvey.Wu    'pid_stepwisecontroller_unittest',
29b1225b26SHarvey.Wu    'pid_thermalcontroller_unittest',
30b1225b26SHarvey.Wu    'pid_zone_unittest',
31b1225b26SHarvey.Wu    'sensor_host_unittest',
32b1225b26SHarvey.Wu    'sensor_manager_unittest',
33b1225b26SHarvey.Wu    'sensor_pluggable_unittest',
34b1225b26SHarvey.Wu    'sensors_json_unittest',
35b1225b26SHarvey.Wu    'util_unittest',
36b1225b26SHarvey.Wu]
37b1225b26SHarvey.Wu
38b1225b26SHarvey.Wuunittest_source = {
39b1225b26SHarvey.Wu    'dbus_active_unittest': ['../dbus/dbusactiveread.cpp'],
40b1225b26SHarvey.Wu    'dbus_passive_unittest': ['../dbus/dbuspassive.cpp',
41b1225b26SHarvey.Wu                              '../dbus/dbuspassiveredundancy.cpp',
42b1225b26SHarvey.Wu                              '../dbus/dbusutil.cpp'],
43b1225b26SHarvey.Wu    'dbus_util_unittest': ['../dbus/dbusutil.cpp'],
44b1225b26SHarvey.Wu    'json_parse_unittest': ['../buildjson/buildjson.cpp'],
45b1225b26SHarvey.Wu    'pid_json_unittest': ['../pid/buildjson.cpp'],
46b1225b26SHarvey.Wu    'pid_fancontroller_unittest': ['../pid/ec/pid.cpp',
47b1225b26SHarvey.Wu                                   '../pid/fancontroller.cpp',
48b1225b26SHarvey.Wu                                   '../pid/pidcontroller.cpp',
49b1225b26SHarvey.Wu                                   '../pid/tuning.cpp',
50b1225b26SHarvey.Wu                                   '../pid/util.cpp'],
51b1225b26SHarvey.Wu    'pid_stepwisecontroller_unittest': ['../pid/ec/stepwise.cpp',
52b1225b26SHarvey.Wu                                        '../pid/stepwisecontroller.cpp',
53*5d678da3SJosh Lehan                                        '../pid/tuning.cpp',
54b1225b26SHarvey.Wu                                        '../pid/util.cpp'],
55b1225b26SHarvey.Wu    'pid_thermalcontroller_unittest': ['../pid/ec/pid.cpp',
56b1225b26SHarvey.Wu                                       '../pid/pidcontroller.cpp',
57b1225b26SHarvey.Wu                                       '../pid/thermalcontroller.cpp',
58b1225b26SHarvey.Wu                                       '../pid/tuning.cpp',
59b1225b26SHarvey.Wu                                       '../pid/util.cpp'],
60b1225b26SHarvey.Wu    'pid_zone_unittest': ['../pid/ec/pid.cpp',
61b1225b26SHarvey.Wu                          '../pid/pidcontroller.cpp',
62b1225b26SHarvey.Wu                          '../pid/tuning.cpp',
63b1225b26SHarvey.Wu                          '../pid/zone.cpp',
64b1225b26SHarvey.Wu                          '../sensors/manager.cpp'],
65b1225b26SHarvey.Wu    'sensor_host_unittest': ['../sensors/host.cpp'],
66b1225b26SHarvey.Wu    'sensor_manager_unittest': ['../sensors/manager.cpp'],
67b1225b26SHarvey.Wu    'sensor_pluggable_unittest': ['../sensors/pluggable.cpp'],
68b1225b26SHarvey.Wu    'sensors_json_unittest': ['../sensors/buildjson.cpp'],
69b1225b26SHarvey.Wu    'util_unittest': ['../sensors/build_utils.cpp']
70b1225b26SHarvey.Wu}
71b1225b26SHarvey.Wu
72b1225b26SHarvey.Wuforeach t : unit_tests
73b1225b26SHarvey.Wu    test(t, executable(t.underscorify(), t + '.cpp',
74b1225b26SHarvey.Wu                       unittest_source.get(t),
75b1225b26SHarvey.Wu                       include_directories: [
76b1225b26SHarvey.Wu                           swampd_sources,
77b1225b26SHarvey.Wu                       ],
78b1225b26SHarvey.Wu                       link_args: dynamic_linker,
79b1225b26SHarvey.Wu                       build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
80b1225b26SHarvey.Wu                       dependencies: [
81b1225b26SHarvey.Wu                           gtest,
82b1225b26SHarvey.Wu                           gmock,
83b1225b26SHarvey.Wu                           deps,
84b1225b26SHarvey.Wu                       ]))
85b1225b26SHarvey.Wuendforeach
86