Ratan Gupta | ca039ca | 2022-01-09 12:22:27 +0530 | [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( |
Patrick Williams | 90b84ad | 2023-11-29 06:44:34 -0600 | [diff] [blame^] | 16 | not get_option('tests').allowed(), |
Ratan Gupta | ca039ca | 2022-01-09 12:22:27 +0530 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
| 22 | test( |
| 23 | 'ldap_config_test', |
| 24 | executable( |
| 25 | 'ldap_config_test', |
| 26 | ['ldap_config_test.cpp', |
| 27 | 'utils_test.cpp'], |
| 28 | include_directories: '..', |
| 29 | dependencies: [ |
| 30 | gtest_dep, |
| 31 | gmock_dep, |
| 32 | phosphor_ldap_conf_dep, |
| 33 | ], |
| 34 | link_args: ['-lldap'], |
| 35 | ), |
| 36 | ) |
| 37 | |
| 38 | test( |
Ratan Gupta | ca039ca | 2022-01-09 12:22:27 +0530 | [diff] [blame] | 39 | 'user_mgr_test', |
| 40 | executable( |
| 41 | 'user_mgr_test', |
| 42 | 'user_mgr_test.cpp', |
| 43 | include_directories: '..', |
| 44 | dependencies: [ |
| 45 | gtest_dep, |
| 46 | gmock_dep, |
| 47 | user_manager_dep, |
| 48 | ], |
| 49 | ), |
| 50 | ) |