2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-27 20:37:57 +00:00
criu/test/others/rpc/run.sh
Adrian Reber eba1fba8b3 tests: fix builds on alpine and centos
Install sudo, create test user with ID 1000, install bash,
fix pidfile creation and pidfile chmod.

v2:
 * use sleep to give the criu daemon some time to start up

v3:
 * Andrei is of course right and sleep is not good solution.
   After adding --status-fd support to criu service, this
   is how we now detect that criu is ready.

v4:
 * This was much more complicated than expected which is related
   to the different versions of the tools on the different travis
   test targets. There seems to be a bug in bash on Ubuntu
    https://lists.gnu.org/archive/html/bug-bash/2017-07/msg00039.html
   which prevents using 'read -n1' on Ubuntu. As a workaround
   the result from CRIU's status FD is now read via python.

   Another problem was discovered on alpine with the loop restore test.
   CRIU says to use setsid even if the process is already using setsid.
   As a workaround, still with setsid, this process is now using
   shell-job true for checkpoint and restore.

Parts of v2 have been committed before. So the changes from this commit
are partially already in another commit.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-29 01:06:06 +03:00

87 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -e
CRIU=./criu
export PROTODIR=`readlink -f "${PWD}/../../protobuf"`
echo $PROTODIR
function title_print {
echo -e "\n**************************************************"
echo -e "\t\t"$1
echo -e "**************************************************\n"
}
function stop_server {
title_print "Shutdown service server"
kill -SIGTERM $(cat build/pidfile)
unlink build/pidfile
}
function test_c {
mkdir -p build/imgs_c
title_print "Run test-c"
setsid ./test-c build/criu_service.socket build/imgs_c < /dev/null &>> build/output_c
title_print "Restore test-c"
${CRIU} restore -v4 -o restore-c.log -D build/imgs_c
}
function test_py {
mkdir -p build/imgs_py
title_print "Run test-py"
setsid ./test.py build/criu_service.socket build/imgs_py < /dev/null &>> build/output_py
title_print "Restore test-py"
${CRIU} restore -v4 -o restore-py.log -D build/imgs_py
}
function test_restore_loop {
mkdir -p build/imgs_loop
title_print "Run loop.sh"
setsid ./loop.sh < /dev/null &> build/loop.log &
P=${!}
echo "pid ${P}"
title_print "Dump loop.sh"
# So theoretically '-j' (--shell-job) should not be necessary, but on alpine
# this test fails without it.
${CRIU} dump -j -v4 -o dump-loop.log -D build/imgs_loop -t ${P}
title_print "Run restore-loop"
./restore-loop.py build/criu_service.socket build/imgs_loop
kill -SIGTERM ${P}
}
function test_ps {
mkdir -p build/imgs_ps
title_print "Run ps_test"
setsid ./ps_test.py build/criu_service.socket build/imgs_ps < /dev/null &>> build/output_ps
}
function test_errno {
mkdir -p build/imgs_errno
title_print "Run cr_errno test"
setsid ./errno.py build/criu_service.socket build/imgs_errno < /dev/null &>> build/output_errno
}
trap 'echo "FAIL"; stop_server' EXIT
test_c
test_py
test_restore_loop
test_ps
test_errno
stop_server
trap 'echo "Success"' EXIT