From: Thomas Weißschuh Date: Sun, 30 Apr 2023 06:36:23 +0000 (+0200) Subject: tests: (functions.sh): add func to detect virtualization platform X-Git-Tag: v2.39~40^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=744894aaf3aadb4b4b670ec1cde3626817523863;p=thirdparty%2Futil-linux.git tests: (functions.sh): add func to detect virtualization platform Signed-off-by: Thomas Weißschuh --- diff --git a/tests/functions.sh b/tests/functions.sh index 3d2c93d77a..d22e426081 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -1133,3 +1133,18 @@ function ts_skip_exitcode_not_supported { function ts_inhibit_custom_colorscheme { export XDG_CONFIG_HOME=/dev/null } + +function ts_is_virt { + type "systemd-detect-virt" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + return 1 + fi + + virt="$(systemd-detect-virt)" + for arg in "$@"; do + if [ "$virt" = "$arg" ]; then + return 0; + fi + done + return 1 +}