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
2024-02-09 13:04:58 +00:00
libnl-route-3-dev time libbsd-dev python3-yaml
2023-06-21 23:48:32 +01:00
libperl-dev pkg-config python3-protobuf python3-pip
2023-09-30 02:56:52 +01:00
python3-importlib-metadata python3-junit.xml libdrm-dev)
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 "
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
2022-11-07 08:26:10 +01:00
# Umount cpuset in cgroupv1 to make it move to cgroupv2
if [ -d /sys/fs/cgroup/cpuset ] ; then
umount /sys/fs/cgroup/cpuset
fi
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
2023-03-08 18:19:17 +05:30
make -C test/others/criu-ns/ run
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
2024-05-23 07:57:14 +01:00
./test/zdtm.py run -t zdtm/static/maps00 --preload-libfault
./test/zdtm.py run -t zdtm/static/maps02 --preload-libfault
2016-07-06 05:01:59 +03:00
./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
2023-02-02 09:43:37 -08:00
# Rootless tests
# Check if cap_checkpoint_restore is supported and also if unshare -c is supported.
2023-11-30 15:10:23 +00:00
#
# Do not run this test in a container (see https://github.com/checkpoint-restore/criu/issues/2312).
2023-12-20 15:22:48 -08:00
# Before v6.8-rc1~215^2~6, the kernel currently did not show correct device and
# inode numbers in /proc/pid/maps for stackable file systems.
skip = 0
findmnt -no FSTYPE / | grep overlay && {
./criu/criu check --feature overlayfs_maps || skip = 1
}
unshare -c /bin/true || skip = 1
capsh --supports= cap_checkpoint_restore || skip = 1
if [ " $skip " = = 0 ] ; then
2023-02-02 09:43:37 -08:00
make -C test/zdtm/ cleanout
rm -rf test/dump
setcap cap_checkpoint_restore,cap_sys_ptrace+eip criu/criu
2023-11-30 15:10:23 +00:00
if [ -d /sys/fs/selinux ] && command -v getenforce & >/dev/null; then
2023-11-29 14:56:41 +00:00
# Note: selinux in Enforcing mode prevents us from calling clone3() or writing to ns_last_pid on restore; hence set to Permissive for the test and then set back.
selinuxmode = $( getenforce)
2024-05-21 09:25:30 +01:00
if [ " $selinuxmode " != "Disabled" ] ; then
setenforce Permissive
fi
2023-11-29 14:56:41 +00:00
fi
2023-02-02 09:43:37 -08:00
# Run it as non-root in a user namespace. Since CAP_CHECKPOINT_RESTORE behaves differently in non-user namespaces (e.g. no access to map_files) this tests that we can dump and restore
# under those conditions. Note that the "... && true" part is necessary; we need at least one statement after the tests so that bash can reap zombies in the user namespace,
# otherwise it will exec the last statement and get replaced and nobody will be left to reap our zombies.
sudo --user= #65534 --group=#65534 unshare -Ucfpm --mount-proc -- bash -c "./test/zdtm.py run -t zdtm/static/maps00 -f h --rootless && true"
2023-11-30 15:10:23 +00:00
if [ -d /sys/fs/selinux ] && command -v getenforce & >/dev/null; then
2024-05-21 09:25:30 +01:00
if [ " $selinuxmode " != "Disabled" ] ; then
setenforce " $selinuxmode "
fi
2023-11-29 14:56:41 +00:00
fi
2023-02-02 09:43:37 -08:00
setcap -r criu/criu
else
echo "Skipping unprivileged mode tests"
fi
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
2023-03-23 20:21:04 +00:00
# action script testing
make -C test/others/action-script 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
2023-09-30 02:56:52 +01:00
2024-07-20 13:17:09 +01:00
# amdgpu and cuda plugin testing
2023-09-30 02:56:52 +01:00
make amdgpu_plugin
make -C plugins/amdgpu/ test_topology_remap
./plugins/amdgpu/test_topology_remap
2024-07-20 13:17:09 +01:00
2024-08-12 08:08:10 -07:00
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin cuda
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin amdgpu
./test/zdtm.py run -t zdtm/static/maps00 -t zdtm/static/maps02 --criu-plugin amdgpu cuda
2024-07-20 13:17:09 +01:00
2024-08-12 08:08:10 -07:00
./test/zdtm.py run -t zdtm/static/sigpending -t zdtm/static/pthread00 --mocked-cuda-checkpoint