integration: add requires() function
This is similar to the testRequires() function in the Docker test suite. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
4fd8a7aafa
commit
72ee54918f
|
@ -12,9 +12,7 @@ function teardown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checkpoint and restore" {
|
@test "checkpoint and restore" {
|
||||||
if [ ! -e "$CRIU" ] ; then
|
requires criu
|
||||||
skip
|
|
||||||
fi
|
|
||||||
|
|
||||||
# criu does not work with external terminals so..
|
# criu does not work with external terminals so..
|
||||||
# setting terminal and root:readonly: to false
|
# setting terminal and root:readonly: to false
|
||||||
|
|
|
@ -33,10 +33,34 @@ function runc() {
|
||||||
run __runc "$@"
|
run __runc "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Raw wrapper for runc.
|
||||||
function __runc() {
|
function __runc() {
|
||||||
"$RUNC" --root "$ROOT" "$@"
|
"$RUNC" --root "$ROOT" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fails the current test, providing the error given.
|
||||||
|
function fail() {
|
||||||
|
echo "$@" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Allows a test to specify what things it requires. If the environment can't
|
||||||
|
# support it, the test is skipped with a message.
|
||||||
|
function requires() {
|
||||||
|
for var in "$@"; do
|
||||||
|
case $var in
|
||||||
|
criu)
|
||||||
|
if [ ! -e "$CRIU" ]; then
|
||||||
|
skip "Test requires ${var}."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fail "BUG: Invalid requires ${var}."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
|
# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
|
||||||
function retry() {
|
function retry() {
|
||||||
local attempts=$1
|
local attempts=$1
|
||||||
|
|
Loading…
Reference in New Issue