George Liu | 07f94f0 | 2022-04-14 14:09:44 +0800 | [diff] [blame] | 1 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 3 | if 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 |
| 20 | endif |
| 21 | |
| 22 | test_sources = [ |
| 23 | generated_cpp, |
| 24 | gen_serialization_hpp, |
| 25 | '../association_manager.cpp', |
| 26 | '../manager.cpp', |
| 27 | '../functor.cpp', |
| 28 | '../errors.cpp', |
| 29 | ] |
| 30 | |
| 31 | tests = [ |
| 32 | 'associations_test.cpp', |
| 33 | 'interface_ops_test.cpp', |
| 34 | 'manager_test.cpp', |
| 35 | 'serialize_test.cpp', |
| 36 | 'types_test.cpp', |
| 37 | 'utils_test.cpp', |
| 38 | ] |
| 39 | |
| 40 | test_deps = [ |
| 41 | sdbusplus_dep, |
| 42 | phosphor_dbus_interfaces_dep, |
| 43 | phosphor_logging_dep, |
Konstantin Aladyshev | 58a0c35 | 2024-04-22 17:10:47 +0300 | [diff] [blame^] | 44 | nlohmann_json_dep, |
| 45 | cereal_dep |
George Liu | 07f94f0 | 2022-04-14 14:09:44 +0800 | [diff] [blame] | 46 | ] |
| 47 | |
| 48 | foreach t : tests |
| 49 | test(t, executable(t.underscorify(), t, |
| 50 | test_sources, |
| 51 | include_directories: ['..'], |
| 52 | dependencies: [ |
| 53 | gtest_dep, |
| 54 | gmock_dep, |
| 55 | test_deps, |
| 56 | ]), |
| 57 | workdir: meson.current_source_dir()) |
| 58 | endforeach |