mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
47 lines
1.1 KiB
Bash
47 lines
1.1 KiB
Bash
fail() {
|
|
echo "ERROR" $@
|
|
exit 1
|
|
}
|
|
|
|
test_equal() {
|
|
local expected="$1"
|
|
shift
|
|
"$@" 2>&1 | diff -u <(echo "$expected") -
|
|
}
|
|
|
|
test_regexp() {
|
|
local REGEXP="$1"
|
|
shift
|
|
local ACTUAL=$("$@" 2>&1)
|
|
if ! echo "$ACTUAL" | grep -E -q "$REGEXP"; then
|
|
echo "Can not find '$REGEXP' in '$ACTUAL'"
|
|
fail
|
|
fi
|
|
}
|
|
|
|
# check if reboot is supported; this needs running with autopkgtest on a
|
|
# supported testbed (QEMU or ssh with a setup script that announces the
|
|
# "reboot" capability)
|
|
can_reboot() {
|
|
[ -x /tmp/autopkgtest-reboot ]
|
|
}
|
|
|
|
# reboot the testbed; the same test will be started again, check after_reboot()
|
|
# to see in which state you are in
|
|
reboot() {
|
|
if [ -z "$CURRENT_TEST" ]; then
|
|
echo 'ERROR: $CURRENT_TEST not defined' >&2
|
|
exit 1
|
|
fi
|
|
echo "Rebooting testbed..."
|
|
sudo /tmp/autopkgtest-reboot "$CURRENT_TEST"
|
|
}
|
|
|
|
# true if the current test reboot()ed and is now restarted after boot; false if
|
|
# it's the first time the test runs (or reboot is not supported)
|
|
after_reboot() {
|
|
[ "$ADT_REBOOT_MARK" = "$CURRENT_TEST" ]
|
|
}
|
|
|
|
# vim: filetype=sh shiftwidth=4
|