blob: 4fa39d236004fdab2f47db4a68c9a0f4ef7fa217 [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
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070084generated_sources = []
85generated_others = []
86subdir('gen')
87subdir('gen/server')
88
89server_test_pre = declare_dependency(
90 include_directories: include_directories('gen'),
91 dependencies: sdbusplus_dep)
92
William A. Kennington III293c8a22022-09-02 14:35:54 -070093server_test_lib = static_library(
94 'server-test',
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070095 generated_sources,
96 implicit_include_directories: false,
97 dependencies: server_test_pre)
98
99generated_sources_header = []
100foreach s : generated_sources
101 foreach f : s.to_list()
102 if f.full_path().endswith('.hpp')
103 generated_sources_header += f
104 endif
105 endforeach
William A. Kennington III293c8a22022-09-02 14:35:54 -0700106endforeach
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700107
William A. Kennington III293c8a22022-09-02 14:35:54 -0700108server_test_dep = declare_dependency(
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700109 sources: generated_sources_header,
110 link_with: server_test_lib,
111 dependencies: server_test_pre)
Patrick Williamsad145e02020-05-19 16:45:15 -0500112
113test(
114 'test-server',
115 executable(
116 'test-server',
117 'server/object.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -0500118 dependencies: [
119 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500120 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700121 server_test_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500122 ],
123 ),
124)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500125
126test(
127 'test-server-message-variant',
128 executable(
129 'test-server-message-variant',
130 'server/message_variant.cpp',
Patrick Williamsea56ec32021-07-14 07:41:47 -0500131 dependencies: [
132 gmock_dep,
133 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700134 server_test_dep,
Patrick Williamsea56ec32021-07-14 07:41:47 -0500135 ],
136 ),
137)