Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tests/integration/cgroups.bats
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ function setup() {
# usually triggered by the "change" event from losetup, we can wait for a
# little bit before continuing the test. For more details, see
# <https://github.com/opencontainers/runc/issues/4781>.
sleep 2s
if host_is_os ".*suse.*"; then
sleep 2s
fi

# See if BFQ scheduler is available.
if ! { grep -qw bfq "/sys/block/${dev#/dev/}/queue/scheduler" &&
Expand Down
16 changes: 13 additions & 3 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,23 @@ function requires() {
# variables in /etc/os-release. The arguments are regular expressions, and any
# match will cause the test to be skipped.
function exclude_os() {
if host_is_os "$@"; then
skip "test doesn't work on these OSes: $*"
fi
}

# Similar to exclude_os, but it doesn't skip the test and just returns 0 if it
# matches, 1 if it doesn't.
function host_is_os() {
local host
host="$(sh -c '. /etc/os-release ; echo "$ID-$VERSION_ID"')"
for bad_os in "$@"; do
if [[ "$host" =~ ^$bad_os$ ]]; then
skip "test doesn't work on $bad_os"
for os in "$@"; do
if [[ "$host" =~ ^$os$ ]]; then
echo "host is $os" >&2
return 0
fi
done
return 1
}

# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
Expand Down