Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 1 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock = dependency('gmock', disabler: true, required: false) |
| 3 | if not gtest.found() or not gmock.found() |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 4 | gtest_opts = import('cmake').subproject_options() |
| 5 | gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'}) |
| 6 | gtest_proj = import('cmake').subproject( |
| 7 | 'googletest', |
| 8 | options: gtest_opts, |
| 9 | required: false, |
| 10 | ) |
| 11 | if gtest_proj.found() |
| 12 | gtest = declare_dependency( |
| 13 | dependencies: [ |
| 14 | dependency('threads'), |
| 15 | gtest_proj.dependency('gtest'), |
| 16 | gtest_proj.dependency('gtest_main'), |
| 17 | ], |
| 18 | ) |
| 19 | gmock = gtest_proj.dependency('gmock') |
| 20 | else |
| 21 | assert(not get_option('tests').enabled(), 'Googletest is required') |
| 22 | endif |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 23 | endif |
| 24 | |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 25 | test( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 26 | 'entitymap_json', |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 27 | executable( |
| 28 | 'entitymap_json', |
| 29 | 'entitymap_json_unittest.cpp', |
| 30 | include_directories: root_inc, |
| 31 | build_by_default: false, |
| 32 | implicit_include_directories: false, |
| 33 | dependencies: [ |
| 34 | entity_map_json_dep, |
| 35 | gmock, |
| 36 | gtest, |
| 37 | nlohmann_json_dep, |
| 38 | sdbusplus_dep, |
| 39 | ], |
| 40 | ), |
| 41 | ) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 42 | |
| 43 | # Build/add oemrouter_unittest to test suite |
| 44 | # Issue #3325 |
| 45 | # test('oemrouter', |
| 46 | # executable( |
| 47 | # 'oemrouter', |
| 48 | # 'oemrouter_unittest.cpp', |
| 49 | # include_directories: root_inc, |
| 50 | # build_by_default: false, |
| 51 | # implicit_include_directories: false, |
| 52 | # dependencies: [gtest, gmock] |
| 53 | # )) |
| 54 | |
| 55 | # Build/add message packing/unpacking unit tests |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 56 | test( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 57 | 'message', |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 58 | executable( |
| 59 | 'message', |
| 60 | 'message/pack.cpp', |
| 61 | 'message/payload.cpp', |
| 62 | 'message/unpack.cpp', |
| 63 | include_directories: root_inc, |
| 64 | build_by_default: false, |
| 65 | override_options: ['b_lundef=true'], |
| 66 | implicit_include_directories: false, |
| 67 | dependencies: [ |
| 68 | boost, |
| 69 | crypto, |
| 70 | gmock, |
| 71 | gtest, |
| 72 | libsystemd_dep, |
| 73 | phosphor_logging_dep, |
| 74 | sdbusplus_dep, |
| 75 | ], |
| 76 | ), |
| 77 | ) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 78 | |
| 79 | # Build/add closesession_unittest to test suite |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 80 | test( |
| 81 | 'session/closesession', |
| 82 | executable( |
| 83 | 'session_closesession', |
| 84 | 'session/closesession_unittest.cpp', |
| 85 | include_directories: root_inc, |
| 86 | build_by_default: false, |
| 87 | implicit_include_directories: false, |
| 88 | dependencies: [gtest, gmock], |
| 89 | ), |
| 90 | ) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 91 | |
| 92 | # Build/add sensorcommands_unittest to test suite |
Patrick Williams | 62ce159 | 2025-02-03 14:12:56 -0500 | [diff] [blame] | 93 | test( |
| 94 | 'dbus-sdr/sensorcommands', |
| 95 | executable( |
| 96 | 'dbus-sdr_sensorcommands', |
| 97 | 'dbus-sdr/sensorcommands_unittest.cpp', |
| 98 | include_directories: root_inc, |
| 99 | build_by_default: false, |
| 100 | implicit_include_directories: false, |
| 101 | dependencies: [sensorutils_dep, gtest, gmock], |
| 102 | ), |
| 103 | ) |