blob: 374dada2be3efd1a4847fe898677f3ac0c94c6d4 [file] [log] [blame]
William A. Kennington IIIadf03542020-06-04 03:01:11 -07001gtest_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
Patrick Williamsad145e02020-05-19 16:45:15 -050021
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',
Patrick Williamsad145e02020-05-19 16:45:15 -050041 dependencies: [
42 gtest_dep,
43 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050044 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050045 ],
46 )
47 )
48endforeach
49
William A. Kennington III5e893b92020-06-04 02:47:29 -070050assert(
51 not get_option('tests').enabled() or boost_dep.found(),
52 'Boost is required when tests are enabled'
53)
54
Patrick Williamsad145e02020-05-19 16:45:15 -050055test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050056 'test-bus_aio',
57 executable(
58 'test-bus_aio',
59 'bus/aio.cpp',
60 dependencies: [
61 boost_dep,
62 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050063 gtest_dep,
64 sdbusplus_dep,
65 ],
66 )
67)
68
69test(
Patrick Williamsad145e02020-05-19 16:45:15 -050070 'test-vtable',
71 executable(
72 'test-vtable',
73 'vtable/vtable.cpp',
74 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050075 dependencies: [
76 gtest_dep,
77 sdbusplus_dep,
78 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050079 ),
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,
Patrick Williamsd0285b92020-06-01 09:43:47 -050099 include_directories: include_directories('server'),
Patrick Williamsad145e02020-05-19 16:45:15 -0500100 dependencies: [
101 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500102 gtest_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -0500103 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500104 ],
105 ),
106)