William A. Kennington III | adf0354 | 2020-06-04 03:01:11 -0700 | [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') |
Patrick Williams | 8a03773 | 2021-04-19 11:42:31 -0500 | [diff] [blame] | 14 | else |
William A. Kennington III | adf0354 | 2020-06-04 03:01:11 -0700 | [diff] [blame] | 15 | assert( |
| 16 | not get_option('tests').enabled(), |
| 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
Patrick Williams | 8a03773 | 2021-04-19 11:42:31 -0500 | [diff] [blame] | 19 | endif |
William A. Kennington III | adf0354 | 2020-06-04 03:01:11 -0700 | [diff] [blame] | 20 | endif |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 21 | |
| 22 | tests = [ |
Patrick Williams | 73e278b | 2022-09-16 08:31:36 -0500 | [diff] [blame] | 23 | 'async/context', |
Patrick Williams | 2f58b79 | 2022-08-26 14:07:04 -0500 | [diff] [blame] | 24 | 'async/task', |
Patrick Williams | 435eb1b | 2022-09-16 16:22:07 -0500 | [diff] [blame] | 25 | 'async/timer', |
Hannu Lounento | 90f8d9b | 2023-03-13 11:05:08 +0200 | [diff] [blame] | 26 | 'bus/exception', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 27 | 'bus/list_names', |
| 28 | 'bus/match', |
Patrick Williams | d2b0044 | 2022-09-16 08:28:07 -0500 | [diff] [blame] | 29 | 'event/event', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 30 | 'exception/sdbus_error', |
| 31 | 'message/append', |
William A. Kennington III | 472b702 | 2021-04-15 13:13:14 -0700 | [diff] [blame] | 32 | 'message/call', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 33 | 'message/native_types', |
Patrick Williams | 2f58b79 | 2022-08-26 14:07:04 -0500 | [diff] [blame] | 34 | 'message/read', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 35 | 'message/types', |
| 36 | 'timer', |
Krzysztof Grobelny | 09b88f2 | 2020-09-02 14:49:01 +0200 | [diff] [blame] | 37 | 'unpack_properties', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 38 | 'utility/tuple_to_array', |
| 39 | 'utility/type_traits', |
| 40 | ] |
| 41 | |
| 42 | foreach t : tests |
| 43 | test( |
| 44 | 'test_' + t.underscorify(), |
| 45 | executable( |
| 46 | 'test-' + t.underscorify(), |
| 47 | t + '.cpp', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 48 | dependencies: [ |
| 49 | gtest_dep, |
| 50 | gmock_dep, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 51 | sdbusplus_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 52 | ], |
| 53 | ) |
| 54 | ) |
| 55 | endforeach |
| 56 | |
William A. Kennington III | 5e893b9 | 2020-06-04 02:47:29 -0700 | [diff] [blame] | 57 | assert( |
| 58 | not get_option('tests').enabled() or boost_dep.found(), |
| 59 | 'Boost is required when tests are enabled' |
| 60 | ) |
| 61 | |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 62 | test( |
Patrick Williams | 3a6d584 | 2020-06-09 14:59:58 -0500 | [diff] [blame] | 63 | 'test-bus_aio', |
| 64 | executable( |
| 65 | 'test-bus_aio', |
| 66 | 'bus/aio.cpp', |
| 67 | dependencies: [ |
| 68 | boost_dep, |
| 69 | gmock_dep, |
Patrick Williams | 3a6d584 | 2020-06-09 14:59:58 -0500 | [diff] [blame] | 70 | gtest_dep, |
| 71 | sdbusplus_dep, |
| 72 | ], |
| 73 | ) |
| 74 | ) |
| 75 | |
| 76 | test( |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 77 | 'test-vtable', |
| 78 | executable( |
| 79 | 'test-vtable', |
| 80 | 'vtable/vtable.cpp', |
| 81 | 'vtable/vtable_c.c', |
Patrick Williams | 617e749 | 2020-06-18 09:28:38 -0500 | [diff] [blame] | 82 | dependencies: [ |
| 83 | gtest_dep, |
| 84 | sdbusplus_dep, |
| 85 | ], |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 86 | ), |
| 87 | ) |
| 88 | |
Willam A. Kennington III | ce8d16d | 2022-09-07 15:46:40 -0700 | [diff] [blame] | 89 | generated_sources = [] |
| 90 | generated_others = [] |
| 91 | subdir('gen') |
| 92 | subdir('gen/server') |
| 93 | |
| 94 | server_test_pre = declare_dependency( |
| 95 | include_directories: include_directories('gen'), |
| 96 | dependencies: sdbusplus_dep) |
| 97 | |
William A. Kennington III | 293c8a2 | 2022-09-02 14:35:54 -0700 | [diff] [blame] | 98 | server_test_lib = static_library( |
| 99 | 'server-test', |
Willam A. Kennington III | ce8d16d | 2022-09-07 15:46:40 -0700 | [diff] [blame] | 100 | generated_sources, |
| 101 | implicit_include_directories: false, |
| 102 | dependencies: server_test_pre) |
| 103 | |
| 104 | generated_sources_header = [] |
| 105 | foreach s : generated_sources |
| 106 | foreach f : s.to_list() |
| 107 | if f.full_path().endswith('.hpp') |
| 108 | generated_sources_header += f |
| 109 | endif |
| 110 | endforeach |
William A. Kennington III | 293c8a2 | 2022-09-02 14:35:54 -0700 | [diff] [blame] | 111 | endforeach |
Willam A. Kennington III | ce8d16d | 2022-09-07 15:46:40 -0700 | [diff] [blame] | 112 | |
William A. Kennington III | 293c8a2 | 2022-09-02 14:35:54 -0700 | [diff] [blame] | 113 | server_test_dep = declare_dependency( |
Willam A. Kennington III | ce8d16d | 2022-09-07 15:46:40 -0700 | [diff] [blame] | 114 | sources: generated_sources_header, |
| 115 | link_with: server_test_lib, |
| 116 | dependencies: server_test_pre) |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 117 | |
| 118 | test( |
| 119 | 'test-server', |
| 120 | executable( |
| 121 | 'test-server', |
| 122 | 'server/object.cpp', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 123 | dependencies: [ |
| 124 | gmock_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 125 | gtest_dep, |
William A. Kennington III | 293c8a2 | 2022-09-02 14:35:54 -0700 | [diff] [blame] | 126 | server_test_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 127 | ], |
| 128 | ), |
| 129 | ) |
Patrick Williams | ea56ec3 | 2021-07-14 07:41:47 -0500 | [diff] [blame] | 130 | |
| 131 | test( |
| 132 | 'test-server-message-variant', |
| 133 | executable( |
| 134 | 'test-server-message-variant', |
| 135 | 'server/message_variant.cpp', |
Patrick Williams | ea56ec3 | 2021-07-14 07:41:47 -0500 | [diff] [blame] | 136 | dependencies: [ |
| 137 | gmock_dep, |
| 138 | gtest_dep, |
William A. Kennington III | 293c8a2 | 2022-09-02 14:35:54 -0700 | [diff] [blame] | 139 | server_test_dep, |
Patrick Williams | ea56ec3 | 2021-07-14 07:41:47 -0500 | [diff] [blame] | 140 | ], |
| 141 | ), |
| 142 | ) |