Andrew Jeffery | 2f20c5a | 2021-05-27 14:52:49 +0930 | [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'), |
Andrew Jeffery | ab8b045 | 2024-01-11 09:55:51 +1030 | [diff] [blame] | 11 | ], |
Andrew Jeffery | 2f20c5a | 2021-05-27 14:52:49 +0930 | [diff] [blame] | 12 | ) |
| 13 | gmock_dep = gtest_proj.dependency('gmock') |
| 14 | else |
| 15 | assert( |
Patrick Williams | 5bc307f | 2023-11-29 06:44:23 -0600 | [diff] [blame] | 16 | not get_option('tests').allowed(), |
Andrew Jeffery | ab8b045 | 2024-01-11 09:55:51 +1030 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled', |
Andrew Jeffery | 2f20c5a | 2021-05-27 14:52:49 +0930 | [diff] [blame] | 18 | ) |
| 19 | endif |
| 20 | endif |
Brad Bishop | feb19ef | 2019-11-07 18:02:16 -0500 | [diff] [blame] | 21 | |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 22 | ut_deps_list = [ |
| 23 | gtest_dep, |
| 24 | ] |
| 25 | |
| 26 | ut_deps_list += default_deps |
| 27 | |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 28 | test( |
| 29 | 'test_utils', |
| 30 | executable( |
| 31 | 'test_utils', |
| 32 | 'test_Utils.cpp', |
| 33 | '../src/Utils.cpp', |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 34 | dependencies: ut_deps_list, |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 35 | implicit_include_directories: false, |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 36 | include_directories: '../src', |
Andrew Jeffery | ab8b045 | 2024-01-11 09:55:51 +1030 | [diff] [blame] | 37 | ), |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 38 | ) |
Ed Tanous | 828c5a6 | 2024-02-09 16:59:22 -0800 | [diff] [blame] | 39 | |
| 40 | test( |
| 41 | 'test_ipmb', |
| 42 | executable( |
| 43 | 'test_ipmb', |
| 44 | '../src/IpmbSensor.cpp', |
| 45 | '../src/Utils.cpp', |
| 46 | '../src/IpmbSDRSensor.cpp', |
| 47 | 'test_IpmbSensor.cpp', |
| 48 | dependencies: ut_deps_list, |
| 49 | link_with: [ |
| 50 | utils_a, |
| 51 | thresholds_a, |
| 52 | devicemgmt_a |
| 53 | ], |
| 54 | implicit_include_directories: false, |
| 55 | include_directories: '../src', |
| 56 | ), |
| 57 | ) |