]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (functions.sh): add func to detect virtualization platform
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 30 Apr 2023 06:36:23 +0000 (08:36 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 30 Apr 2023 06:36:51 +0000 (08:36 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/functions.sh

index 3d2c93d77af34885cc0c744409069fe13c815128..d22e42608105541f087d1f66747c6c0859b17fdd 100644 (file)
@@ -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
+}