summaryrefslogtreecommitdiff
path: root/test/system/helpers.bash
diff options
context:
space:
mode:
Diffstat (limited to 'test/system/helpers.bash')
-rw-r--r--test/system/helpers.bash33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 28ea924bb..03e1ab82b 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -428,6 +428,18 @@ function skip_if_cgroupsv1() {
fi
}
+######################
+# skip_if_rootless_cgroupsv1 # ...with an optional message
+######################
+function skip_if_rootless_cgroupsv1() {
+ if is_rootless; then
+ if ! is_cgroupsv2; then
+ local msg=$(_add_label_if_missing "$1" "rootless cgroupvs1")
+ skip "${msg:-not supported as rootless under cgroupsv1}"
+ fi
+ fi
+}
+
##################################
# skip_if_journald_unavailable # rhbz#1895105: rootless journald permissions
##################################
@@ -466,13 +478,30 @@ function is() {
local expect="$2"
local testname="${3:-${MOST_RECENT_PODMAN_COMMAND:-[no test name given]}}"
+ local is_expr=
if [ -z "$expect" ]; then
if [ -z "$actual" ]; then
+ # Both strings are empty.
return
fi
expect='[no output]'
- elif expr "$actual" : "$expect" >/dev/null; then
+ elif [[ "$actual" = "$expect" ]]; then
+ # Strings are identical.
return
+ else
+ # Strings are not identical. Are there wild cards in our expect string?
+ if expr "$expect" : ".*[^\\][\*\[]" >/dev/null; then
+ # There is a '[' or '*' without a preceding backslash.
+ is_expr=' (using expr)'
+ elif [[ "${expect:0:1}" = '[' ]]; then
+ # String starts with '[', e.g. checking seconds like '[345]'
+ is_expr=' (using expr)'
+ fi
+ if [[ -n "$is_expr" ]]; then
+ if expr "$actual" : "$expect" >/dev/null; then
+ return
+ fi
+ fi
fi
# This is a multi-line message, which may in turn contain multi-line
@@ -481,7 +510,7 @@ function is() {
readarray -t actual_split <<<"$actual"
printf "#/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n" >&2
printf "#| FAIL: $testname\n" >&2
- printf "#| expected: '%s'\n" "$expect" >&2
+ printf "#| expected: '%s'%s\n" "$expect" "$is_expr" >&2
printf "#| actual: '%s'\n" "${actual_split[0]}" >&2
local line
for line in "${actual_split[@]:1}"; do