forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.test.mk
282 lines (229 loc) · 9.76 KB
/
.test.mk
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
#
# CI testing rules
#
SRC_DIR = .
BUILD_DIR ?= .
STATIC_DIR = static-build
STATIC_BIN_DIR = ${STATIC_DIR}/tarantool-prefix/src/tarantool-build
LUAJIT_TEST_BUILD_DIR = ${BUILD_DIR}
# `nproc` - for Linux
# `sysctl -n hw.logicalcpu` - for OSX
# `sysctl -n hw.ncpu` - for FreeBSD (deprecated in OSX)
NPROC ?= $(shell nproc || sysctl -n hw.logicalcpu || sysctl -n hw.ncpu)
MAX_PROCS ?= 2048
MAX_FILES ?= 4096
VARDIR ?= /tmp/t
TEST_RUN_PARAMS = --builddir ${PWD}/${BUILD_DIR}
COVERITY_DIR = cov-int
COVERITY_URL = https://scan.coverity.com/builds?project=tarantool%2Ftarantool
CMAKE = ${CMAKE_ENV} cmake -S ${SRC_DIR} -B ${BUILD_DIR}
CMAKE_BUILD = ${CMAKE_BUILD_ENV} cmake --build ${BUILD_DIR} --parallel ${NPROC}
.PHONY: configure
configure:
${CMAKE} ${CMAKE_PARAMS} ${CMAKE_EXTRA_PARAMS}
# Static Analysis
.PHONY: luacheck
luacheck: configure
${CMAKE_BUILD} --target luacheck
# Building
.PHONY: build
build: configure
${CMAKE_BUILD}
if [ "${CTEST}" = "true" ]; then cd ${BUILD_DIR} && ctest -V; fi
# Testing
.PHONY: run-luajit-test
run-luajit-test:
${LUAJIT_TEST_ENV} cmake --build ${LUAJIT_TEST_BUILD_DIR} --parallel ${NPROC} --target LuaJIT-test
.PHONY: install-test-deps
install-test-deps:
python3 -m pip install -r test-run/requirements.txt
.PHONY: run-test
run-test: install-test-deps
cd test && ${TEST_RUN_ENV} ./test-run.py --force --vardir ${VARDIR} ${TEST_RUN_PARAMS} ${TEST_RUN_EXTRA_PARAMS}
##############################
# Linux #
##############################
# Release build
.PHONY: test-release
test-release: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
test-release: build run-luajit-test run-test
# Release ASAN build
.PHONY: test-release-asan
# FIBER_STACK_SIZE=640Kb: The default value of fiber stack size
# is 512Kb, but several tests in test/PUC-Rio-Lua-5.1-test suite
# in the LuaJIT repo (e.g. some cases with deep recursion in
# errors.lua or pm.lua) have already been tweaked according to the
# limitations mentioned in #5782, but the crashes still occur
# while running LuaJIT tests with ASan support enabled.
# Experiments once again confirm the notorious quote that "640 Kb
# ought to be enough for anybody".
test-release-asan: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DENABLE_ASAN=ON \
-DENABLE_UB_SANITIZER=ON \
-DFIBER_STACK_SIZE=640Kb \
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=OFF \
-DENABLE_FUZZER=ON \
-DTEST_BUILD=ON
# Some checks are temporary suppressed in the scope of the issue
# https://github.com/tarantool/tarantool/issues/4360:
# - ASAN: to suppress failures of memory error checks caught while tests run, the asan/asan.supp
# file is used. It is set as a value for the `-fsanitize-blacklist` option at the build time in
# the cmake/profile.cmake file.
# - LSAN: to suppress failures of memory leak checks caught while tests run, the asan/lsan.supp
# file is used.
test-release-asan: TEST_RUN_ENV = ASAN=ON \
LSAN_OPTIONS=suppressions=${PWD}/asan/lsan.supp \
ASAN_OPTIONS=heap_profile=0:unmap_shadow_on_exit=1:$\
detect_invalid_pointer_pairs=1:symbolize=1:$\
detect_leaks=1:dump_instruction_bytes=1:$\
print_suppressions=0
test-release-asan: LUAJIT_TEST_ENV = LSAN_OPTIONS=suppressions=${PWD}/asan/lsan.supp \
ASAN_OPTIONS=detect_invalid_pointer_pairs=1:$\
detect_leaks=1:$\
dump_instruction_bytes=1:$\
heap_profile=0:$\
print_suppressions=0:$\
symbolize=1:$\
unmap_shadow_on_exit=1
test-release-asan: build run-luajit-test run-test
# Debug build
.PHONY: test-debug
test-debug: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=Debug \
-DTEST_BUILD=ON
test-debug: build run-luajit-test run-test
# Static build
.PHONY: test-static
test-static: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DBUILD_STATIC=ON \
-DTEST_BUILD=ON
test-static: build run-luajit-test run-test
# Static build (cmake)
.PHONY: test-static-cmake
test-static-cmake: SRC_DIR = ${STATIC_DIR}
test-static-cmake: BUILD_DIR = ${STATIC_DIR}
test-static-cmake: CMAKE_PARAMS = -DCMAKE_TARANTOOL_ARGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DENABLE_WERROR=ON;-DTEST_BUILD=ON"
test-static-cmake: CTEST = true
test-static-cmake: LUAJIT_TEST_BUILD_DIR = ${STATIC_BIN_DIR}
test-static-cmake: TEST_RUN_PARAMS = --builddir ${PWD}/${STATIC_BIN_DIR}
test-static-cmake: build run-luajit-test run-test
# Coverage build
.PHONY: test-coverage
test-coverage: CMAKE_PARAMS = -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_GCOV=ON \
-DTEST_BUILD=ON
test-coverage: TEST_RUN_PARAMS += --long
test-coverage: OUTPUT_FILE = coverage.info
test-coverage: build run-luajit-test run-test
lcov --capture \
--compat-libtool \
--directory ${BUILD_DIR}/src/ \
--output-file ${OUTPUT_FILE} \
--rc lcov_function_coverage=1 \
--rc lcov_branch_coverage=1 \
--exclude '/usr/*' \
--exclude '*/build/*' \
--exclude '*/test/*' \
--exclude '*/third_party/*'
lcov --list ${OUTPUT_FILE}
##############################
# OSX #
##############################
.PHONY: prebuild-osx
prebuild-osx:
sysctl vm.swapusage
.PHONY: pretest-osx
pretest-osx:
ulimit -u ${MAX_PROCS} || : && ulimit -u
ulimit -n ${MAX_FILES} || : && ulimit -n
# Release build
.PHONY: test-osx-release
test-osx-release: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
test-osx-release: prebuild-osx build run-luajit-test pretest-osx run-test
# Debug build
.PHONY: test-osx-debug
test-osx-debug: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=Debug \
-DTEST_BUILD=ON
test-osx-debug: prebuild-osx build run-luajit-test pretest-osx run-test
# Static build
.PHONY: test-osx-static-cmake
test-osx-static-cmake: SRC_DIR = ${STATIC_DIR}
test-osx-static-cmake: BUILD_DIR = ${STATIC_DIR}
test-osx-static-cmake: CMAKE_PARAMS = -DCMAKE_TARANTOOL_ARGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DENABLE_WERROR=ON;-DTEST_BUILD=ON"
test-osx-static-cmake: CTEST = true
test-osx-static-cmake: LUAJIT_TEST_BUILD_DIR = ${STATIC_BIN_DIR}
test-osx-static-cmake: TEST_RUN_PARAMS = --builddir ${PWD}/${STATIC_BIN_DIR}
test-osx-static-cmake: prebuild-osx build run-luajit-test pretest-osx run-test
##############################
# FreeBSD #
##############################
.PHONY: prebuild-freebsd
prebuild-freebsd:
if [ "$$(swapctl -l | wc -l)" != "1" ]; then swapoff -a; fi
swapctl -l
# Release build
.PHONY: test-freebsd-release
test-freebsd-release: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
test-freebsd-release: prebuild-freebsd build run-luajit-test run-test
##############################
# Jepsen testing #
##############################
.PHONY: prebuild-jepsen
prebuild-jepsen:
# Jepsen build uses git commands internally, like command `git stash --all` that fails w/o
# git configuration setup.
git config --get user.name || git config --global user.name "Nodody User"
git config --get user.email || git config --global user.email "[email protected]"
.PHONY: test-jepsen
test-jepsen: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DWITH_JEPSEN=ON \
-DTEST_BUILD=ON
test-jepsen: configure prebuild-jepsen
${CMAKE_BUILD} --target run-jepsen
##############################
# Coverity testing #
##############################
.PHONY: build-coverity
build-coverity: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
build-coverity: CMAKE_BUILD_ENV = PATH=${PATH}:/cov-analysis/bin cov-build --dir ${COVERITY_DIR}
build-coverity: configure
${CMAKE_BUILD}
.PHONY: test-coverity
test-coverity: build-coverity
tar czvf tarantool.tgz ${COVERITY_DIR}
if [ -n "$${COVERITY_TOKEN}" ]; then \
echo "Exporting code coverity information to scan.coverity.com"; \
curl --location \
--fail \
--silent \
--show-error \
--retry 5 \
--retry-delay 5 \
--form token=$${COVERITY_TOKEN} \
--form [email protected] \
--form [email protected] \
--form version=$(shell git describe HEAD) \
--form description="Tarantool Coverity" \
${COVERITY_URL}; \
else \
echo "Coverity token is not provided"; \
exit 1; \
fi
##############################
# LuaJIT integration testing #
##############################
test-luajit-Linux-x86_64: build run-luajit-test run-test
test-luajit-Linux-ARM64: build run-luajit-test run-test
test-luajit-macOS-x86_64: prebuild-osx build run-luajit-test pretest-osx run-test
test-luajit-macOS-ARM64: prebuild-osx build run-luajit-test pretest-osx run-test