blob: 0deeed8e1dee8e61085e0a330916f07542249e4c [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')
Patrick Williams8a037732021-04-19 11:42:31 -050014 else
William A. Kennington IIIadf03542020-06-04 03:01:11 -070015 assert(
16 not get_option('tests').enabled(),
17 'Googletest is required if tests are enabled'
18 )
Patrick Williams8a037732021-04-19 11:42:31 -050019 endif
William A. Kennington IIIadf03542020-06-04 03:01:11 -070020endif
Patrick Williamsad145e02020-05-19 16:45:15 -050021
22tests = [
23 'bus/list_names',
24 'bus/match',
25 'exception/sdbus_error',
26 'message/append',
William A. Kennington III472b7022021-04-15 13:13:14 -070027 'message/call',
Patrick Williamsad145e02020-05-19 16:45:15 -050028 'message/read',
29 'message/native_types',
30 'message/types',
31 'timer',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020032 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050033 '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',
Patrick Williamsad145e02020-05-19 16:45:15 -050043 dependencies: [
44 gtest_dep,
45 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050046 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050047 ],
48 )
49 )
50endforeach
51
William A. Kennington III5e893b92020-06-04 02:47:29 -070052assert(
53 not get_option('tests').enabled() or boost_dep.found(),
54 'Boost is required when tests are enabled'
55)
56
Patrick Williamsad145e02020-05-19 16:45:15 -050057test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050058 'test-bus_aio',
59 executable(
60 'test-bus_aio',
61 'bus/aio.cpp',
62 dependencies: [
63 boost_dep,
64 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050065 gtest_dep,
66 sdbusplus_dep,
67 ],
68 )
69)
70
71test(
Patrick Williamsad145e02020-05-19 16:45:15 -050072 'test-vtable',
73 executable(
74 'test-vtable',
75 'vtable/vtable.cpp',
76 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050077 dependencies: [
78 gtest_dep,
79 sdbusplus_dep,
80 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050081 ),
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,
Patrick Williamsd0285b92020-06-01 09:43:47 -0500101 include_directories: include_directories('server'),
Patrick Williamsad145e02020-05-19 16:45:15 -0500102 dependencies: [
103 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500104 gtest_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -0500105 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500106 ],
107 ),
108)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500109
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)