qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

iotests: limit line length to 79 chars

79 is the PEP8 recommendation. This recommendation works well for
reading patch diffs in TUI email clients.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200331000014.11581-10-jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>

authored by

John Snow and committed by
Max Reitz
b031e9a5 1cd0dbfc

+47 -23
+42 -22
tests/qemu-iotests/iotests.py
··· 80 80 def qemu_img(*args): 81 81 '''Run qemu-img and return the exit code''' 82 82 devnull = open('/dev/null', 'r+') 83 - exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) 83 + exitcode = subprocess.call(qemu_img_args + list(args), 84 + stdin=devnull, stdout=devnull) 84 85 if exitcode < 0: 85 - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) 86 + sys.stderr.write('qemu-img received signal %i: %s\n' 87 + % (-exitcode, ' '.join(qemu_img_args + list(args)))) 86 88 return exitcode 87 89 88 90 def ordered_qmp(qmsg, conv_keys=True): ··· 121 123 '''Run qemu-img without suppressing its output and return the exit code''' 122 124 exitcode = subprocess.call(qemu_img_args + list(args)) 123 125 if exitcode < 0: 124 - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) 126 + sys.stderr.write('qemu-img received signal %i: %s\n' 127 + % (-exitcode, ' '.join(qemu_img_args + list(args)))) 125 128 return exitcode 126 129 127 130 def qemu_img_pipe(*args): ··· 132 135 universal_newlines=True) 133 136 exitcode = subp.wait() 134 137 if exitcode < 0: 135 - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) 138 + sys.stderr.write('qemu-img received signal %i: %s\n' 139 + % (-exitcode, ' '.join(qemu_img_args + list(args)))) 136 140 return subp.communicate()[0] 137 141 138 142 def qemu_img_log(*args): ··· 162 166 universal_newlines=True) 163 167 exitcode = subp.wait() 164 168 if exitcode < 0: 165 - sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) 169 + sys.stderr.write('qemu-io received signal %i: %s\n' 170 + % (-exitcode, ' '.join(args))) 166 171 return subp.communicate()[0] 167 172 168 173 def qemu_io_log(*args): ··· 284 289 def filter_win32(msg): 285 290 return win32_re.sub("", msg) 286 291 287 - qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]* [EPTGMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)") 292 + qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* " 293 + r"\([0-9\/.inf]* [EPTGMKiBbytes]*\/sec " 294 + r"and [0-9\/.inf]* ops\/sec\)") 288 295 def filter_qemu_io(msg): 289 296 msg = filter_win32(msg) 290 - return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)", msg) 297 + return qemu_io_re.sub("X ops; XX:XX:XX.X " 298 + "(XXX YYY/sec and XXX ops/sec)", msg) 291 299 292 300 chown_re = re.compile(r"chown [0-9]+:[0-9]+") 293 301 def filter_chown(msg): ··· 340 348 line = filter_testfiles(line) 341 349 line = line.replace(imgfmt, 'IMGFMT') 342 350 line = re.sub('iters: [0-9]+', 'iters: XXX', line) 343 - line = re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', line) 351 + line = re.sub('uuid: [-a-f0-9]+', 352 + 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 353 + line) 344 354 line = re.sub('cid: [0-9]+', 'cid: XXXXXXXXXX', line) 345 355 lines.append(line) 346 356 return '\n'.join(lines) ··· 538 548 self.pause_drive(drive, "write_aio") 539 549 return 540 550 self.qmp('human-monitor-command', 541 - command_line='qemu-io %s "break %s bp_%s"' % (drive, event, drive)) 551 + command_line='qemu-io %s "break %s bp_%s"' 552 + % (drive, event, drive)) 542 553 543 554 def resume_drive(self, drive): 544 555 self.qmp('human-monitor-command', 545 - command_line='qemu-io %s "remove_break bp_%s"' % (drive, drive)) 556 + command_line='qemu-io %s "remove_break bp_%s"' 557 + % (drive, drive)) 546 558 547 559 def hmp_qemu_io(self, drive, cmd): 548 560 '''Write to a given drive using an HMP command''' ··· 802 814 idx = int(idx) 803 815 804 816 if not isinstance(d, dict) or component not in d: 805 - self.fail('failed path traversal for "%s" in "%s"' % (path, str(d))) 817 + self.fail(f'failed path traversal for "{path}" in "{d}"') 806 818 d = d[component] 807 819 808 820 if m: 809 821 if not isinstance(d, list): 810 - self.fail('path component "%s" in "%s" is not a list in "%s"' % (component, path, str(d))) 822 + self.fail(f'path component "{component}" in "{path}" ' 823 + f'is not a list in "{d}"') 811 824 try: 812 825 d = d[idx] 813 826 except IndexError: 814 - self.fail('invalid index "%s" in path "%s" in "%s"' % (idx, path, str(d))) 827 + self.fail(f'invalid index "{idx}" in path "{path}" ' 828 + f'in "{d}"') 815 829 return d 816 830 817 831 def assert_qmp_absent(self, d, path): ··· 862 876 '''Asserts that the given filename is a json: filename and that its 863 877 content is equal to the given reference object''' 864 878 self.assertEqual(json_filename[:5], 'json:') 865 - self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filename[5:])), 866 - self.vm.flatten_qmp_object(reference)) 879 + self.assertEqual( 880 + self.vm.flatten_qmp_object(json.loads(json_filename[5:])), 881 + self.vm.flatten_qmp_object(reference) 882 + ) 867 883 868 - def cancel_and_wait(self, drive='drive0', force=False, resume=False, wait=60.0): 884 + def cancel_and_wait(self, drive='drive0', force=False, 885 + resume=False, wait=60.0): 869 886 '''Cancel a block job and wait for it to finish, returning the event''' 870 887 result = self.vm.qmp('block-job-cancel', device=drive, force=force) 871 888 self.assert_qmp(result, 'return', {}) ··· 889 906 self.assert_no_active_block_jobs() 890 907 return result 891 908 892 - def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0, 893 - error=None): 909 + def wait_until_completed(self, drive='drive0', check_offset=True, 910 + wait=60.0, error=None): 894 911 '''Wait for a block job to finish, returning the event''' 895 912 while True: 896 913 for event in self.vm.get_qmp_events(wait=wait): ··· 1029 1046 notrun('quorum support missing') 1030 1047 1031 1048 def qemu_pipe(*args): 1032 - '''Run qemu with an option to print something and exit (e.g. a help option), 1033 - and return its output''' 1049 + """ 1050 + Run qemu with an option to print something and exit (e.g. a help option). 1051 + 1052 + :return: QEMU's stdout output. 1053 + """ 1034 1054 args = [qemu_prog] + qemu_opts + list(args) 1035 1055 subp = subprocess.Popen(args, stdout=subprocess.PIPE, 1036 1056 stderr=subprocess.STDOUT, ··· 1068 1088 1069 1089 usf_list = list(set(fmts) - set(supported_formats(read_only))) 1070 1090 if usf_list: 1071 - test_case.case_skip('{}: formats {} are not whitelisted'.format( 1072 - test_case, usf_list)) 1091 + msg = f'{test_case}: formats {usf_list} are not whitelisted' 1092 + test_case.case_skip(msg) 1073 1093 return None 1074 1094 else: 1075 1095 return func(test_case, *args, **kwargs)
+5 -1
tests/qemu-iotests/pylintrc
··· 18 18 too-many-locals, 19 19 too-many-public-methods, 20 20 # These are temporary, and should be removed: 21 - line-too-long, 22 21 missing-docstring, 22 + 23 + [FORMAT] 24 + 25 + # Maximum number of characters on a single line. 26 + max-line-length=79