mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
test: add tests for configuration file parsing
This adds a test run to ensure known (but fixed) configuration file parser errors are not crashing CRIU anymore. Based on missing test code coverage this script also tests code paths of the option handling which have not been tested until now. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
committed by
Andrei Vagin
parent
f695e6e107
commit
45bde968a2
1
Makefile
1
Makefile
@@ -405,6 +405,7 @@ lint:
|
|||||||
shellcheck scripts/*.sh
|
shellcheck scripts/*.sh
|
||||||
shellcheck scripts/ci/*.sh scripts/ci/apt-install
|
shellcheck scripts/ci/*.sh scripts/ci/apt-install
|
||||||
shellcheck test/others/crit/*.sh
|
shellcheck test/others/crit/*.sh
|
||||||
|
shellcheck test/others/config-file/*.sh
|
||||||
# Do not append \n to pr_perror or fail
|
# Do not append \n to pr_perror or fail
|
||||||
! git --no-pager grep -E '^\s*\<(pr_perror|fail)\>.*\\n"'
|
! git --no-pager grep -E '^\s*\<(pr_perror|fail)\>.*\\n"'
|
||||||
# Do not use %m with pr_perror or fail
|
# Do not use %m with pr_perror or fail
|
||||||
|
@@ -261,6 +261,9 @@ make -C test/others/libcriu run
|
|||||||
# external namespace testing
|
# external namespace testing
|
||||||
make -C test/others/ns_ext run
|
make -C test/others/ns_ext run
|
||||||
|
|
||||||
|
# config file parser and parameter testing
|
||||||
|
make -C test/others/config-file 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
|
||||||
|
3
test/others/config-file/Makefile
Normal file
3
test/others/config-file/Makefile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
run:
|
||||||
|
./run.sh
|
||||||
|
.PHONY: run
|
13
test/others/config-file/conf1.test
Normal file
13
test/others/config-file/conf1.test
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
verbosity 4
|
||||||
|
lsm-profile "" # more comments
|
||||||
|
lsm-profile "something"# comment
|
||||||
|
lsm-profile "selinux:something\"with\"quotes"
|
||||||
|
lsm-profile "apparmor:something\"with\"quotes"
|
||||||
|
work-dir /tmp
|
||||||
|
work-dir "/tmp"
|
||||||
|
work-dir "/dir with spaces"
|
||||||
|
a b c d e f g h i j k l m n o p
|
||||||
|
dsfa "aaaaa \"bbbbbb\""
|
16
test/others/config-file/conf2.test
Normal file
16
test/others/config-file/conf2.test
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
verbosity 4
|
||||||
|
lsm-profile "" # more comments
|
||||||
|
lsm-profile "something"# comment
|
||||||
|
lsm-profile "selinux:something\"with\"quotes"
|
||||||
|
lsm-profile "apparmor:something\"with\"quotes"
|
||||||
|
work-dir /tmp
|
||||||
|
work-dir "/tmp"
|
||||||
|
work-dir "/dir with spaces"
|
||||||
|
work-dir "/dir with spaces" #comment
|
||||||
|
work-dir "/dir with spaces" # comment
|
||||||
|
work-dir "/dir with spaces"# comment
|
||||||
|
work-dir "/dir with spaces"#comment
|
||||||
|
dsfa "aaaaa \"bbbbbb\""
|
17
test/others/config-file/conf3.test
Normal file
17
test/others/config-file/conf3.test
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
verbosity 4
|
||||||
|
lsm-profile "" # more comments
|
||||||
|
lsm-profile "something"# comment
|
||||||
|
lsm-profile "selinux:something\"with\"quotes"
|
||||||
|
lsm-profile "apparmor:something\"with\"quotes"
|
||||||
|
work-dir /tmp
|
||||||
|
work-dir "/tmp"
|
||||||
|
work-dir "/dir with spaces"
|
||||||
|
work-dir "/dir with spaces" #comment
|
||||||
|
work-dir "/dir with spaces" # comment
|
||||||
|
work-dir "/dir with spaces"# comment
|
||||||
|
work-dir "/dir with spaces"#comment
|
||||||
|
dsfa "aaaaa \"bbbbbb\""
|
||||||
|
dsfa "aaaaa \"bbbbbb\"" more
|
108
test/others/config-file/run.sh
Executable file
108
test/others/config-file/run.sh
Executable file
@@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# This script tries to run criu with different options to ensure
|
||||||
|
# the configuration file and option handling does not break.
|
||||||
|
#
|
||||||
|
# The options have been selected by looking at the existing
|
||||||
|
# test code coverage and missing code coverage should be handled
|
||||||
|
# by the options used in this file.
|
||||||
|
#
|
||||||
|
# This script tries to only exit if criu crashes. A return value
|
||||||
|
# of '1' should not stop the script.
|
||||||
|
|
||||||
|
set -xbm
|
||||||
|
|
||||||
|
#shellcheck disable=SC1091
|
||||||
|
source ../env.sh
|
||||||
|
|
||||||
|
if [ ! -d /etc/criu ]; then
|
||||||
|
mkdir -p /etc/criu
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e /etc/criu/default.conf ]; then
|
||||||
|
touch /etc/criu/default.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This tries to capture any exit codes other than 0 and 1
|
||||||
|
# Especially looking for crashes
|
||||||
|
trap '
|
||||||
|
RESULT=$?
|
||||||
|
if [[ $RESULT -gt 1 ]]; then
|
||||||
|
echo "unexpected exit code $RESULT"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
' CHLD
|
||||||
|
|
||||||
|
# Just some random combination of flags
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -v0
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf conf1.test
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf1.test
|
||||||
|
$CRIU check --pre-dump-mode invalid --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf1.test
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf conf2.test
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf2.test
|
||||||
|
$CRIU check --pre-dump-mode invalid --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf2.test
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf conf3.test
|
||||||
|
$CRIU check --pre-dump-mode splice --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf3.test
|
||||||
|
$CRIU check --pre-dump-mode invalid --auto-dedup --page-server --track-mem --display-stats -v0 --conf=conf3.test
|
||||||
|
$CRIU check --no-default-config
|
||||||
|
$CRIU check --no-default-config --config=conf
|
||||||
|
$CRIU check --no-default-config --config=conf1.test
|
||||||
|
$CRIU check --no-default-config --config=conf1.test --help
|
||||||
|
$CRIU check --no-default-config --config=conf1.test --h
|
||||||
|
$CRIU check --no-default-config --config=conf2.test
|
||||||
|
$CRIU check --no-default-config --config=conf2.test --help
|
||||||
|
$CRIU check --no-default-config --config=conf2.test --h
|
||||||
|
$CRIU check --no-default-config --config=conf3.test
|
||||||
|
$CRIU check --no-default-config --config=conf3.test --help
|
||||||
|
$CRIU check --no-default-config --config=conf3.test --h
|
||||||
|
|
||||||
|
if [ ! -e "$HOME"/.criu.default ]; then
|
||||||
|
touch "$HOME"/.criu.default
|
||||||
|
fi
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -v0 -s -t "-1"
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -S -R -vvvvvv
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -J invalidjoin-invalid
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -d -r
|
||||||
|
$CRIU check --pre-dump-mode read --auto-dedup --page-server --track-mem --display-stats -d -r none
|
||||||
|
unset HOME
|
||||||
|
$CRIU check --close
|
||||||
|
export HOME=/ROOOOT
|
||||||
|
$CRIU check --close
|
||||||
|
$CRIU check --port
|
||||||
|
$CRIU check --port 20000
|
||||||
|
$CRIU check --port some-port -l
|
||||||
|
CRIU_CONFIG_FILE=conf $CRIU check --port some-port -l
|
||||||
|
CRIU_CONFIG_FILE=conf1.test $CRIU check
|
||||||
|
CRIU_CONFIG_FILE=conf2.test $CRIU check
|
||||||
|
CRIU_CONFIG_FILE=conf3.test $CRIU check
|
||||||
|
CRIU_CONFIG_FILE=conf1.test $CRIU check --port some-port -l
|
||||||
|
CRIU_CONFIG_FILE=conf2.test $CRIU check --port some-port -l
|
||||||
|
CRIU_CONFIG_FILE=conf3.test $CRIU check --port some-port -l
|
||||||
|
$CRIU check --ms -L
|
||||||
|
CRIU_DEPRECATED=1 $CRIU check --ms
|
||||||
|
CRIU_DEPRECATED=1 $CRIU check
|
||||||
|
$CRIU check -l
|
||||||
|
$CRIU check -l 17
|
||||||
|
$CRIU check -L
|
||||||
|
$CRIU check -L 13
|
||||||
|
$CRIU check -L /tmp
|
||||||
|
$CRIU check --skip-mnt
|
||||||
|
$CRIU check --skip-mnt 13
|
||||||
|
$CRIU check --skip-mnt -13
|
||||||
|
$CRIU check --skip-mnt /tmp
|
||||||
|
$CRIU check --force-irmap --link-remap --evasive-devices
|
||||||
|
$CRIU check -M 1:2 --status-fd
|
||||||
|
$CRIU check -M 1:2 --status-fd 1 --ps-socket 1
|
||||||
|
$CRIU check -M 1:2 --status-fd 1 --ps-socket 1 -D
|
||||||
|
$CRIU check -M 1:2 --status-fd 1 --ps-socket 1 --port 4242
|
||||||
|
$CRIU check -M 1:2 --status-fd 1 --ps-socket one
|
||||||
|
$CRIU check -M 1:2 --status-fd one
|
||||||
|
$CRIU check --cgroup-props conf.test --cgroup-props-file conf.test
|
||||||
|
$CRIU -V
|
||||||
|
$CRIU dump --file-validation
|
||||||
|
$CRIU restore --file-validation 1
|
||||||
|
$CRIU check --file-validation filesizefilesize
|
||||||
|
$CRIU dump --file-validation filesize
|
||||||
|
$CRIU restore --file-validation buildid
|
||||||
|
$CRIU check --file-validation buildid --deprecated
|
||||||
|
exit 0
|
Reference in New Issue
Block a user