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