To be used in the next commit: that would be a test for TAP networking, and it will need to setup TAP device.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Tested-by: Lei Yang <[email protected]> Reviewed-by: Maksim Davydov <[email protected]> --- tests/functional/qemu_test/decorators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py index b239295804..125d31dda6 100644 --- a/tests/functional/qemu_test/decorators.py +++ b/tests/functional/qemu_test/decorators.py @@ -6,6 +6,7 @@ import os import platform import resource +import subprocess from unittest import skipIf, skipUnless from .cmd import which @@ -167,3 +168,18 @@ def skipLockedMemoryTest(locked_memory): ulimit_memory == resource.RLIM_INFINITY or ulimit_memory >= locked_memory * 1024, f'Test required {locked_memory} kB of available locked memory', ) + +''' +Decorator to skip execution of a test if passwordless +sudo command is not available. +''' +def skipWithoutSudo(): + proc = subprocess.run(["sudo", "-n", "/bin/true"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True, + check=False) + + return skipUnless(proc.returncode == 0, + f'requires password-less sudo access: {proc.stdout}') -- 2.48.1
