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() |
| 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 | if gtest_proj.found() |
| 11 | gtest = declare_dependency( |
| 12 | dependencies: [ |
| 13 | dependency('threads'), |
| 14 | gtest_proj.dependency('gtest'), |
| 15 | gtest_proj.dependency('gtest_main'), |
| 16 | ]) |
| 17 | gmock = gtest_proj.dependency('gmock') |
| 18 | else |
| 19 | assert(not get_option('tests').enabled(), 'Googletest is required') |
| 20 | endif |
| 21 | endif |
| 22 | |
| 23 | test('entitymap_json', |
| 24 | executable( |
| 25 | 'entitymap_json', |
| 26 | 'entitymap_json_unittest.cpp', |
| 27 | include_directories: root_inc, |
| 28 | build_by_default: false, |
| 29 | implicit_include_directories: false, |
Patrick Williams | bbc6ad4 | 2022-06-16 12:26:23 -0500 | [diff] [blame] | 30 | dependencies: [ |
| 31 | entity_map_json_dep, |
| 32 | gmock, |
| 33 | gtest, |
| 34 | nlohmann_json_dep, |
| 35 | sdbusplus_dep, |
| 36 | ] |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 37 | )) |
| 38 | |
| 39 | # Build/add oemrouter_unittest to test suite |
| 40 | # Issue #3325 |
| 41 | # test('oemrouter', |
| 42 | # executable( |
| 43 | # 'oemrouter', |
| 44 | # 'oemrouter_unittest.cpp', |
| 45 | # include_directories: root_inc, |
| 46 | # build_by_default: false, |
| 47 | # implicit_include_directories: false, |
| 48 | # dependencies: [gtest, gmock] |
| 49 | # )) |
| 50 | |
| 51 | # Build/add message packing/unpacking unit tests |
| 52 | test('message', |
| 53 | executable( |
| 54 | 'message', |
| 55 | 'message/pack.cpp', |
| 56 | 'message/payload.cpp', |
| 57 | 'message/unpack.cpp', |
| 58 | include_directories: root_inc, |
| 59 | build_by_default: false, |
| 60 | implicit_include_directories: false, |
| 61 | dependencies: [phosphor_logging_dep, crypto, systemd, sdbusplus_dep, gtest, gmock] |
| 62 | )) |
| 63 | |
| 64 | # Build/add closesession_unittest to test suite |
| 65 | test('session/closesession', |
| 66 | executable( |
| 67 | 'session_closesession', |
| 68 | 'session/closesession_unittest.cpp', |
| 69 | include_directories: root_inc, |
| 70 | build_by_default: false, |
| 71 | implicit_include_directories: false, |
| 72 | dependencies: [gtest, gmock] |
| 73 | )) |
| 74 | |
| 75 | # Build/add sensorcommands_unittest to test suite |
| 76 | test('dbus-sdr/sensorcommands', |
| 77 | executable( |
| 78 | 'dbus-sdr_sensorcommands', |
| 79 | 'dbus-sdr/sensorcommands_unittest.cpp', |
| 80 | include_directories: root_inc, |
| 81 | build_by_default: false, |
| 82 | implicit_include_directories: false, |
| 83 | dependencies: [sensorutils_dep, gtest, gmock] |
| 84 | )) |