blob: c2e937a914c9b6785b26fd3b4265060023cacf3f [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 Williamsad145e02020-05-19 16:45:15 -050025 'bus/list_names',
26 'bus/match',
Patrick Williamsd2b00442022-09-16 08:28:07 -050027 'event/event',
Patrick Williamsad145e02020-05-19 16:45:15 -050028 'exception/sdbus_error',
29 'message/append',
William A. Kennington III472b7022021-04-15 13:13:14 -070030 'message/call',
Patrick Williamsad145e02020-05-19 16:45:15 -050031 'message/native_types',
Patrick Williams2f58b792022-08-26 14:07:04 -050032 'message/read',
Patrick Williamsad145e02020-05-19 16:45:15 -050033 'message/types',
34 'timer',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020035 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050036 'utility/tuple_to_array',
37 'utility/type_traits',
38]
39
40foreach t : tests
41 test(
42 'test_' + t.underscorify(),
43 executable(
44 'test-' + t.underscorify(),
45 t + '.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -050046 dependencies: [
47 gtest_dep,
48 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050049 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050050 ],
51 )
52 )
53endforeach
54
William A. Kennington III5e893b92020-06-04 02:47:29 -070055assert(
56 not get_option('tests').enabled() or boost_dep.found(),
57 'Boost is required when tests are enabled'
58)
59
Patrick Williamsad145e02020-05-19 16:45:15 -050060test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050061 'test-bus_aio',
62 executable(
63 'test-bus_aio',
64 'bus/aio.cpp',
65 dependencies: [
66 boost_dep,
67 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050068 gtest_dep,
69 sdbusplus_dep,
70 ],
71 )
72)
73
74test(
Patrick Williamsad145e02020-05-19 16:45:15 -050075 'test-vtable',
76 executable(
77 'test-vtable',
78 'vtable/vtable.cpp',
79 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050080 dependencies: [
81 gtest_dep,
82 sdbusplus_dep,
83 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050084 ),
85)
86
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070087generated_sources = []
88generated_others = []
89subdir('gen')
90subdir('gen/server')
91
92server_test_pre = declare_dependency(
93 include_directories: include_directories('gen'),
94 dependencies: sdbusplus_dep)
95
William A. Kennington III293c8a22022-09-02 14:35:54 -070096server_test_lib = static_library(
97 'server-test',
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070098 generated_sources,
99 implicit_include_directories: false,
100 dependencies: server_test_pre)
101
102generated_sources_header = []
103foreach s : generated_sources
104 foreach f : s.to_list()
105 if f.full_path().endswith('.hpp')
106 generated_sources_header += f
107 endif
108 endforeach
William A. Kennington III293c8a22022-09-02 14:35:54 -0700109endforeach
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700110
William A. Kennington III293c8a22022-09-02 14:35:54 -0700111server_test_dep = declare_dependency(
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700112 sources: generated_sources_header,
113 link_with: server_test_lib,
114 dependencies: server_test_pre)
Patrick Williamsad145e02020-05-19 16:45:15 -0500115
116test(
117 'test-server',
118 executable(
119 'test-server',
120 'server/object.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -0500121 dependencies: [
122 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500123 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700124 server_test_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500125 ],
126 ),
127)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500128
129test(
130 'test-server-message-variant',
131 executable(
132 'test-server-message-variant',
133 'server/message_variant.cpp',
Patrick Williamsea56ec32021-07-14 07:41:47 -0500134 dependencies: [
135 gmock_dep,
136 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700137 server_test_dep,
Patrick Williamsea56ec32021-07-14 07:41:47 -0500138 ],
139 ),
140)