2020-08-05 14:16:38 +00:00
|
|
|
#!/bin/bash
|
2016-02-23 03:23:00 +03:00
|
|
|
set -x -e
|
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
CI_PKGS=(protobuf-c-compiler libprotobuf-c-dev libaio-dev libgnutls28-dev
|
2020-05-19 16:23:31 +00:00
|
|
|
libgnutls30 libprotobuf-dev protobuf-compiler libcap-dev
|
|
|
|
libnl-3-dev gdb bash libnet-dev util-linux asciidoctor
|
2021-06-15 06:02:55 +00:00
|
|
|
libnl-route-3-dev time flake8 libbsd-dev python3-yaml
|
|
|
|
libperl-dev pkg-config python3-future python3-protobuf
|
2022-04-12 17:07:43 -07:00
|
|
|
python3-junit.xml)
|
2019-10-29 15:17:40 +01:00
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
X86_64_PKGS=(gcc-multilib)
|
|
|
|
|
|
|
|
# Convert from string to array.
|
|
|
|
IFS=" " read -r -a ZDTM_OPTS <<< "$ZDTM_OPTS"
|
2019-10-29 15:17:40 +01:00
|
|
|
|
2020-09-23 06:29:35 +00:00
|
|
|
UNAME_M=$(uname -m)
|
2019-10-29 15:17:40 +01:00
|
|
|
|
|
|
|
if [ "$UNAME_M" != "x86_64" ]; then
|
|
|
|
# For Travis only x86_64 seems to be baremetal. Other
|
|
|
|
# architectures are running in unprivileged LXD containers.
|
|
|
|
# That seems to block most of CRIU's interfaces.
|
2020-11-04 07:51:32 +00:00
|
|
|
|
|
|
|
# But with the introduction of baremetal aarch64 systems in
|
|
|
|
# Travis (arch: arm64-graviton2) we can override this using
|
2022-03-30 18:45:16 -07:00
|
|
|
# an environment variable
|
2020-11-04 07:51:32 +00:00
|
|
|
[ -n "$RUN_TESTS" ] || SKIP_CI_TEST=1
|
2019-10-29 15:17:40 +01:00
|
|
|
fi
|
2016-10-19 10:34:00 +03:00
|
|
|
|
2020-11-03 10:18:02 +00:00
|
|
|
ci_prep () {
|
|
|
|
[ -n "$SKIP_CI_PREP" ] && return
|
2016-10-08 17:22:00 +03:00
|
|
|
|
|
|
|
cd ../../
|
|
|
|
|
2020-08-14 19:08:14 +00:00
|
|
|
# At least one of the test cases run by this script (others/rpc)
|
|
|
|
# expects a user with the ID 1000. sudo from 20.04 (focal) does
|
|
|
|
# not run anymore with 'sudo -u \#1000' if the UID does not exist.
|
|
|
|
adduser -u 1000 --disabled-password --gecos "criutest" criutest || :
|
|
|
|
|
2019-10-29 15:17:40 +01:00
|
|
|
# This can fail on aarch64 travis
|
|
|
|
service apport stop || :
|
2016-08-24 23:09:00 +03:00
|
|
|
|
2017-03-15 16:17:22 -07:00
|
|
|
if [ "$CLANG" = "1" ]; then
|
2020-11-12 12:22:41 +00:00
|
|
|
# clang support
|
2017-03-15 16:17:22 -07:00
|
|
|
CC=clang
|
2020-12-29 08:47:26 +00:00
|
|
|
# If this is running in an environment without gcc installed
|
|
|
|
# compel-host-bin will fail as it is using HOSTCC. Also
|
|
|
|
# set HOSTCC to clang to build compel-host-bin with it.
|
|
|
|
export HOSTCC=clang
|
2020-11-12 12:22:41 +00:00
|
|
|
else
|
|
|
|
CC=gcc
|
2017-03-15 16:17:22 -07:00
|
|
|
fi
|
2022-04-12 17:07:43 -07:00
|
|
|
CI_PKGS+=("$CC")
|
2017-03-15 16:17:22 -07:00
|
|
|
|
2019-10-29 15:17:40 +01:00
|
|
|
# Do not install x86_64 specific packages on other architectures
|
|
|
|
if [ "$UNAME_M" = "x86_64" ]; then
|
2022-04-12 17:07:43 -07:00
|
|
|
CI_PKGS+=("${X86_64_PKGS[@]}")
|
2019-10-29 15:17:40 +01:00
|
|
|
fi
|
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
scripts/ci/apt-install "${CI_PKGS[@]}"
|
2020-09-23 06:29:35 +00:00
|
|
|
chmod a+x "$HOME"
|
2020-05-19 16:23:31 +00:00
|
|
|
|
|
|
|
# zdtm uses an unversioned python binary to run the tests.
|
|
|
|
# let's point python to python3
|
|
|
|
ln -sf /usr/bin/python3 /usr/bin/python
|
2016-10-08 17:22:00 +03:00
|
|
|
}
|
2016-02-23 03:23:00 +03:00
|
|
|
|
2020-06-10 20:25:36 +00:00
|
|
|
test_stream() {
|
2021-12-28 19:30:09 +00:00
|
|
|
# Testing CRIU streaming to criu-image-streamer
|
2022-02-12 16:00:39 +07:00
|
|
|
|
|
|
|
# FIXME: Currently, hugetlb mappings is not premapped, so in the restore content
|
|
|
|
# phase, we skip page read these pages, enqueue the iovec for later reading in
|
|
|
|
# restorer and eventually close the page read. However, image-streamer expects the
|
|
|
|
# whole image to be read and the image is not reopened, sent twice. These MAP_HUGETLB
|
|
|
|
# test cases will result in EPIPE error at the moment.
|
2022-04-12 17:07:43 -07:00
|
|
|
STREAM_TEST_EXCLUDE=(-x maps09 -x maps10)
|
|
|
|
./test/zdtm.py run --stream -p 2 --keep-going -a "${STREAM_TEST_EXCLUDE[@]}" "${ZDTM_OPTS[@]}"
|
2020-06-10 20:25:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 17:08:18 +00:00
|
|
|
print_header() {
|
|
|
|
echo "############### $1 ###############"
|
|
|
|
}
|
|
|
|
|
|
|
|
print_env() {
|
2021-06-14 20:52:44 +00:00
|
|
|
set +x
|
2020-12-20 17:08:18 +00:00
|
|
|
# As this script can run on multiple different CI systems
|
|
|
|
# the following lines should give some context to the
|
|
|
|
# evnvironment of this CI run.
|
|
|
|
print_header "Environment variables"
|
|
|
|
printenv
|
|
|
|
print_header "uname -a"
|
|
|
|
uname -a || :
|
|
|
|
print_header "Mounted file systems"
|
2022-04-07 18:30:16 +03:00
|
|
|
cat /proc/self/mountinfo || :
|
2020-12-20 17:08:18 +00:00
|
|
|
print_header "Kernel command line"
|
|
|
|
cat /proc/cmdline || :
|
2022-05-04 00:19:46 +03:00
|
|
|
print_header "Kernel modules"
|
|
|
|
lsmod || :
|
2020-12-20 17:08:18 +00:00
|
|
|
print_header "Distribution information"
|
|
|
|
[ -e /etc/lsb-release ] && cat /etc/lsb-release
|
|
|
|
[ -e /etc/redhat-release ] && cat /etc/redhat-release
|
|
|
|
[ -e /etc/alpine-release ] && cat /etc/alpine-release
|
|
|
|
print_header "ulimit -a"
|
|
|
|
ulimit -a
|
|
|
|
print_header "Available memory"
|
2020-12-26 19:29:58 +00:00
|
|
|
if [ -e /etc/alpine-release ]; then
|
|
|
|
# Alpine's busybox based free does not understand -h
|
|
|
|
free
|
|
|
|
else
|
|
|
|
free -h
|
|
|
|
fi
|
2020-12-20 17:08:18 +00:00
|
|
|
print_header "Available CPUs"
|
|
|
|
lscpu || :
|
2021-06-14 20:52:44 +00:00
|
|
|
set -x
|
2020-12-20 17:08:18 +00:00
|
|
|
}
|
|
|
|
|
2022-05-05 00:13:40 +03:00
|
|
|
# FIXME: workaround for the issue https://github.com/checkpoint-restore/criu/issues/1866
|
|
|
|
modprobe -v sit || :
|
|
|
|
|
2020-12-20 17:08:18 +00:00
|
|
|
print_env
|
|
|
|
|
2020-11-03 10:18:02 +00:00
|
|
|
ci_prep
|
2016-10-08 17:22:00 +03:00
|
|
|
|
2021-01-31 17:41:09 +00:00
|
|
|
if [ "${CD_TO_TOP}" = "1" ]; then
|
|
|
|
cd ../../
|
|
|
|
fi
|
|
|
|
|
2020-12-20 17:08:18 +00:00
|
|
|
export GCOV CC
|
2019-10-29 15:17:40 +01:00
|
|
|
$CC --version
|
2020-12-20 17:08:18 +00:00
|
|
|
time make CC="$CC" -j4 V=1
|
2017-10-05 20:38:24 +03:00
|
|
|
|
2019-10-29 15:17:40 +01:00
|
|
|
./criu/criu -v4 cpuinfo dump || :
|
|
|
|
./criu/criu -v4 cpuinfo check || :
|
|
|
|
|
|
|
|
# Check that help output fits into 80 columns
|
|
|
|
WIDTH=$(./criu/criu --help | wc --max-line-length)
|
|
|
|
if [ "$WIDTH" -gt 80 ]; then
|
|
|
|
echo "criu --help output does not obey 80 characters line width!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-06-22 14:52:09 +00:00
|
|
|
# Unit tests at this point do not require any kernel or hardware capabilities.
|
|
|
|
# Just try to run it everywhere for now.
|
|
|
|
time make unittest
|
|
|
|
|
2020-11-03 10:18:02 +00:00
|
|
|
[ -n "$SKIP_CI_TEST" ] && exit 0
|
2017-10-05 20:38:24 +03:00
|
|
|
|
2019-10-29 15:17:40 +01:00
|
|
|
ulimit -c unlimited
|
|
|
|
|
2022-03-20 22:13:45 -07:00
|
|
|
cgid=$$
|
|
|
|
cleanup_cgroup() {
|
|
|
|
./test/zdtm_umount_cgroups $cgid
|
|
|
|
}
|
|
|
|
trap cleanup_cgroup EXIT
|
|
|
|
./test/zdtm_mount_cgroups $cgid
|
|
|
|
|
2020-09-23 06:29:35 +00:00
|
|
|
echo "|$(pwd)/test/abrt.sh %P %p %s %e" > /proc/sys/kernel/core_pattern
|
2019-10-29 15:17:40 +01:00
|
|
|
|
2019-04-10 15:03:02 +01:00
|
|
|
if [ "${COMPAT_TEST}x" = "yx" ] ; then
|
|
|
|
# Dirty hack to keep both ia32 & x86_64 shared libs on a machine:
|
|
|
|
# headers are probably not compatible, so apt-get doesn't allow
|
|
|
|
# installing both versions, while we need one for CRIU and one
|
|
|
|
# for 32-bit tests. A better way would involve launching docker..
|
|
|
|
# But it would require making zdtm.py aware of docker and launching
|
|
|
|
# tests inside the CT.
|
2022-04-12 17:07:43 -07:00
|
|
|
INCOMPATIBLE_LIBS=(libaio-dev libcap-dev libnl-3-dev libnl-route-3-dev)
|
|
|
|
IA32_PKGS=()
|
2019-04-10 15:03:02 +01:00
|
|
|
REFUGE=64-refuge
|
|
|
|
|
|
|
|
mkdir "$REFUGE"
|
2022-04-12 17:07:43 -07:00
|
|
|
for i in "${INCOMPATIBLE_LIBS[@]}" ; do
|
2020-09-23 06:29:35 +00:00
|
|
|
for j in $(dpkg --listfiles "$i" | grep '\.so$') ; do
|
2019-04-10 15:03:02 +01:00
|
|
|
cp "$j" "$REFUGE/"
|
|
|
|
done
|
2022-04-12 17:07:43 -07:00
|
|
|
IA32_PKGS+=("$i:i386")
|
2019-04-10 15:03:02 +01:00
|
|
|
done
|
2022-04-12 17:07:43 -07:00
|
|
|
apt-get remove "${INCOMPATIBLE_LIBS[@]}"
|
2021-02-01 11:06:07 +00:00
|
|
|
dpkg --add-architecture i386
|
2022-04-12 17:07:43 -07:00
|
|
|
scripts/ci/apt-install "${IA32_PKGS[@]}"
|
2019-04-10 15:03:02 +01:00
|
|
|
mkdir -p /usr/lib/x86_64-linux-gnu/
|
|
|
|
mv "$REFUGE"/* /usr/lib/x86_64-linux-gnu/
|
|
|
|
fi
|
|
|
|
|
2020-12-20 17:08:18 +00:00
|
|
|
time make CC="$CC" -j4 -C test/zdtm V=1
|
2017-03-15 16:17:22 -07:00
|
|
|
|
2021-02-26 20:43:41 +00:00
|
|
|
if [ "${COMPAT_TEST}x" = "yx" ] ; then
|
|
|
|
# Cross-verify that zdtm tests are 32-bit
|
|
|
|
file test/zdtm/static/env00 | grep 'ELF 32-bit' -q
|
|
|
|
fi
|
|
|
|
|
2017-10-04 09:43:04 +03:00
|
|
|
# umask has to be called before a first criu run, so that .gcda (coverage data)
|
|
|
|
# files are created with read-write permissions for all.
|
|
|
|
umask 0000
|
2016-07-06 05:01:59 +03:00
|
|
|
./criu/criu check
|
|
|
|
./criu/criu check --all || echo $?
|
2020-11-04 07:51:32 +00:00
|
|
|
if [ "$UNAME_M" == "x86_64" ]; then
|
|
|
|
# This fails on aarch64 (aws-graviton2)
|
|
|
|
./criu/criu cpuinfo dump
|
|
|
|
./criu/criu cpuinfo check
|
|
|
|
fi
|
2016-07-06 05:01:59 +03:00
|
|
|
|
|
|
|
export SKIP_PREP=1
|
|
|
|
|
2016-08-31 22:50:00 +03:00
|
|
|
chmod 0777 test/
|
|
|
|
chmod 0777 test/zdtm/static
|
|
|
|
chmod 0777 test/zdtm/transition
|
|
|
|
|
2020-06-10 20:25:36 +00:00
|
|
|
# We run streaming tests separately to improve test completion times,
|
|
|
|
# hence the exit 0.
|
|
|
|
if [ "${STREAM_TEST}" = "1" ]; then
|
|
|
|
./scripts/install-criu-image-streamer.sh
|
|
|
|
test_stream
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
./test/zdtm.py run -a -p 2 --keep-going "${ZDTM_OPTS[@]}"
|
2022-01-14 12:12:12 +03:00
|
|
|
if criu/criu check --feature move_mount_set_group; then
|
2022-04-12 17:07:43 -07:00
|
|
|
./test/zdtm.py run -a -p 2 --mntns-compat-mode --keep-going "${ZDTM_OPTS[@]}"
|
2022-01-14 12:12:12 +03:00
|
|
|
fi
|
2017-05-31 12:51:41 +03:00
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
./test/zdtm.py run -a -p 2 --keep-going --criu-config "${ZDTM_OPTS[@]}"
|
2021-08-15 11:29:22 +01:00
|
|
|
|
2021-11-04 09:10:38 +00:00
|
|
|
# Newer kernels are blocking access to userfaultfd:
|
|
|
|
# uffd: Set unprivileged_userfaultfd sysctl knob to 1 if kernel faults must be handled without obtaining CAP_SYS_PTRACE capability
|
|
|
|
if [ -e /proc/sys/vm/unprivileged_userfaultfd ]; then
|
|
|
|
echo 1 > /proc/sys/vm/unprivileged_userfaultfd
|
|
|
|
fi
|
|
|
|
|
2022-04-12 17:07:43 -07:00
|
|
|
LAZY_EXCLUDE=(-x maps04 -x cmdlinenv00 -x maps007)
|
2017-10-08 16:19:40 +03:00
|
|
|
|
2020-11-08 09:50:23 +02:00
|
|
|
LAZY_TESTS='.*(maps0|uffd-events|lazy-thp|futex|fork).*'
|
2022-04-12 17:07:43 -07:00
|
|
|
LAZY_OPTS=(-p 2 -T "$LAZY_TESTS" "${LAZY_EXCLUDE[@]}" "${ZDTM_OPTS[@]}")
|
|
|
|
|
|
|
|
./test/zdtm.py run "${LAZY_OPTS[@]}" --lazy-pages
|
|
|
|
./test/zdtm.py run "${LAZY_OPTS[@]}" --remote-lazy-pages
|
|
|
|
./test/zdtm.py run "${LAZY_OPTS[@]}" --remote-lazy-pages --tls
|
2016-07-06 05:01:59 +03:00
|
|
|
|
2020-11-04 07:51:32 +00:00
|
|
|
bash -x ./test/jenkins/criu-fault.sh
|
|
|
|
if [ "$UNAME_M" == "x86_64" ]; then
|
|
|
|
# This fails on aarch64 (aws-graviton2) with:
|
|
|
|
# 33: ERR: thread-bomb.c:49: pthread_attr_setstacksize(): 22
|
|
|
|
bash -x ./test/jenkins/criu-fcg.sh
|
|
|
|
fi
|
|
|
|
bash -x ./test/jenkins/criu-inhfd.sh
|
2016-07-06 05:01:59 +03:00
|
|
|
|
2018-06-02 00:03:04 +03:00
|
|
|
if [ -z "$SKIP_EXT_DEV_TEST" ]; then
|
|
|
|
make -C test/others/mnt-ext-dev/ run
|
2022-01-14 19:29:08 +03:00
|
|
|
if criu/criu check --feature move_mount_set_group; then
|
|
|
|
EXTRA_OPTS=--mntns-compat-mode make -C test/others/mnt-ext-dev/ run
|
|
|
|
fi
|
2018-06-02 00:03:04 +03:00
|
|
|
fi
|
2021-06-15 06:02:55 +00:00
|
|
|
|
2018-03-02 00:49:12 +03:00
|
|
|
make -C test/others/make/ run CC="$CC"
|
2020-12-16 18:58:23 +00:00
|
|
|
if [ -n "$TRAVIS" ] || [ -n "$CIRCLECI" ]; then
|
2021-03-19 08:57:04 +00:00
|
|
|
# GitHub Actions (and Cirrus CI) does not provide a real TTY and CRIU will fail with:
|
2020-11-07 12:40:22 +00:00
|
|
|
# Error (criu/tty.c:1014): tty: Don't have tty to inherit session from, aborting
|
|
|
|
make -C test/others/shell-job/ run
|
|
|
|
fi
|
2022-06-03 09:47:11 -07:00
|
|
|
make -C test/others/skip-file-rwx-check/ run
|
2021-12-21 23:42:26 +03:00
|
|
|
make -C test/others/rpc/ run
|
2016-07-06 05:01:59 +03:00
|
|
|
|
|
|
|
./test/zdtm.py run -t zdtm/static/env00 --sibling
|
|
|
|
|
|
|
|
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --dedup
|
2016-09-02 00:12:00 +03:00
|
|
|
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --noauto-dedup
|
2016-07-06 05:01:59 +03:00
|
|
|
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --page-server
|
2016-09-02 00:12:00 +03:00
|
|
|
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --page-server --dedup
|
2022-04-28 18:51:32 +03:00
|
|
|
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --pre-dump-mode read
|
2016-07-06 05:01:59 +03:00
|
|
|
|
2021-04-20 23:46:15 +02:00
|
|
|
./test/zdtm.py run -t zdtm/transition/pid_reuse --pre 2 # start time based pid reuse detection
|
|
|
|
./test/zdtm.py run -t zdtm/transition/pidfd_store_sk --rpc --pre 2 # pidfd based pid reuse detection
|
2021-01-22 01:08:59 +02:00
|
|
|
|
2016-07-06 05:01:59 +03:00
|
|
|
./test/zdtm.py run -t zdtm/static/socket-tcp-local --norst
|
|
|
|
|
|
|
|
ip net add test
|
|
|
|
./test/zdtm.py run -t zdtm/static/env00 -f h --join-ns
|
2016-06-03 05:33:00 +03:00
|
|
|
|
2016-11-08 07:38:38 +03:00
|
|
|
# RPC testing
|
|
|
|
./test/zdtm.py run -t zdtm/static/env00 --rpc # Basic
|
2017-05-17 08:07:13 +03:00
|
|
|
./test/zdtm.py run -t zdtm/static/env00 --rpc --pre 2 --page-server
|
2016-11-08 07:38:38 +03:00
|
|
|
./test/zdtm.py run -t zdtm/static/ptrace_sig -f h --rpc # Error handling (crfail test)
|
|
|
|
|
2017-05-04 23:27:47 +03:00
|
|
|
./test/zdtm.py run --empty-ns -T zdtm/static/socket-tcp*-local --iter 2
|
|
|
|
|
2021-07-14 14:41:59 +00:00
|
|
|
./test/zdtm.py run -t zdtm/static/env00 -t zdtm/transition/fork -t zdtm/static/ghost_holes00 -t zdtm/static/socket-tcp -t zdtm/static/msgque -k always
|
2018-06-02 00:02:56 +03:00
|
|
|
./test/crit-recode.py
|
|
|
|
|
2021-03-15 14:06:18 +00:00
|
|
|
# more crit testing
|
|
|
|
make -C test/others/crit run
|
|
|
|
|
2021-09-05 23:06:56 +01:00
|
|
|
# coredump testing
|
|
|
|
make -C test/others/criu-coredump run
|
|
|
|
|
2019-09-16 06:49:07 +00:00
|
|
|
# libcriu testing
|
|
|
|
make -C test/others/libcriu run
|
|
|
|
|
2020-05-06 08:04:45 +00:00
|
|
|
# external namespace testing
|
|
|
|
make -C test/others/ns_ext run
|
2021-01-11 22:59:06 +00:00
|
|
|
|
2021-06-16 07:19:30 +00:00
|
|
|
# config file parser and parameter testing
|
|
|
|
make -C test/others/config-file run
|
|
|
|
|
2021-02-01 11:08:24 +00:00
|
|
|
# Skip all further tests when running with GCOV=1
|
|
|
|
# The one test which currently cannot handle GCOV testing is compel/test
|
|
|
|
# Probably because the GCOV Makefile infrastructure does not exist in compel
|
|
|
|
[ -n "$GCOV" ] && exit 0
|
|
|
|
|
2021-01-11 22:59:06 +00:00
|
|
|
# compel testing
|
|
|
|
make -C compel/test
|