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'], 4531058fd3SJosh Lehan 'pid_json_unittest': ['../pid/buildjson.cpp', 4631058fd3SJosh Lehan '../util.cpp'], 47b1225b26SHarvey.Wu 'pid_fancontroller_unittest': ['../pid/ec/pid.cpp', 48de74542cSJosh Lehan '../pid/ec/logging.cpp', 49b1225b26SHarvey.Wu '../pid/fancontroller.cpp', 50b1225b26SHarvey.Wu '../pid/pidcontroller.cpp', 51b1225b26SHarvey.Wu '../pid/tuning.cpp', 52b1225b26SHarvey.Wu '../pid/util.cpp'], 53b1225b26SHarvey.Wu 'pid_stepwisecontroller_unittest': ['../pid/ec/stepwise.cpp', 54b1225b26SHarvey.Wu '../pid/stepwisecontroller.cpp', 555d678da3SJosh Lehan '../pid/tuning.cpp', 56b1225b26SHarvey.Wu '../pid/util.cpp'], 57b1225b26SHarvey.Wu 'pid_thermalcontroller_unittest': ['../pid/ec/pid.cpp', 58de74542cSJosh Lehan '../pid/ec/logging.cpp', 59b1225b26SHarvey.Wu '../pid/pidcontroller.cpp', 60b1225b26SHarvey.Wu '../pid/thermalcontroller.cpp', 61b1225b26SHarvey.Wu '../pid/tuning.cpp', 62b1225b26SHarvey.Wu '../pid/util.cpp'], 63b1225b26SHarvey.Wu 'pid_zone_unittest': ['../pid/ec/pid.cpp', 64de74542cSJosh Lehan '../pid/ec/logging.cpp', 65b1225b26SHarvey.Wu '../pid/pidcontroller.cpp', 66b1225b26SHarvey.Wu '../pid/tuning.cpp', 67b1225b26SHarvey.Wu '../pid/zone.cpp', 68b1225b26SHarvey.Wu '../sensors/manager.cpp'], 69b1225b26SHarvey.Wu 'sensor_host_unittest': ['../sensors/host.cpp'], 70b1225b26SHarvey.Wu 'sensor_manager_unittest': ['../sensors/manager.cpp'], 71b1225b26SHarvey.Wu 'sensor_pluggable_unittest': ['../sensors/pluggable.cpp'], 72b1225b26SHarvey.Wu 'sensors_json_unittest': ['../sensors/buildjson.cpp'], 73b1225b26SHarvey.Wu 'util_unittest': ['../sensors/build_utils.cpp'] 74b1225b26SHarvey.Wu} 75b1225b26SHarvey.Wu 76b1225b26SHarvey.Wuforeach t : unit_tests 77b1225b26SHarvey.Wu test(t, executable(t.underscorify(), t + '.cpp', 78b1225b26SHarvey.Wu unittest_source.get(t), 79b1225b26SHarvey.Wu include_directories: [ 80b1225b26SHarvey.Wu swampd_sources, 81b1225b26SHarvey.Wu ], 82b1225b26SHarvey.Wu link_args: dynamic_linker, 83*397e6bcbSPatrick Williams build_rpath: get_option('oe-sdk').allowed() ? rpath : '', 84b1225b26SHarvey.Wu dependencies: [ 85b1225b26SHarvey.Wu gtest, 86b1225b26SHarvey.Wu gmock, 87b1225b26SHarvey.Wu deps, 88b1225b26SHarvey.Wu ])) 89b1225b26SHarvey.Wuendforeach 90