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 | |
| 84 | server_buildroot = meson.current_build_dir() |
| 85 | server_files = files( |
| 86 | run_command( |
| 87 | sdbusgen_prog, |
| 88 | '--tool', sdbusplusplus_prog, |
| 89 | '--output', server_buildroot, |
| 90 | 'server', |
| 91 | check: true |
| 92 | ).stdout().strip().split('\n') |
| 93 | ) |
| 94 | |
| 95 | test( |
| 96 | 'test-server', |
| 97 | executable( |
| 98 | 'test-server', |
| 99 | 'server/object.cpp', |
| 100 | server_files, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 101 | include_directories: include_directories('server'), |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 102 | dependencies: [ |
| 103 | gmock_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 104 | gtest_dep, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 105 | sdbusplus_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 106 | ], |
| 107 | ), |
| 108 | ) |
Patrick Williams | ea56ec3 | 2021-07-14 07:41:47 -0500 | [diff] [blame] | 109 | |
| 110 | test( |
| 111 | 'test-server-message-variant', |
| 112 | executable( |
| 113 | 'test-server-message-variant', |
| 114 | 'server/message_variant.cpp', |
| 115 | server_files, |
| 116 | include_directories: include_directories('server'), |
| 117 | dependencies: [ |
| 118 | gmock_dep, |
| 119 | gtest_dep, |
| 120 | sdbusplus_dep, |
| 121 | ], |
| 122 | ), |
| 123 | ) |