1gtest_dep = dependency('gtest', main: true, disabler: true, required: false) 2gmock_dep = dependency('gmock', disabler: true, required: false) 3if 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 20endif 21 22tests = [ 23 'bus/list_names', 24 'bus/match', 25 'exception/sdbus_error', 26 'message/append', 27 'message/call', 28 'message/read', 29 'message/native_types', 30 'message/types', 31 'timer', 32 'unpack_properties', 33 'utility/tuple_to_array', 34 'utility/type_traits', 35] 36 37foreach t : tests 38 test( 39 'test_' + t.underscorify(), 40 executable( 41 'test-' + t.underscorify(), 42 t + '.cpp', 43 dependencies: [ 44 gtest_dep, 45 gmock_dep, 46 sdbusplus_dep, 47 ], 48 ) 49 ) 50endforeach 51 52assert( 53 not get_option('tests').enabled() or boost_dep.found(), 54 'Boost is required when tests are enabled' 55) 56 57test( 58 'test-bus_aio', 59 executable( 60 'test-bus_aio', 61 'bus/aio.cpp', 62 dependencies: [ 63 boost_dep, 64 gmock_dep, 65 gtest_dep, 66 sdbusplus_dep, 67 ], 68 ) 69) 70 71test( 72 'test-vtable', 73 executable( 74 'test-vtable', 75 'vtable/vtable.cpp', 76 'vtable/vtable_c.c', 77 dependencies: [ 78 gtest_dep, 79 sdbusplus_dep, 80 ], 81 ), 82) 83 84server_buildroot = meson.current_build_dir() 85server_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 95test( 96 'test-server', 97 executable( 98 'test-server', 99 'server/object.cpp', 100 server_files, 101 include_directories: include_directories('server'), 102 dependencies: [ 103 gmock_dep, 104 gtest_dep, 105 sdbusplus_dep, 106 ], 107 ), 108) 109 110test( 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) 124