blob: 02e45507d8d9a26c30f24828187be56cd4b0a8cb [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',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020031 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050032 'utility/tuple_to_array',
33 'utility/type_traits',
34]
35
36foreach t : tests
37 test(
38 'test_' + t.underscorify(),
39 executable(
40 'test-' + t.underscorify(),
41 t + '.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -050042 dependencies: [
43 gtest_dep,
44 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050045 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050046 ],
47 )
48 )
49endforeach
50
William A. Kennington III5e893b92020-06-04 02:47:29 -070051assert(
52 not get_option('tests').enabled() or boost_dep.found(),
53 'Boost is required when tests are enabled'
54)
55
Patrick Williamsad145e02020-05-19 16:45:15 -050056test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050057 'test-bus_aio',
58 executable(
59 'test-bus_aio',
60 'bus/aio.cpp',
61 dependencies: [
62 boost_dep,
63 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050064 gtest_dep,
65 sdbusplus_dep,
66 ],
67 )
68)
69
70test(
Patrick Williamsad145e02020-05-19 16:45:15 -050071 'test-vtable',
72 executable(
73 'test-vtable',
74 'vtable/vtable.cpp',
75 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050076 dependencies: [
77 gtest_dep,
78 sdbusplus_dep,
79 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050080 ),
81)
82
83server_buildroot = meson.current_build_dir()
84server_files = files(
85 run_command(
86 sdbusgen_prog,
87 '--tool', sdbusplusplus_prog,
88 '--output', server_buildroot,
89 'server',
90 check: true
91 ).stdout().strip().split('\n')
92)
93
94test(
95 'test-server',
96 executable(
97 'test-server',
98 'server/object.cpp',
99 server_files,
Patrick Williamsd0285b92020-06-01 09:43:47 -0500100 include_directories: include_directories('server'),
Patrick Williamsad145e02020-05-19 16:45:15 -0500101 dependencies: [
102 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500103 gtest_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -0500104 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500105 ],
106 ),
107)