blob: 01817668c1aca92b9e39591f9d2e277d0fdbb26a [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 = [
Patrick Williams73e278b2022-09-16 08:31:36 -050023 'async/context',
Patrick Williams2f58b792022-08-26 14:07:04 -050024 'async/task',
Patrick Williams435eb1b2022-09-16 16:22:07 -050025 'async/timer',
Patrick Williamsad145e02020-05-19 16:45:15 -050026 'bus/list_names',
27 'bus/match',
Patrick Williamsd2b00442022-09-16 08:28:07 -050028 'event/event',
Patrick Williamsad145e02020-05-19 16:45:15 -050029 'exception/sdbus_error',
30 'message/append',
William A. Kennington III472b7022021-04-15 13:13:14 -070031 'message/call',
Patrick Williamsad145e02020-05-19 16:45:15 -050032 'message/native_types',
Patrick Williams2f58b792022-08-26 14:07:04 -050033 'message/read',
Patrick Williamsad145e02020-05-19 16:45:15 -050034 'message/types',
35 'timer',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020036 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050037 'utility/tuple_to_array',
38 'utility/type_traits',
39]
40
41foreach t : tests
42 test(
43 'test_' + t.underscorify(),
44 executable(
45 'test-' + t.underscorify(),
46 t + '.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -050047 dependencies: [
48 gtest_dep,
49 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050050 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050051 ],
52 )
53 )
54endforeach
55
William A. Kennington III5e893b92020-06-04 02:47:29 -070056assert(
57 not get_option('tests').enabled() or boost_dep.found(),
58 'Boost is required when tests are enabled'
59)
60
Patrick Williamsad145e02020-05-19 16:45:15 -050061test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050062 'test-bus_aio',
63 executable(
64 'test-bus_aio',
65 'bus/aio.cpp',
66 dependencies: [
67 boost_dep,
68 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050069 gtest_dep,
70 sdbusplus_dep,
71 ],
72 )
73)
74
75test(
Patrick Williamsad145e02020-05-19 16:45:15 -050076 'test-vtable',
77 executable(
78 'test-vtable',
79 'vtable/vtable.cpp',
80 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050081 dependencies: [
82 gtest_dep,
83 sdbusplus_dep,
84 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050085 ),
86)
87
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070088generated_sources = []
89generated_others = []
90subdir('gen')
91subdir('gen/server')
92
93server_test_pre = declare_dependency(
94 include_directories: include_directories('gen'),
95 dependencies: sdbusplus_dep)
96
William A. Kennington III293c8a22022-09-02 14:35:54 -070097server_test_lib = static_library(
98 'server-test',
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070099 generated_sources,
100 implicit_include_directories: false,
101 dependencies: server_test_pre)
102
103generated_sources_header = []
104foreach s : generated_sources
105 foreach f : s.to_list()
106 if f.full_path().endswith('.hpp')
107 generated_sources_header += f
108 endif
109 endforeach
William A. Kennington III293c8a22022-09-02 14:35:54 -0700110endforeach
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700111
William A. Kennington III293c8a22022-09-02 14:35:54 -0700112server_test_dep = declare_dependency(
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700113 sources: generated_sources_header,
114 link_with: server_test_lib,
115 dependencies: server_test_pre)
Patrick Williamsad145e02020-05-19 16:45:15 -0500116
117test(
118 'test-server',
119 executable(
120 'test-server',
121 'server/object.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -0500122 dependencies: [
123 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500124 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700125 server_test_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500126 ],
127 ),
128)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500129
130test(
131 'test-server-message-variant',
132 executable(
133 'test-server-message-variant',
134 'server/message_variant.cpp',
Patrick Williamsea56ec32021-07-14 07:41:47 -0500135 dependencies: [
136 gmock_dep,
137 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700138 server_test_dep,
Patrick Williamsea56ec32021-07-14 07:41:47 -0500139 ],
140 ),
141)