blob: 2efdfebbfe42aaa655ad13d37d68598f4a15a3d4 [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',
Hannu Lounento90f8d9b2023-03-13 11:05:08 +020026 'bus/exception',
Patrick Williamsad145e02020-05-19 16:45:15 -050027 'bus/list_names',
28 'bus/match',
Patrick Williamsd2b00442022-09-16 08:28:07 -050029 'event/event',
Patrick Williamsad145e02020-05-19 16:45:15 -050030 'exception/sdbus_error',
31 'message/append',
William A. Kennington III472b7022021-04-15 13:13:14 -070032 'message/call',
Patrick Williamsad145e02020-05-19 16:45:15 -050033 'message/native_types',
Patrick Williams2f58b792022-08-26 14:07:04 -050034 'message/read',
Patrick Williamsad145e02020-05-19 16:45:15 -050035 'message/types',
36 'timer',
Krzysztof Grobelny09b88f22020-09-02 14:49:01 +020037 'unpack_properties',
Patrick Williamsad145e02020-05-19 16:45:15 -050038 'utility/tuple_to_array',
39 'utility/type_traits',
40]
41
42foreach t : tests
43 test(
44 'test_' + t.underscorify(),
45 executable(
46 'test-' + t.underscorify(),
47 t + '.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -050048 dependencies: [
49 gtest_dep,
50 gmock_dep,
Patrick Williamsd0285b92020-06-01 09:43:47 -050051 sdbusplus_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -050052 ],
53 )
54 )
55endforeach
56
William A. Kennington III5e893b92020-06-04 02:47:29 -070057assert(
58 not get_option('tests').enabled() or boost_dep.found(),
59 'Boost is required when tests are enabled'
60)
61
Patrick Williamsad145e02020-05-19 16:45:15 -050062test(
Patrick Williams3a6d5842020-06-09 14:59:58 -050063 'test-bus_aio',
64 executable(
65 'test-bus_aio',
66 'bus/aio.cpp',
67 dependencies: [
68 boost_dep,
69 gmock_dep,
Patrick Williams3a6d5842020-06-09 14:59:58 -050070 gtest_dep,
71 sdbusplus_dep,
72 ],
73 )
74)
75
76test(
Patrick Williamsad145e02020-05-19 16:45:15 -050077 'test-vtable',
78 executable(
79 'test-vtable',
80 'vtable/vtable.cpp',
81 'vtable/vtable_c.c',
Patrick Williams617e7492020-06-18 09:28:38 -050082 dependencies: [
83 gtest_dep,
84 sdbusplus_dep,
85 ],
Patrick Williamsad145e02020-05-19 16:45:15 -050086 ),
87)
88
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -070089generated_sources = []
90generated_others = []
91subdir('gen')
92subdir('gen/server')
93
94server_test_pre = declare_dependency(
95 include_directories: include_directories('gen'),
96 dependencies: sdbusplus_dep)
97
William A. Kennington III293c8a22022-09-02 14:35:54 -070098server_test_lib = static_library(
99 'server-test',
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700100 generated_sources,
101 implicit_include_directories: false,
102 dependencies: server_test_pre)
103
104generated_sources_header = []
105foreach s : generated_sources
106 foreach f : s.to_list()
107 if f.full_path().endswith('.hpp')
108 generated_sources_header += f
109 endif
110 endforeach
William A. Kennington III293c8a22022-09-02 14:35:54 -0700111endforeach
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700112
William A. Kennington III293c8a22022-09-02 14:35:54 -0700113server_test_dep = declare_dependency(
Willam A. Kennington IIIce8d16d2022-09-07 15:46:40 -0700114 sources: generated_sources_header,
115 link_with: server_test_lib,
116 dependencies: server_test_pre)
Patrick Williamsad145e02020-05-19 16:45:15 -0500117
118test(
119 'test-server',
120 executable(
121 'test-server',
122 'server/object.cpp',
Patrick Williamsad145e02020-05-19 16:45:15 -0500123 dependencies: [
124 gmock_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500125 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700126 server_test_dep,
Patrick Williamsad145e02020-05-19 16:45:15 -0500127 ],
128 ),
129)
Patrick Williamsea56ec32021-07-14 07:41:47 -0500130
131test(
132 'test-server-message-variant',
133 executable(
134 'test-server-message-variant',
135 'server/message_variant.cpp',
Patrick Williamsea56ec32021-07-14 07:41:47 -0500136 dependencies: [
137 gmock_dep,
138 gtest_dep,
William A. Kennington III293c8a22022-09-02 14:35:54 -0700139 server_test_dep,
Patrick Williamsea56ec32021-07-14 07:41:47 -0500140 ],
141 ),
142)