mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
iotests: Skip read-only cases in 118 when run as root
Some tests in 118 use chmod to remove write permissions from the file and assume that the image can indeed not be opened read-write afterwards. This doesn't work when the test is run as root, because root can still open the file as writable even when the permission bit isn't set. Introduce a @skip_if_root decorator and use it in 118 to skip the tests in question when the script is run as root. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
35e32d9e2e
commit
d926f4ddd2
2 changed files with 13 additions and 0 deletions
|
@ -931,6 +931,16 @@ def skip_if_unsupported(required_formats=[], read_only=False):
|
|||
return func_wrapper
|
||||
return skip_test_decorator
|
||||
|
||||
def skip_if_user_is_root(func):
|
||||
'''Skip Test Decorator
|
||||
Runs the test only without root permissions'''
|
||||
def func_wrapper(*args, **kwargs):
|
||||
if os.getuid() == 0:
|
||||
case_notrun('{}: cannot be run as root'.format(args[0]))
|
||||
else:
|
||||
return func(*args, **kwargs)
|
||||
return func_wrapper
|
||||
|
||||
def execute_unittest(output, verbosity, debug):
|
||||
runner = unittest.TextTestRunner(stream=output, descriptions=True,
|
||||
verbosity=verbosity)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue