mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
test/other: add test for action-script
This commit is introducing a test for the action-script functionality of CRIU to verify that pre-dump, post-dump, pre-restore, pre-resume, post-restore, post-resume hooks are executed during dump/restore. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
committed by
Andrei Vagin
parent
ba27d27cd4
commit
2df6ec519d
1
Makefile
1
Makefile
@@ -449,6 +449,7 @@ lint:
|
|||||||
shellcheck -x test/others/libcriu/*.sh
|
shellcheck -x test/others/libcriu/*.sh
|
||||||
shellcheck -x test/others/crit/*.sh test/others/criu-coredump/*.sh
|
shellcheck -x test/others/crit/*.sh test/others/criu-coredump/*.sh
|
||||||
shellcheck -x test/others/config-file/*.sh
|
shellcheck -x test/others/config-file/*.sh
|
||||||
|
shellcheck -x test/others/action-script/*.sh
|
||||||
codespell -S tags
|
codespell -S tags
|
||||||
# Do not append \n to pr_perror, pr_pwarn or fail
|
# Do not append \n to pr_perror, pr_pwarn or fail
|
||||||
! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>.*\\n"'
|
! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>.*\\n"'
|
||||||
|
@@ -316,6 +316,9 @@ make -C test/others/ns_ext run
|
|||||||
# config file parser and parameter testing
|
# config file parser and parameter testing
|
||||||
make -C test/others/config-file run
|
make -C test/others/config-file run
|
||||||
|
|
||||||
|
# action script testing
|
||||||
|
make -C test/others/action-script run
|
||||||
|
|
||||||
# Skip all further tests when running with GCOV=1
|
# Skip all further tests when running with GCOV=1
|
||||||
# The one test which currently cannot handle GCOV testing is compel/test
|
# The one test which currently cannot handle GCOV testing is compel/test
|
||||||
# Probably because the GCOV Makefile infrastructure does not exist in compel
|
# Probably because the GCOV Makefile infrastructure does not exist in compel
|
||||||
|
1
test/others/action-script/.gitignore
vendored
Normal file
1
test/others/action-script/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
img-dir-*
|
5
test/others/action-script/Makefile
Normal file
5
test/others/action-script/Makefile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
run:
|
||||||
|
@make -C .. loop
|
||||||
|
./run.sh
|
||||||
|
|
||||||
|
.PHONY: run
|
2
test/others/action-script/action-script.sh
Executable file
2
test/others/action-script/action-script.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
touch action-hook-"$CRTOOLS_SCRIPT_ACTION"
|
60
test/others/action-script/run.sh
Executable file
60
test/others/action-script/run.sh
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ebm
|
||||||
|
|
||||||
|
# shellcheck source=test/others/env.sh
|
||||||
|
source ../env.sh || exit 1
|
||||||
|
|
||||||
|
SELFDIR="$(dirname "$(readlink -f "$0")")"
|
||||||
|
SCRIPT="$SELFDIR/action-script.sh"
|
||||||
|
IMGDIR="$SELFDIR/img-dir-$$"
|
||||||
|
|
||||||
|
rm -rf "$IMGDIR"
|
||||||
|
mkdir "$IMGDIR"
|
||||||
|
|
||||||
|
trap "cleanup" QUIT TERM INT HUP EXIT
|
||||||
|
|
||||||
|
# shellcheck disable=SC2317
|
||||||
|
# https://github.com/koalaman/shellcheck/issues/2660
|
||||||
|
function cleanup()
|
||||||
|
{
|
||||||
|
if [[ -n "$PID" ]]; then
|
||||||
|
kill -9 "$PID"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
PID=$(../loop)
|
||||||
|
if ! $CRIU dump -v4 -o dump.log -t "$PID" -D "$IMGDIR" --action-script "$SCRIPT"; then
|
||||||
|
echo "Failed to checkpoint process $PID"
|
||||||
|
cat dump.log
|
||||||
|
kill -9 "$PID"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! $CRIU restore -v4 -o restore.log -D "$IMGDIR" -d --pidfile test.pidfile --action-script "$SCRIPT"; then
|
||||||
|
echo "CRIU restore failed"
|
||||||
|
echo FAIL
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PID=$(cat "$IMGDIR"/test.pidfile)
|
||||||
|
|
||||||
|
found_missing_file=false
|
||||||
|
hooks=("pre-dump" "post-dump" "pre-restore" "pre-resume" "post-restore" "post-resume")
|
||||||
|
|
||||||
|
for hook in "${hooks[@]}"
|
||||||
|
do
|
||||||
|
if [ ! -e "$IMGDIR/action-hook-$hook" ]; then
|
||||||
|
echo "ERROR: action-hook-$hook does not exist"
|
||||||
|
found_missing_file=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$found_missing_file" = true ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo PASS
|
||||||
|
|
||||||
|
rm -rf "$IMGDIR"
|
||||||
|
exit 0
|
Reference in New Issue
Block a user