Newer
Older
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
#
# 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}
# 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}
.PHONY: run-perf-test
run-perf-test:
cmake --build ${BUILD_DIR} --parallel
cmake --build ${BUILD_DIR} --target test-perf
##############################
# Linux #
##############################
# Release build
.PHONY: test-release
test-release: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_GLAUTH_DOWNLOAD=ON \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
test-release: build run-luajit-test run-test
.PHONY: test-perf
test-perf: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
test-perf: build run-perf-test
# *_ASAN variables are common part of respective variables for all ASAN builds.
CMAKE_PARAMS_ASAN = -DENABLE_WERROR=ON \
-DENABLE_ASAN=ON \
-DENABLE_UB_SANITIZER=ON \
-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_RUN_ENV_ASAN = 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
LUAJIT_TEST_ENV_ASAN = 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
# 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 = ${CMAKE_PARAMS_ASAN} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_GLAUTH_DOWNLOAD=ON \
-DFIBER_STACK_SIZE=640Kb
test-release-asan: TEST_RUN_ENV = ${TEST_RUN_ENV_ASAN}
test-release-asan: LUAJIT_TEST_ENV = ${LUAJIT_TEST_ENV_ASAN}
test-release-asan: build run-luajit-test run-test
# Debug ASAN build
.PHONY: test-debug-asan
# We need even larger fiber stacks in ASAN debug build for luajit tests
# to pass. Value twice as big as in ASAN release is just a wild guess.
test-debug-asan: CMAKE_PARAMS = ${CMAKE_PARAMS_ASAN} \
-DCMAKE_BUILD_TYPE=Debug \
-DFIBER_STACK_SIZE=1280Kb
test-debug-asan: TEST_RUN_ENV = ${TEST_RUN_ENV_ASAN}
test-debug-asan: LUAJIT_TEST_ENV = ${LUAJIT_TEST_ENV_ASAN}
# Increase timeouts as some tests in ASAN debug build take quite a lot
# of time to finish.
test-debug-asan: TEST_RUN_PARAMS += --test-timeout 620 \
--no-output-timeout 630 \
--server-start-timeout 610
test-debug-asan: build run-luajit-test run-test
# Debug build
.PHONY: test-debug
test-debug: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=Debug \
-DENABLE_GLAUTH_DOWNLOAD=ON \
test-debug: build run-luajit-test run-test
# Static build
.PHONY: test-static
test-static: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_GLAUTH_DOWNLOAD=ON \
-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;-DENABLE_GLAUTH_DOWNLOAD=ON"
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_GLAUTH_DOWNLOAD=ON \
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
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_GLAUTH_DOWNLOAD=ON \
-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 \
-DENABLE_GLAUTH_DOWNLOAD=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;-DENABLE_GLAUTH_DOWNLOAD=ON"
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_GLAUTH_DOWNLOAD=ON \
-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 "nobody@nowhere.com"
.PHONY: test-jepsen
test-jepsen: CMAKE_PARAMS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_GLAUTH_DOWNLOAD=ON \
-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_GLAUTH_DOWNLOAD=ON \
-DENABLE_WERROR=ON \
-DTEST_BUILD=ON
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
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=tarantool@tarantool.org \
--form file=@tarantool.tgz \
--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