diff options
author | Adrian Reber <areber@redhat.com> | 2021-06-16 10:19:30 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2021-09-03 20:31:00 +0300 |
commit | 45bde968a26e21d060de86e6490c8d10d7a191b5 (patch) | |
tree | 3bce04b1fd0175fc8ae5dfcaf93b035914d1e37f /test/others/config-file | |
parent | f695e6e107c8b19bdaf7c1476fd048d1327cea65 (diff) |
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>
Diffstat (limited to 'test/others/config-file')
-rw-r--r-- | test/others/config-file/Makefile | 3 | ||||
-rw-r--r-- | test/others/config-file/conf1.test | 13 | ||||
-rw-r--r-- | test/others/config-file/conf2.test | 16 | ||||
-rw-r--r-- | test/others/config-file/conf3.test | 17 | ||||
-rwxr-xr-x | test/others/config-file/run.sh | 108 |
5 files changed, 157 insertions, 0 deletions
diff --git a/test/others/config-file/Makefile b/test/others/config-file/Makefile new file mode 100644 index 000000000..594edc070 --- /dev/null +++ b/test/others/config-file/Makefile @@ -0,0 +1,3 @@ +run: + ./run.sh +.PHONY: run diff --git a/test/others/config-file/conf1.test b/test/others/config-file/conf1.test new file mode 100644 index 000000000..68d3aba31 --- /dev/null +++ b/test/others/config-file/conf1.test @@ -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\"" diff --git a/test/others/config-file/conf2.test b/test/others/config-file/conf2.test new file mode 100644 index 000000000..41c6c4f92 --- /dev/null +++ b/test/others/config-file/conf2.test @@ -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\"" diff --git a/test/others/config-file/conf3.test b/test/others/config-file/conf3.test new file mode 100644 index 000000000..fe82a5835 --- /dev/null +++ b/test/others/config-file/conf3.test @@ -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 diff --git a/test/others/config-file/run.sh b/test/others/config-file/run.sh new file mode 100755 index 000000000..92195883e --- /dev/null +++ b/test/others/config-file/run.sh @@ -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 |