iotests: replace mutable list default args
It's bad hygiene: if we modify this list, it will be modified across all invocations. (Remaining bad usages are fixed in a subsequent patch which changes the function signature anyway.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-5-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
		
							parent
							
								
									368e062003
								
							
						
					
					
						commit
						4eabe0515a
					
				@ -139,7 +139,7 @@ def qemu_img_log(*args):
 | 
				
			|||||||
    log(result, filters=[filter_testfiles])
 | 
					    log(result, filters=[filter_testfiles])
 | 
				
			||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[]):
 | 
					def img_info_log(filename, filter_path=None, imgopts=False, extra_args=()):
 | 
				
			||||||
    args = ['info']
 | 
					    args = ['info']
 | 
				
			||||||
    if imgopts:
 | 
					    if imgopts:
 | 
				
			||||||
        args.append('--image-opts')
 | 
					        args.append('--image-opts')
 | 
				
			||||||
@ -354,7 +354,7 @@ def filter_qmp_imgfmt(qmsg):
 | 
				
			|||||||
        return value
 | 
					        return value
 | 
				
			||||||
    return filter_qmp(qmsg, _filter)
 | 
					    return filter_qmp(qmsg, _filter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def log(msg, filters=[], indent=None):
 | 
					def log(msg, filters=(), indent=None):
 | 
				
			||||||
    '''Logs either a string message or a JSON serializable message (like QMP).
 | 
					    '''Logs either a string message or a JSON serializable message (like QMP).
 | 
				
			||||||
    If indent is provided, JSON serializable messages are pretty-printed.'''
 | 
					    If indent is provided, JSON serializable messages are pretty-printed.'''
 | 
				
			||||||
    for flt in filters:
 | 
					    for flt in filters:
 | 
				
			||||||
@ -570,7 +570,7 @@ class VM(qtest.QEMUQtestMachine):
 | 
				
			|||||||
            result.append(filter_qmp_event(ev))
 | 
					            result.append(filter_qmp_event(ev))
 | 
				
			||||||
        return result
 | 
					        return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def qmp_log(self, cmd, filters=[], indent=None, **kwargs):
 | 
					    def qmp_log(self, cmd, filters=(), indent=None, **kwargs):
 | 
				
			||||||
        full_cmd = OrderedDict((
 | 
					        full_cmd = OrderedDict((
 | 
				
			||||||
            ("execute", cmd),
 | 
					            ("execute", cmd),
 | 
				
			||||||
            ("arguments", ordered_qmp(kwargs))
 | 
					            ("arguments", ordered_qmp(kwargs))
 | 
				
			||||||
@ -974,7 +974,7 @@ def case_notrun(reason):
 | 
				
			|||||||
    open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
 | 
					    open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
 | 
				
			||||||
        '    [case not run] ' + reason + '\n')
 | 
					        '    [case not run] ' + reason + '\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
 | 
					def verify_image_format(supported_fmts=(), unsupported_fmts=()):
 | 
				
			||||||
    assert not (supported_fmts and unsupported_fmts)
 | 
					    assert not (supported_fmts and unsupported_fmts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if 'generic' in supported_fmts and \
 | 
					    if 'generic' in supported_fmts and \
 | 
				
			||||||
@ -988,7 +988,7 @@ def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
 | 
				
			|||||||
    if not_sup or (imgfmt in unsupported_fmts):
 | 
					    if not_sup or (imgfmt in unsupported_fmts):
 | 
				
			||||||
        notrun('not suitable for this image format: %s' % imgfmt)
 | 
					        notrun('not suitable for this image format: %s' % imgfmt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def verify_protocol(supported=[], unsupported=[]):
 | 
					def verify_protocol(supported=(), unsupported=()):
 | 
				
			||||||
    assert not (supported and unsupported)
 | 
					    assert not (supported and unsupported)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if 'generic' in supported:
 | 
					    if 'generic' in supported:
 | 
				
			||||||
@ -1007,11 +1007,11 @@ def verify_platform(supported=None, unsupported=None):
 | 
				
			|||||||
        if not any((sys.platform.startswith(x) for x in supported)):
 | 
					        if not any((sys.platform.startswith(x) for x in supported)):
 | 
				
			||||||
            notrun('not suitable for this OS: %s' % sys.platform)
 | 
					            notrun('not suitable for this OS: %s' % sys.platform)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def verify_cache_mode(supported_cache_modes=[]):
 | 
					def verify_cache_mode(supported_cache_modes=()):
 | 
				
			||||||
    if supported_cache_modes and (cachemode not in supported_cache_modes):
 | 
					    if supported_cache_modes and (cachemode not in supported_cache_modes):
 | 
				
			||||||
        notrun('not suitable for this cache mode: %s' % cachemode)
 | 
					        notrun('not suitable for this cache mode: %s' % cachemode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def verify_aio_mode(supported_aio_modes=[]):
 | 
					def verify_aio_mode(supported_aio_modes=()):
 | 
				
			||||||
    if supported_aio_modes and (aiomode not in supported_aio_modes):
 | 
					    if supported_aio_modes and (aiomode not in supported_aio_modes):
 | 
				
			||||||
        notrun('not suitable for this aio mode: %s' % aiomode)
 | 
					        notrun('not suitable for this aio mode: %s' % aiomode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1051,7 +1051,7 @@ def supported_formats(read_only=False):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return supported_formats.formats[read_only]
 | 
					    return supported_formats.formats[read_only]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def skip_if_unsupported(required_formats=[], read_only=False):
 | 
					def skip_if_unsupported(required_formats=(), read_only=False):
 | 
				
			||||||
    '''Skip Test Decorator
 | 
					    '''Skip Test Decorator
 | 
				
			||||||
       Runs the test if all the required formats are whitelisted'''
 | 
					       Runs the test if all the required formats are whitelisted'''
 | 
				
			||||||
    def skip_test_decorator(func):
 | 
					    def skip_test_decorator(func):
 | 
				
			||||||
@ -1102,11 +1102,11 @@ def execute_unittest(output, verbosity, debug):
 | 
				
			|||||||
            sys.stderr.write(out)
 | 
					            sys.stderr.write(out)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def execute_test(test_function=None,
 | 
					def execute_test(test_function=None,
 | 
				
			||||||
                 supported_fmts=[],
 | 
					                 supported_fmts=(),
 | 
				
			||||||
                 supported_platforms=None,
 | 
					                 supported_platforms=None,
 | 
				
			||||||
                 supported_cache_modes=[], supported_aio_modes={},
 | 
					                 supported_cache_modes=(), supported_aio_modes=(),
 | 
				
			||||||
                 unsupported_fmts=[], supported_protocols=[],
 | 
					                 unsupported_fmts=(), supported_protocols=(),
 | 
				
			||||||
                 unsupported_protocols=[]):
 | 
					                 unsupported_protocols=()):
 | 
				
			||||||
    """Run either unittest or script-style tests."""
 | 
					    """Run either unittest or script-style tests."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
 | 
					    # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user