blob: 4d3114c7fafd516763800312444079ee4d19288b [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 Williams2f58b792022-08-26 14:07:04 -050023 'async/task',
Patrick Williamsad145e02020-05-19 16:45:15 -050024 'bus/list_names',
25 'bus/match',
26 'exception/sdbus_error',
27 'message/append',
William A. Kennington III472b7022021-04-15 13:13:14 -070028 'message/call',
Patrick Williamsad145e02020-05-19 16:45:15 -050029 'message/native_types',
Patrick Williams2f58b792022-08-26 14:07:04 -050030 'message/read',
Patrick Williamsad145e02020-05-19 16:45:15 -050031 'message/types',
32 'timer',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020033 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050034 'utility/tuple_to_array',
35 'utility/type_traits',
36]
37
38foreach t : tests
39 test(
40 'test_' + t.underscorify(),
41 executable(
42 'test-' + t.underscorify(),
43 t + '.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -050044 dependencies: [
45 gtest_dep,
46 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050047 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050048 ],
49 )
50 )
51endforeach
52
William A. Kennington III5e893b92020-06-04 02:47:29 -070053assert(
54 not get_option('tests').enabled() or boost_dep.found(),
55 'Boost is required when tests are enabled'
56)
57
Patrick Williamsad145e02020-05-19 16:45:15 -050058test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050059 'test-bus_aio',
60 executable(
61 'test-bus_aio',
62 'bus/aio.cpp',
63 dependencies: [
64 boost_dep,
65 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050066 gtest_dep,
67 sdbusplus_dep,
68 ],
69 )
70)
71
72test(
Patrick Williamsad145e02020-05-19 16:45:15 -050073 'test-vtable',
74 executable(
75 'test-vtable',
76 'vtable/vtable.cpp',
77 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050078 dependencies: [
79 gtest_dep,
80 sdbusplus_dep,
81 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050082 ),
83)
84
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070085generated_sources = []
86generated_others = []
87subdir('gen')
88subdir('gen/server')
89
90server_test_pre = declare_dependency(
91 include_directories: include_directories('gen'),
92 dependencies: sdbusplus_dep)
93
William A. Kennington III293c8a22022-09-02 14:35:54 -070094server_test_lib = static_library(
95 'server-test',
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070096 generated_sources,
97 implicit_include_directories: false,
98 dependencies: server_test_pre)
99
100generated_sources_header = []
101foreach s : generated_sources
102 foreach f : s.to_list()
103 if f.full_path().endswith('.hpp')
104 generated_sources_header += f
105 endif
106 endforeach
William A. Kennington III293c8a22022-09-02 14:35:54 -0700107endforeach
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700108
William A. Kennington III293c8a22022-09-02 14:35:54 -0700109server_test_dep = declare_dependency(
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700110 sources: generated_sources_header,
111 link_with: server_test_lib,
112 dependencies: server_test_pre)
Patrick Williamsad145e02020-05-19 16:45:15 -0500113
114test(
115 'test-server',
116 executable(
117 'test-server',
118 'server/object.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -0500119 dependencies: [
120 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500121 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700122 server_test_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500123 ],
124 ),
125)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500126
127test(
128 'test-server-message-variant',
129 executable(
130 'test-server-message-variant',
131 'server/message_variant.cpp',
Patrick Williamsea56ec32021-07-14 07:41:47 -0500132 dependencies: [
133 gmock_dep,
134 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700135 server_test_dep,
Patrick Williamsea56ec32021-07-14 07:41:47 -0500136 ],
137 ),
138)