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