/
CMakeLists.txt
424 lines (377 loc) · 10.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2020 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${OPENSSL_INCLUDE_DIR})
macro(bareos_gtest_add_tests testname)
gtest_add_tests(
TARGET ${testname}
TEST_PREFIX gtest:
TEST_LIST found_tests
)
if(HAVE_WIN32)
set_tests_properties(
${found_tests} PROPERTIES ENVIRONMENT "WINEPATH=${WINEPATH}"
)
endif() # HAVE_WIN32
endmacro() # bareos_gtest_add_tests
macro(bareos_add_test BAREOS_ADD_TEST_TESTNAME)
set(options SKIP_GTEST)
set(multiValueArgs ADDITIONAL_SOURCES LINK_LIBRARIES COMPILE_DEFINITIONS)
cmake_parse_arguments(
BAREOS_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)
add_executable(
${BAREOS_ADD_TEST_TESTNAME} ${BAREOS_ADD_TEST_TESTNAME}.cc
${BAREOS_ADD_TEST_ADDITIONAL_SOURCES}
)
target_link_libraries(
${BAREOS_ADD_TEST_TESTNAME} ${BAREOS_ADD_TEST_LINK_LIBRARIES}
)
target_compile_definitions(
${BAREOS_ADD_TEST_TESTNAME} PRIVATE ${BAREOS_ADD_TEST_COMPILE_DEFINITIONS}
)
if(NOT BAREOS_ADD_TEST_SKIP_GTEST)
bareos_gtest_add_tests(${BAREOS_ADD_TEST_TESTNAME})
endif()
endmacro() # bareos_add_test
include(GoogleTest)
if(HAVE_WIN32)
link_libraries(
kernel32
user32
gdi32
winspool
shell32
ole32
oleaut32
uuid
comdlg32
advapi32
)
endif() # HAVE_WIN32
if(HAVE_OPENSSL)
set(SSL_UNIT_TEST_FILES init_openssl.cc)
endif()
set(LINK_LIBRARIES
stored_objects
dird_objects
console_objects
bareossd
bareos
bareoscats
bareossql
bareosfind
${LMDB_LIBS}
${NDMP_LIBS}
${JANSSON_LIBRARIES}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
if(HAVE_PAM)
list(APPEND LINK_LIBRARIES ${PAM_LIBRARIES})
endif()
# set some path variables used during test compilation
if(HAVE_WIN32)
set(RELATIVE_PROJECT_SOURCE_DIR "Z:${CMAKE_CURRENT_SOURCE_DIR}")
set(TEST_ORIGINAL_FILE_DIR
Z:${CMAKE_CURRENT_SOURCE_DIR}/recent_job_results_list
)
set(TEST_TEMP_DIR Z:${CMAKE_CURRENT_BINARY_DIR}/recent_job_results_list_tmp)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/recent_job_results_list_tmp)
set(CERTDIR Z:${CMAKE_CURRENT_SOURCE_DIR}/configs/test_bsock/tls)
else() # NOT HAVE_WIN32
file(RELATIVE_PATH RELATIVE_PROJECT_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(TEST_ORIGINAL_FILE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/recent_job_results_list
)
set(TEST_TEMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/recent_job_results_list_tmp)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/recent_job_results_list_tmp)
set(CERTDIR ${CMAKE_CURRENT_SOURCE_DIR}/configs/test_bsock/tls)
endif() # HAVE_WIN32
add_definitions(
-DRELATIVE_PROJECT_SOURCE_DIR=\"${RELATIVE_PROJECT_SOURCE_DIR}\"
)
if(NOT client-only)
bareos_add_test(
run_on_incoming_connect_interval
LINK_LIBRARIES
dird_objects
bareos
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${NDMP_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
scheduler
LINK_LIBRARIES
dird_objects
bareos
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${NDMP_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
scheduler_job_item_queue
LINK_LIBRARIES dird_objects bareos bareosfind bareoscats bareossql ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
test_acl_entry_syntax LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
if(NOT client-only)
bareos_add_test(
test_dir_plugins
ADDITIONAL_SOURCES ${PROJECT_SOURCE_DIR}/src/dird/dir_plugins.cc
LINK_LIBRARIES bareos bareoscats bareossql ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
test_fd_plugins
ADDITIONAL_SOURCES ${PROJECT_SOURCE_DIR}/src/filed/fd_plugins.cc
${PROJECT_SOURCE_DIR}/src/filed/fileset.cc
LINK_LIBRARIES bareos bareosfind ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
test_is_name_valid LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
test_output_formatter
LINK_LIBRARIES ${GTEST_MAIN_LIBRARIES} ${GTEST_LIBRARIES}
${JANSSON_LIBRARIES} bareos
)
if(NOT client-only)
bareos_add_test(
test_sd_plugins LINK_LIBRARIES bareos bareossd ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
version_strings LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
job_control_record LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
cram_md5
LINK_LIBRARIES bareos ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
ADDITIONAL_SOURCES bareos_test_sockets.cc
)
if(NOT client-only)
bareos_add_test(multiplied_device_test LINK_LIBRARIES ${LINK_LIBRARIES})
endif()
if(NOT client-only)
bareos_add_test(
ndmp_address_translate_test
ADDITIONAL_SOURCES ../dird/ndmp_slot2elemaddr.cc
LINK_LIBRARIES ${LINK_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
recent_job_results_list
LINK_LIBRARIES bareos ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
COMPILE_DEFINITIONS TEST_TEMP_DIR=\"${TEST_TEMP_DIR}\"
TEST_ORIGINAL_FILE_DIR=\"${TEST_ORIGINAL_FILE_DIR}\"
)
if(NOT client-only)
bareos_add_test(
show_cmd_available_resources_equals_config_resources
LINK_LIBRARIES dird_objects bareos bareosfind bareoscats bareossql
${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
test_config_parser_console
LINK_LIBRARIES console_objects bareos bareosfind ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
if(NOT client-only)
bareos_add_test(
test_config_parser_dir
LINK_LIBRARIES dird_objects bareos bareosfind bareoscats bareossql
${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
test_config_parser_fd
LINK_LIBRARIES fd_objects bareos bareosfind ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
if(NOT client-only)
bareos_add_test(
test_config_parser_sd
LINK_LIBRARIES stored_objects bareossd bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
test_crc32
ADDITIONAL_SOURCES ../stored/crc32/crc32.cc
LINK_LIBRARIES bareos ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
test_fileindex_list
LINK_LIBRARIES
dird_objects
bareos
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${NDMP_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
test_setdebug
LINK_LIBRARIES
dird_objects
bareos
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${NDMP_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
bareos_add_test(
thread_list LINK_LIBRARIES bareos ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
thread_specific_data LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
timer_thread LINK_LIBRARIES bareos ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
if(NOT client-only)
bareos_add_test(
catalog
LINK_LIBRARIES
bareos
dird_objects
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
SKIP_GTEST
)
endif()
if(HAVE_EXECINFO_H
AND HAVE_BACKTRACE
AND HAVE_BACKTRACE_SYMBOLS
)
bareos_add_test(
test_backtrace LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # HAVE_EXECINFO_H ..
if(GMOCK_FOUND AND NOT client-only)
bareos_add_test(
sd_reservation LINK_LIBRARIES ${LINK_LIBRARIES} ${GMOCK_LIBRARIES}
)
endif()
if(NOT client-only)
bareos_add_test(
lib_tests
ADDITIONAL_SOURCES
alist_test.cc bareos_test_sockets.cc dlist_test.cc htable_test.cc
qualified_resource_name_type_converter_test.cc
${PROJECT_SOURCE_DIR}/src/filed/evaluate_job_command.cc
LINK_LIBRARIES stored_objects bareossd bareos ${JANSSON_LIBRARIES}
${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
)
bareos_add_test(
bsock_test_connection_setup
ADDITIONAL_SOURCES ${SSL_UNIT_TEST_FILES}
LINK_LIBRARIES ${LINK_LIBRARIES}
)
endif() # NOT client-only
if(NOT HAVE_WIN32 AND NOT client-only)
bareos_add_test(
test_bsock
ADDITIONAL_SOURCES
bareos_test_sockets.cc bsock_constructor_test.cc
bsock_cert_verify_common_names_test.cc create_resource.cc
${SSL_UNIT_TEST_FILES}
LINK_LIBRARIES ${LINK_LIBRARIES}
COMPILE_DEFINITIONS -DCERTDIR=\"${CERTDIR}\"
)
bareos_add_test(
watchdog_timer LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT HAVE_WIN32 AND NOT client-only
if(NOT client-only)
bareos_add_test(
sort_stringvector LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
messages_resource
LINK_LIBRARIES
bareos
dird_objects
bareosfind
bareoscats
bareossql
$<$<BOOL:HAVE_PAM>:${PAM_LIBRARIES}>
${LMDB_LIBS}
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
SKIP_GTEST
)
endif() # NOT client-only
bareos_add_test(
test_edit LINK_LIBRARIES bareos ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)