tests/int: fix some checks

Apparently, bash with set -e deliberately ignores non-zero return codes
from ! cmd, unless this is the last command. The workaround is to either
use "! cmd || false', "or run ! cmd". Choose the latter, and require
bash-core 1.5.0 (since this is when "run !" was added), replacing the
older check.

Alas I only learned this recently from the bash-core documentation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2023-04-05 15:15:07 -07:00
parent 9dbb9f90b9
commit 9b71787be0
3 changed files with 8 additions and 12 deletions
+4 -4
View File
@@ -355,7 +355,7 @@ function simple_cr() {
runc checkpoint --work-path ./work-dir test_busybox
grep -B 5 Error ./work-dir/dump.log || true
[ "$status" -eq 0 ]
! test -f ./work-dir/"$tmplog1"
run ! test -f ./work-dir/"$tmplog1"
test -f ./work-dir/"$tmplog2"
# after checkpoint busybox is no longer running
@@ -366,7 +366,7 @@ function simple_cr() {
runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
grep -B 5 Error ./work-dir/restore.log || true
[ "$status" -eq 0 ]
! test -f ./work-dir/"$tmplog1"
run ! test -f ./work-dir/"$tmplog1"
test -f ./work-dir/"$tmplog2"
# busybox should be back up and running
@@ -434,7 +434,7 @@ function simple_cr() {
[ "$status" -eq 0 ]
testcontainer test_busybox checkpointed
# Check that the cgroup is gone.
! test -d "$orig_path"
run ! test -d "$orig_path"
# Restore into a different cgroup.
set_cgroups_path # Changes the path.
@@ -445,7 +445,7 @@ function simple_cr() {
testcontainer test_busybox running
# Check that the old cgroup path doesn't exist.
! test -d "$orig_path"
run ! test -d "$orig_path"
# Check that the new path exists.
local new_path
+2 -2
View File
@@ -234,12 +234,12 @@ function check_exec_debug() {
# Check we can join top-level cgroup (implicit).
runc exec test_busybox cat /proc/self/cgroup
[ "$status" -eq 0 ]
! grep -v ":$REL_CGROUPS_PATH\$" <<<"$output"
run ! grep -v ":$REL_CGROUPS_PATH\$" <<<"$output"
# Check we can join top-level cgroup (explicit).
runc exec --cgroup / test_busybox cat /proc/self/cgroup
[ "$status" -eq 0 ]
! grep -v ":$REL_CGROUPS_PATH\$" <<<"$output"
run ! grep -v ":$REL_CGROUPS_PATH\$" <<<"$output"
# Create a few subcgroups.
# Note that cpu,cpuacct may be mounted together or separate.
+2 -6
View File
@@ -2,11 +2,7 @@
set -u
# bats-core v1.2.1 defines BATS_RUN_TMPDIR.
if [ ! -v BATS_RUN_TMPDIR ]; then
echo "bats >= v1.2.1 is required. Aborting." >&2
exit 1
fi
bats_require_minimum_version 1.5.0
# Root directory of integration tests.
INTEGRATION_ROOT=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
@@ -357,7 +353,7 @@ function have_criu() {
# Workaround for https://github.com/opencontainers/runc/issues/3532.
local ver
ver=$(rpm -q criu 2>/dev/null || true)
! grep -q '^criu-3\.17-[123]\.el9' <<<"$ver"
run ! grep -q '^criu-3\.17-[123]\.el9' <<<"$ver"
}
# Allows a test to specify what things it requires. If the environment can't