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') |
| 14 | else |
| 15 | assert( |
| 16 | not get_option('tests').enabled(), |
| 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 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', |
| 27 | 'message/read', |
| 28 | 'message/native_types', |
| 29 | 'message/types', |
| 30 | 'timer', |
| 31 | 'utility/tuple_to_array', |
| 32 | 'utility/type_traits', |
| 33 | ] |
| 34 | |
| 35 | foreach t : tests |
| 36 | test( |
| 37 | 'test_' + t.underscorify(), |
| 38 | executable( |
| 39 | 'test-' + t.underscorify(), |
| 40 | t + '.cpp', |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 41 | dependencies: [ |
| 42 | gtest_dep, |
| 43 | gmock_dep, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 44 | sdbusplus_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 45 | ], |
| 46 | ) |
| 47 | ) |
| 48 | endforeach |
| 49 | |
William A. Kennington III | 5e893b9 | 2020-06-04 02:47:29 -0700 | [diff] [blame] | 50 | assert( |
| 51 | not get_option('tests').enabled() or boost_dep.found(), |
| 52 | 'Boost is required when tests are enabled' |
| 53 | ) |
| 54 | |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 55 | test( |
Patrick Williams | 3a6d584 | 2020-06-09 14:59:58 -0500 | [diff] [blame] | 56 | 'test-bus_aio', |
| 57 | executable( |
| 58 | 'test-bus_aio', |
| 59 | 'bus/aio.cpp', |
| 60 | dependencies: [ |
| 61 | boost_dep, |
| 62 | gmock_dep, |
Patrick Williams | 3a6d584 | 2020-06-09 14:59:58 -0500 | [diff] [blame] | 63 | gtest_dep, |
| 64 | sdbusplus_dep, |
| 65 | ], |
| 66 | ) |
| 67 | ) |
| 68 | |
| 69 | test( |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 70 | 'test-vtable', |
| 71 | executable( |
| 72 | 'test-vtable', |
| 73 | 'vtable/vtable.cpp', |
| 74 | 'vtable/vtable_c.c', |
Patrick Williams | 617e749 | 2020-06-18 09:28:38 -0500 | [diff] [blame] | 75 | dependencies: [ |
| 76 | gtest_dep, |
| 77 | sdbusplus_dep, |
| 78 | ], |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 79 | ), |
| 80 | ) |
| 81 | |
| 82 | server_buildroot = meson.current_build_dir() |
| 83 | server_files = files( |
| 84 | run_command( |
| 85 | sdbusgen_prog, |
| 86 | '--tool', sdbusplusplus_prog, |
| 87 | '--output', server_buildroot, |
| 88 | 'server', |
| 89 | check: true |
| 90 | ).stdout().strip().split('\n') |
| 91 | ) |
| 92 | |
| 93 | test( |
| 94 | 'test-server', |
| 95 | executable( |
| 96 | 'test-server', |
| 97 | 'server/object.cpp', |
| 98 | server_files, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 99 | include_directories: include_directories('server'), |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 100 | dependencies: [ |
| 101 | gmock_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 102 | gtest_dep, |
Patrick Williams | d0285b9 | 2020-06-01 09:43:47 -0500 | [diff] [blame] | 103 | sdbusplus_dep, |
Patrick Williams | ad145e0 | 2020-05-19 16:45:15 -0500 | [diff] [blame] | 104 | ], |
| 105 | ), |
| 106 | ) |