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/read', 28 'message/native_types', 29 'message/types', 30 'timer', 31 'utility/tuple_to_array', 32 'utility/type_traits', 33] 34 35foreach t : tests 36 test( 37 'test_' + t.underscorify(), 38 executable( 39 'test-' + t.underscorify(), 40 t + '.cpp', 41 dependencies: [ 42 gtest_dep, 43 gmock_dep, 44 sdbusplus_dep, 45 ], 46 ) 47 ) 48endforeach 49 50assert( 51 not get_option('tests').enabled() or boost_dep.found(), 52 'Boost is required when tests are enabled' 53) 54 55test( 56 'test-bus_aio', 57 executable( 58 'test-bus_aio', 59 'bus/aio.cpp', 60 dependencies: [ 61 boost_dep, 62 gmock_dep, 63 gtest_dep, 64 sdbusplus_dep, 65 ], 66 ) 67) 68 69test( 70 'test-vtable', 71 executable( 72 'test-vtable', 73 'vtable/vtable.cpp', 74 'vtable/vtable_c.c', 75 dependencies: [ 76 gtest_dep, 77 sdbusplus_dep, 78 ], 79 ), 80) 81 82server_buildroot = meson.current_build_dir() 83server_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 93test( 94 'test-server', 95 executable( 96 'test-server', 97 'server/object.cpp', 98 server_files, 99 include_directories: include_directories('server'), 100 dependencies: [ 101 gmock_dep, 102 gtest_dep, 103 sdbusplus_dep, 104 ], 105 ), 106) 107