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