/
CMakeLists.txt
296 lines (233 loc) · 9.42 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
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2019 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.
cmake_minimum_required(VERSION 3.0)
project(bareos-systemtests)
function(ConfigureFilesToSystemtest srcdir subdirectory globexpression configure_option)
set(count 1)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${subdirectory})
file(GLOB_RECURSE ALL_FILES "${CMAKE_SOURCE_DIR}/${srcdir}/${subdirectory}/${globexpression}")
foreach(CURRENT_FILE ${ALL_FILES})
MATH(EXPR COUNT "${COUNT}+1")
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" TARGET_FILE ${CURRENT_FILE})
string(REPLACE ".in" "" TARGET_FILE ${TARGET_FILE})
#MESSAGE(STATUS "configuring ${TARGET_FILE}" )
string(REPLACE "${srcdir}/${subdirectory}" "" TARGET_FILE ${TARGET_FILE})
configure_file(${CURRENT_FILE} ${PROJECT_BINARY_DIR}/${subdirectory}/${TARGET_FILE} ${configure_option})
endforeach()
MESSAGE(STATUS "Configured ${COUNT} files from ${srcdir} to ${subdirectory} with glob ${globexpression} ${configure_option}" )
endfunction()
# extract db version from cats.h
file(STRINGS ${CMAKE_SOURCE_DIR}/core/src/cats/cats.h DB_VERSION_STRING REGEX .*BDB_VERSION.*)
string(REGEX MATCH [0-9]+ BDB_VERSION ${DB_VERSION_STRING})
find_program(PERL perl)
# set variable values to be replaced by configure_file
#set(DEFAULT_DB_TYPE ${default_db_backend})
message(STATUS "DEFAULT_DB_TYPE is ${DEFAULT_DB_TYPE}")
#set(TAPEDRIVE "TAPEDRIVE")
set(archivedir "${PROJECT_BINARY_DIR}/archivedir")
set(backenddir "${PROJECT_BINARY_DIR}/../core/src/cats")
set(bin ${PROJECT_BINARY_DIR}/bin)
set(bindir ${PROJECT_BINARY_DIR}/bin)
#set(conf ${PROJECT_BINARY_DIR}/defaultconfigs)
#set(confdir ${conf})
#set(configs ${conf})
set(BAREOS_CONFIG_DIR ${conf})
set(db_name "regress")
set(db_password "")
set(db_port "5432")
set(db_user "regress")
set(dir_password "dir_password")
set(dir_port 8101)
set(dumps ${PROJECT_BINARY_DIR}/dumps)
set(fd_password "fd_password")
set(fd_port 8102)
cmake_host_system_information(RESULT hostname QUERY HOSTNAME)
set(job_email "job_email")
set(logdir "log")
set(mon_dir_password "mon_dir_password")
set(mon_fd_password "mon_fd_password")
set(mon_sd_password "mon_sd_password")
set(plugindir ${PROJECT_BINARY_DIR}/plugindir)
set(plugindirtmp ${PROJECT_BINARY_DIR}/plugindirtmp)
set(rscripts ${PROJECT_BINARY_DIR}/scripts)
set(sbindir ${PROJECT_BINARY_DIR}/sbin)
set(scriptdir ${PROJECT_BINARY_DIR}/scripts)
set(scripts ${PROJECT_BINARY_DIR}/scripts)
set(sd_password "sd_password")
set(sd_port 8103)
set(smtp_host "smtp_host")
set(src ${PROJECT_BINARY_DIR}/src)
set(subsysdir ${PROJECT_BINARY_DIR}/subsysdir)
set(tmp ${PROJECT_BINARY_DIR}/tmp)
set(tmpdir ${tmp})
set(tmpsrc ${PROJECT_BINARY_DIR}/tmpsrc)
set(working ${PROJECT_BINARY_DIR}/working)
set(working_dir ${PROJECT_BINARY_DIR}/working)
set(piddir ${PROJECT_BINARY_DIR}/piddir)
file(MAKE_DIRECTORY ${piddir})
#set(BASEPORT ${dir_port})
# for config-lib.sh: do not remove @DB___@ but replace them with the original
set(DB_NAME @DB_NAME@)
set(DB_USER @DB_USER@)
set(DB_PASS @DB_PASS@)
set(DB_VERSION @DB_VERSION@)
ConfigureFilesToSystemtest("systemtests" "data" "*.tgz" COPYONLY)
ConfigureFilesToSystemtest("systemtests" "scripts" "functions" @ONLY)
ConfigureFilesToSystemtest("systemtests" "scripts" "cleanup" @ONLY)
ConfigureFilesToSystemtest("systemtests" "scripts" "setup" @ONLY)
ConfigureFilesToSystemtest("systemtests" "scripts" "check_for_zombie_jobs" @ONLY)
ConfigureFilesToSystemtest("systemtests" "scripts" "diff.pl.in" @ONLY)
ConfigureFilesToSystemtest("core/src" "defaultconfigs" "*.conf" @ONLY)
ConfigureFilesToSystemtest("core/src" "defaultconfigs" "*.in" @ONLY)
ConfigureFilesToSystemtest("core" "scripts" "*.in" @ONLY)
ConfigureFilesToSystemtest("core" "scripts" "bareos-ctl-funcs" @ONLY)
ConfigureFilesToSystemtest("core" "scripts" "btraceback.gdb" @ONLY)
ConfigureFilesToSystemtest("core/src/cats" "ddl" "${DEFAULT_DB_TYPE}*" @ONLY)
ConfigureFilesToSystemtest("core/src" "cats" "*.in" @ONLY)
ConfigureFilesToSystemtest("core/src" "cats" "*_bareos_*" @ONLY)
ConfigureFilesToSystemtest("core/src" "console" "*.in" @ONLY)
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${scriptdir}/btraceback ${sbindir}/btraceback)
file(MAKE_DIRECTORY ${subsysdir})
file(MAKE_DIRECTORY ${sbindir})
file(MAKE_DIRECTORY ${bindir})
file(MAKE_DIRECTORY ${scripts})
file(MAKE_DIRECTORY ${working})
file(MAKE_DIRECTORY ${archivedir})
file(REMOVE_RECURSE ${scripts}/ddl)
file(RENAME ${PROJECT_BINARY_DIR}/ddl ${scripts}/ddl)
file(GLOB ALL_FILES "${CMAKE_BINARY_DIR}/systemtests/cats/*_bareos_*")
foreach(CURRENT_FILE ${ALL_FILES})
string(REPLACE "${CMAKE_BINARY_DIR}/systemtests/cats/" "" TARGET_FILE ${CURRENT_FILE})
file(RENAME ${CURRENT_FILE} ${scripts}/${TARGET_FILE})
# MESSAGE(STATUS "moved ${scripts}/${TARGET_FILE}")
endforeach()
set(tests_dir ${PROJECT_BINARY_DIR}/tests)
set(SYSTEM_TESTS
backup-bareos-test
backup-bareos-passive-test
multiplied-device-test
virtualfull
virtualfull-bscan
backup-bscan
copy-bscan
copy-remote-bscan
)
IF(PAM_WRAPPER_LIBRARIES) # BareosFindLibrary(pam_wrapper)
find_program(PAMTESTER pamtester)
IF(PAMTESTER)
set(ENV{PAM_WRAPPER_LIBRARIES} "${PAM_WRAPPER_LIBRARIES}")
execute_process(
COMMAND "${CMAKE_SOURCE_DIR}/systemtests/tests/bconsole-pam/bin/check_pam_exec_available.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/systemtests/tests/bconsole-pam/"
RESULT_VARIABLE PAM_EXEC_AVAILABLE_RC
)
IF(${PAM_EXEC_AVAILABLE_RC} EQUAL "0")
set(PAM_EXEC_FOUND TRUE)
list(APPEND SYSTEM_TESTS "bconsole-pam")
ENDIF()
MESSAGE( STATUS "PAM_EXEC_FOUND: " ${PAM_EXEC_FOUND} )
ENDIF()
ENDIF()
set(BASEPORT 42001)
foreach(TEST_NAME ${SYSTEM_TESTS})
# base directory for this test
set(current_test_directory ${PROJECT_BINARY_DIR}/tests/${TEST_NAME})
set(basename ${TEST_NAME})
#db parameters
set(db_password "")
#db_name is regress-${TEST_NAME} replacing - by _
string(REPLACE "-" "_" db_name "regress-${TEST_NAME}")
#set(db_name "regress-${TEST_NAME}")
set(db_user "regress")
set(job_email root@localhost)
set(dir_password dir_password)
set(fd_password fd_password)
set(mon_dir_password mon_dir_password)
set(mon_fd_password mon_fd_password)
set(mon_sd_password mon_sd_password)
set(sd_password sd_password)
math(EXPR dir_port "${BASEPORT} + 0")
math(EXPR fd_port "${BASEPORT} + 1")
math(EXPR sd_port "${BASEPORT} + 2")
math(EXPR sd2_port "${BASEPORT} + 3")
# set(DEFAULT_DB_TYPE )
set(archivedir ${current_test_directory}/storage)
set(confdir ${current_test_directory}/etc/bareos)
set(logdir ${current_test_directory}/log)
set(tmpdir ${current_test_directory}/tmp)
set(tmp ${tmpdir}/tmp)
set(working_dir ${current_test_directory}/working)
file(MAKE_DIRECTORY ${archivedir})
file(MAKE_DIRECTORY ${confdir})
file(MAKE_DIRECTORY ${logdir})
file(MAKE_DIRECTORY ${tmpdir})
file(MAKE_DIRECTORY ${working_dir})
ConfigureFilesToSystemtest("systemtests" "tests/${TEST_NAME}" "*" @ONLY)
configure_file("environment.in" "tests/${TEST_NAME}/environment" @ONLY)
# create a bin/bareos and bin/bconsole script
# in every testdir for start/stop and bconsole
#file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/tests/${TEST_NAME}/bin")
configure_file("bin/bconsole" "tests/${TEST_NAME}/bin/bconsole" COPYONLY)
configure_file("bin/bareos" "tests/${TEST_NAME}/bin/bareos" COPYONLY)
add_test(NAME "system:${TEST_NAME}"
COMMAND ${tests_dir}/${TEST_NAME}/testrunner
WORKING_DIRECTORY ${tests_dir}/${TEST_NAME})
math(EXPR BASEPORT "${BASEPORT} + 10")
endforeach()
# create symlinks for the binaries
set(BINARIES_TO_LINK_TO_SBIN
dird/bareos-dir
dird/bareos-dbcheck
filed/bareos-fd
stored/bareos-sd
stored/bcopy
stored/btape
stored/bextract
stored/bareos-sd
stored/bls
stored/bscan
)
foreach (BINARY_SOURCEPATH ${BINARIES_TO_LINK_TO_SBIN})
get_filename_component(BINARY_NAME ${BINARY_SOURCEPATH} NAME)
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${PROJECT_BINARY_DIR}/../core/src/${BINARY_SOURCEPATH} ${sbindir}/${BINARY_NAME})
endforeach()
set(BINARIES_TO_LINK_TO_BIN
console/bconsole
tools/bsmtp
tools/timelimit
tools/bwild
tools/bpluginfo
tools/bsmtp
tools/bscrypto
tools/btestls
tools/drivetype
tools/fstype
tools/bregex
)
foreach (BINARY_SOURCEPATH ${BINARIES_TO_LINK_TO_BIN})
get_filename_component(BINARY_NAME ${BINARY_SOURCEPATH} NAME)
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${PROJECT_BINARY_DIR}/../core/src/${BINARY_SOURCEPATH} ${bindir}/${BINARY_NAME})
endforeach()
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${PROJECT_BINARY_DIR}/../core/src/console/bconsole ${bindir}/bconsole)
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${scriptdir}/bareos ${bindir}/bareos)