tp-qemu: Mass PEP8 E713 fixes

Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 720418bf
......@@ -164,7 +164,7 @@ def run(test, params, env):
list_labels_output = session_server.cmd(list_labels_cmd)
for line in list_labels_output.splitlines():
logging.debug(line)
if not label_name in list_labels_output:
if label_name not in list_labels_output:
raise ValueError("No label %s in the output of %s" %
(label_name, list_labels_cmd))
......@@ -178,10 +178,10 @@ def run(test, params, env):
list_hosts_output = session_server.cmd(list_hosts_cmd)
for line in list_hosts_output.splitlines():
logging.debug(line)
if not client_ip in list_hosts_output:
if client_ip not in list_hosts_output:
raise ValueError("No client %s in the output of %s" %
(client_ip, create_label_cmd))
if not label_name in list_hosts_output:
if label_name not in list_hosts_output:
raise ValueError("No label %s in the output of %s" %
(label_name, create_label_cmd))
......
......@@ -40,7 +40,7 @@ def run(test, params, env):
cmd = params.get("nic_module_cmd")
out = session.cmd(cmd)
for module in out.split("\n"):
if not cmd in module:
if cmd not in module:
modules.append(module.split("/")[-1])
modules.remove("")
return set(modules)
......
......@@ -26,7 +26,7 @@ def run(test, params, env):
logging.debug, "(pxe capture) ", timeout)[1]
error.context("Analyzing the tcpdump result", logging.info)
if not "tftp" in output:
if "tftp" not in output:
raise error.TestFail(
"Couldn't find any TFTP packets after %s seconds" %
timeout)
......
......@@ -517,7 +517,7 @@ def run(test, params, env):
missing = []
cpu_models = map(separe_cpu_model, cpu_models)
for cpu_model in cpu_models:
if not cpu_model in result.stdout:
if cpu_model not in result.stdout:
missing.append(cpu_model)
if missing:
raise error.TestFail("CPU models %s are not in output "
......@@ -537,7 +537,7 @@ def run(test, params, env):
cpu_models = map(separe_cpu_model, cpu_models)
missing = []
for cpu_model in cpu_models:
if not cpu_model in result.stdout:
if cpu_model not in result.stdout:
missing.append(cpu_model)
if missing:
raise error.TestFail("CPU models %s are not in output "
......
......@@ -26,7 +26,7 @@ def run(test, params, env):
cpuinfos = params.get("cpu_info", "Conroe").split(",")
missing = []
for cpuinfo in cpuinfos:
if not cpuinfo in output:
if cpuinfo not in output:
missing.append(cpuinfo)
if missing:
raise error.TestFail("%s is missing in the output\n %s" %
......
......@@ -112,7 +112,7 @@ def run(test, params, env):
# needs time to load and init floppy driver
if self.dest_dir:
lsmod = self.session.cmd("lsmod")
if not 'floppy' in lsmod:
if 'floppy' not in lsmod:
self.session.cmd("modprobe floppy")
else:
time.sleep(20)
......@@ -234,7 +234,7 @@ def run(test, params, env):
error.context("Prepare floppy for writing.")
if self.mount_dir:
lsmod = session.cmd("lsmod")
if not 'floppy' in lsmod:
if 'floppy' not in lsmod:
session.cmd("modprobe floppy")
else:
time.sleep(20)
......@@ -265,7 +265,7 @@ def run(test, params, env):
error.context("Wait for copy finishing.")
status = int(session.cmd_status("kill %s" % pid,
timeout=copy_timeout))
if not status in [0]:
if status not in [0]:
raise error.TestFail("Copy process was terminatted with"
" error code %s" % (status))
......@@ -338,12 +338,12 @@ def run(test, params, env):
error.context("Prepare floppy for writing.")
if self.mount_dir: # If linux
lsmod = session.cmd("lsmod")
if not 'floppy' in lsmod:
if 'floppy' not in lsmod:
session.cmd("modprobe floppy")
else:
time.sleep(20)
if not floppy in vm.monitor.info("block"):
if floppy not in vm.monitor.info("block"):
raise error.TestFail("Wrong floppy image is placed in vm.")
try:
......@@ -387,7 +387,7 @@ def run(test, params, env):
session.cmd("mount -t vfat %s %s" % (guest_floppy_path,
self.mount_dir), timeout=30)
if not second_floppy in vm.monitor.info("block"):
if second_floppy not in vm.monitor.info("block"):
raise error.TestFail("Wrong floppy image is placed in vm.")
sync = SyncData(self.mig.master_id(), self.mig.hostid,
......
......@@ -68,7 +68,7 @@ def run(test, params, env):
ret = s.get("migrated") == "true"
o = vm.monitor.info("migrate")
if isinstance(o, str):
return ret and (not "status: active" in o)
return ret and ("status: active" not in o)
else:
return ret and (o.get("status") != "active")
......
......@@ -39,7 +39,7 @@ def run(test, params, env):
ret = s.get("migrated") == "true"
o = vm.monitor.info("migrate")
if isinstance(o, str):
return ret and (not "status: active" in o)
return ret and ("status: active" not in o)
else:
return ret and (o.get("status") != "active")
......
......@@ -61,7 +61,7 @@ def run(test, params, env):
self.time_filter_re,
self.time_format)
session.cmd(self.create_file)
if not vm.name in self.start_ht.keys():
if vm.name not in self.start_ht.keys():
(self.start_ht[vm.name], self.start_gt[vm.name]) = (ht, gt)
if abs(ht - gt) > self.diff_limit:
logging.warning("Host and %s time diff %s is greater "
......
......@@ -59,7 +59,7 @@ def run(test, params, env):
fail_msg = ("Could not determine the transferred memory from"
" monitor data: %s" % o)
if isinstance(o, str):
if not "status: active" in o:
if "status: active" not in o:
raise error.TestWarn(warning_msg)
try:
transfered_mem = int(get_mig_speed.search(o).groups()[0])
......
......@@ -260,7 +260,7 @@ def run(test, params, env):
session.cmd("dd if=/dev/zero of=%s bs=1M count=%s" % (disk_path,
disk_size))
status, output = session.cmd_status_output("setenforce 0")
if not status in [0, 127]:
if status not in [0, 127]:
logging.warn("Function setenforce fails.\n %s" % (output))
config = self.config % (self.server_name, disk_path,
......
......@@ -56,7 +56,7 @@ def run(test, params, env):
fail_msg = ("Could not determine the transferred memory from"
" monitor data: %s" % o)
if isinstance(o, str):
if not "status: active" in o:
if "status: active" not in o:
raise error.TestWarn(warning_msg)
try:
transfered_mem = int(get_mig_speed.search(o).groups()[0])
......
......@@ -96,7 +96,7 @@ def run(test, params, env):
error.context("Change queues number repeatly", logging.info)
repeat_counts = int(params.get("repeat_counts", 10))
for nic_index, nic in enumerate(vm.virtnet):
if not "virtio" in nic['nic_model']:
if "virtio" not in nic['nic_model']:
continue
queues = int(vm.virtnet[nic_index].queues)
if queues == 1:
......
......@@ -44,7 +44,7 @@ def run(test, params, env):
add_output = vm.monitor.send_args_cmd(pci_add_cmd, convert=False)
pci_info.append(['', '', add_output, pci_model])
if not "OK domain" in add_output:
if "OK domain" not in add_output:
raise error.TestFail("Add PCI device failed. "
"Monitor command is: %s, Output: %r" %
(pci_add_cmd, add_output))
......
......@@ -86,7 +86,7 @@ def run(test, params, env):
add_output = vm.monitor.send_args_cmd(pci_add_cmd, convert=False)
guest_device = find_new_device(chk_cmd, guest_devices)
pci_info.append(['', '', add_output, pci_model, guest_device])
if not "OK domain" in add_output:
if "OK domain" not in add_output:
raise error.TestFail("Add PCI device failed. "
"Monitor command is: %s, Output: %r" %
(pci_add_cmd, add_output))
......
......@@ -271,7 +271,7 @@ def run(test, params, env):
if expected_vendor_id and cpu_vendor_id_chk_cmd:
output = session.cmd_output(cpu_vendor_id_chk_cmd)
if not expected_vendor_id in output:
if expected_vendor_id not in output:
fail_log = "CPU vendor id check failed.\n"
fail_log += " Assigned to VM: '%s'\n" % expected_vendor_id
fail_log += " Reported by OS: '%s'" % output
......@@ -333,7 +333,7 @@ def run(test, params, env):
num_nics = len(params.objects("nics"))
for nic_index in range(num_nics):
mac = vm.get_mac_address(nic_index)
if not string.lower(mac) in found_mac_addresses:
if string.lower(mac) not in found_mac_addresses:
fail_log = "MAC address mismatch:\n"
fail_log += " Assigned to VM (not found): %s" % mac
n_fail.append(fail_log)
......
......@@ -240,10 +240,10 @@ def run(test, params, env):
"""
img_info = _info(cmd, image_name)
logging.info("Info of image '%s':\n%s", image_name, img_info)
if not image_format in img_info:
if image_format not in img_info:
raise error.TestFail("Got unexpected format of image '%s'"
" in info test" % image_name)
if not image_size in img_info:
if image_size not in img_info:
raise error.TestFail("Got unexpected size of image '%s'"
" in info test" % image_name)
......@@ -424,7 +424,7 @@ def run(test, params, env):
:param cmd: qemu-img base command.
"""
if not 'rebase' in utils.system_output(cmd + ' --help',
if 'rebase' not in utils.system_output(cmd + ' --help',
ignore_status=True):
raise error.TestNAError("Current kvm user space version does not"
" support 'rebase' subcommand")
......@@ -453,7 +453,7 @@ def run(test, params, env):
# Check sn2's format and backing_file
actual_base_img = _info(cmd, sn2, "backing file")
base_img_name = os.path.basename(base_img)
if not base_img_name in actual_base_img:
if base_img_name not in actual_base_img:
raise error.TestFail("After rebase the backing_file of 'sn2' is "
"'%s' which is not expected as '%s'"
% (actual_base_img, base_img_name))
......
......@@ -34,7 +34,7 @@ def run(test, params, env):
if not isinstance(qmp_dict, dict):
raise error.TestFail("qmp_dict is not a dict (it's '%s')" %
type(qmp_dict))
if not key in qmp_dict:
if key not in qmp_dict:
raise error.TestFail("'%s' key doesn't exist in dict ('%s')" %
(key, str(qmp_dict)))
......
......@@ -35,7 +35,7 @@ def run(test, params, env):
if not isinstance(qmp_dict, dict):
raise error.TestFail("qmp_dict is not a dict (it's '%s')" %
type(qmp_dict))
if not key in qmp_dict:
if key not in qmp_dict:
raise error.TestFail("'%s' key doesn't exist in dict ('%s')" %
(key, str(qmp_dict)))
......
......@@ -94,7 +94,7 @@ def test_type_and_func_keys(client_vm, guest_session, params):
logging.info("Sending typewriter and functional keys to client machine")
for i in range(1, 69):
# Avoid Ctrl, RSH, LSH, PtScr, Alt, CpsLk
if not (i in [29, 42, 54, 55, 56, 58]):
if i not in [29, 42, 54, 55, 56, 58]:
client_vm.send_key(str(hex(i)))
utils_spice.wait_timeout(0.3)
......
......@@ -84,8 +84,8 @@ def run(test, params, env):
raise error.TestFail("Certificate %s was not found as a listed"
" cert in the guest" % subj_string)
elif smartcard_testtype == "pklogin_finder":
# pkcs11_listcerts not installed until
# Smart Card Support is installed
# pkcs11_listcerts not installed until
# Smart Card Support is installed
try:
certsinfo_output = guest_session.cmd("pklogin_finder debug")
except aexpect.ShellTimeoutError:
......
......@@ -51,7 +51,7 @@ def run(test, params, env):
error.context("Adding pci device with command 'pci_add'")
add_output = vm.monitor.send_args_cmd(pci_add_cmd, convert=False)
pci_info.append(['', add_output])
if not "OK domain" in add_output:
if "OK domain" not in add_output:
raise error.TestFail("Add PCI device failed. "
"Monitor command is: %s, Output: %r" %
(pci_add_cmd, add_output))
......
......@@ -149,7 +149,7 @@ class TimedriftTest(object):
read_clock_cmd = "cat /sys/devices/system/clocksource/"
read_clock_cmd += "clocksource0/current_clocksource"
current_clocksource = session.cmd_output(read_clock_cmd)
if not clock_source in current_clocksource:
if clock_source not in current_clocksource:
raise error.TestFail("Guest didn't use'%s'" % clock_source +
"clocksource, current clocksoure " +
"is %s;" % current_clocksource)
......
......@@ -120,7 +120,7 @@ def run(test, params, env):
session = vm.wait_for_serial_login(timeout=login_timeout)
out = session.cmd_output("cat /sys/devices/system/clocksource/"
"clocksource0/current_clocksource")
if not guest_clock_source in out:
if guest_clock_source not in out:
raise error.TestFail("Clock source %s missing in guest clock "
"sources %s." % (guest_clock_source, out))
......
......@@ -32,7 +32,7 @@ def run(test, params, env):
error.context("Check the current clocksource in guest", logging.info)
cmd = "cat /sys/devices/system/clocksource/"
cmd += "clocksource0/current_clocksource"
if not expected in session.cmd(cmd):
if expected not in session.cmd(cmd):
raise error.TestFail(
"Guest didn't use '%s' clocksource" % expected)
......
......@@ -24,7 +24,7 @@ def run(test, params, env):
error.context("Check the current clocksource in guest", logging.info)
cmd = "cat /sys/devices/system/clocksource/"
cmd += "clocksource0/current_clocksource"
if not expected in session.cmd(cmd):
if expected not in session.cmd(cmd):
raise error.TestFail(
"Guest didn't use '%s' clocksource" % expected)
......@@ -38,7 +38,7 @@ def run(test, params, env):
error.context("Check the current clocksource in guest", logging.info)
cmd = "cat /sys/devices/system/clocksource/"
cmd += "clocksource0/current_clocksource"
if not "kvm-clock" in session.cmd(cmd):
if "kvm-clock" not in session.cmd(cmd):
grub_file = params.get("grub_file", "/boot/grub2/grub.cfg")
if "clocksource=" not in session.cmd("cat %s" % grub_file):
raise error.TestFail("Guest didn't use 'kvm-clock' clocksource")
......
......@@ -36,7 +36,7 @@ def run(test, params, env):
error.context("Check for an appropriate clocksource on host", logging.info)
host_cmd = "cat /sys/devices/system/clocksource/"
host_cmd += "clocksource0/current_clocksource"
if not "tsc" in utils.system_output(host_cmd):
if "tsc" not in utils.system_output(host_cmd):
raise error.TestNAError("Host must use 'tsc' clocksource")
error.context("Boot the guest", logging.info)
......
......@@ -53,7 +53,7 @@ def run(test, params, env):
logging.info)
cmd = "cat /sys/devices/system/clocksource/"
cmd += "clocksource0/current_clocksource"
if not "kvm-clock" in session.cmd(cmd):
if "kvm-clock" not in session.cmd(cmd):
grub_file = params.get("grub_file", "/boot/grub2/grub.cfg")
if "clocksource=" not in session.cmd("cat %s" % grub_file):
raise error.TestFail("Guest didn't use 'kvm-clock' clocksource")
......
......@@ -27,7 +27,7 @@ def run(test, params, env):
error.context("Check for an appropriate clocksource on host", logging.info)
host_cmd = "cat /sys/devices/system/clocksource/"
host_cmd += "clocksource0/current_clocksource"
if not "tsc" in utils.system_output(host_cmd):
if "tsc" not in utils.system_output(host_cmd):
raise error.TestNAError("Host must use 'tsc' clocksource")
error.context("Boot the guest with one cpu socket", logging.info)
......@@ -40,7 +40,7 @@ def run(test, params, env):
error.context("Check the guest is using vsyscall", logging.info)
date_cmd = "strace date 2>&1|egrep 'clock_gettime|gettimeofday'|wc -l"
output = session.cmd(date_cmd)
if not '0' in output:
if '0' not in output:
raise error.TestFail("Failed to check vsyscall. Output: '%s'" % output)
error.context("Copy time-warp-test.c to guest", logging.info)
......@@ -99,7 +99,7 @@ def run(test, params, env):
" Output (last 5 lines): '%s'" % msg)
output = session.cmd(date_cmd)
if not "1" in output:
if "1" not in output:
raise error.TestFail("Failed to check vsyscall."
" Output: '%s'" % output)
finally:
......
......@@ -25,7 +25,7 @@ def run(test, params, env):
error.context("Check for an appropriate clocksource on host", logging.info)
host_cmd = "cat /sys/devices/system/clocksource/"
host_cmd += "clocksource0/current_clocksource"
if not "tsc" in utils.system_output(host_cmd):
if "tsc" not in utils.system_output(host_cmd):
raise error.TestNAError("Host must use 'tsc' clocksource")
error.context("Check host has more than one cpu socket", logging.info)
......
......@@ -20,7 +20,7 @@ def run(test, params, env):
error.context("Check for an appropriate clocksource on host", logging.info)
host_cmd = "cat /sys/devices/system/clocksource/"
host_cmd += "clocksource0/current_clocksource"
if not "tsc" in utils.system_output(host_cmd):
if "tsc" not in utils.system_output(host_cmd):
raise error.TestNAError("Host must use 'tsc' clocksource")
error.context("Boot the guest", logging.info)
......@@ -40,7 +40,7 @@ def run(test, params, env):
date_cmd = "strace date 2>&1 | egrep 'clock_gettime|gettimeofday' | wc -l"
output = session.cmd(date_cmd)
if not '0' in output:
if '0' not in output:
raise error.TestFail("Test failed before run msr tools."
" Output: '%s'" % output)
......@@ -51,6 +51,6 @@ def run(test, params, env):
session.cmd(cmd)
output = session.cmd(date_cmd)
if not "1" in output:
if "1" not in output:
raise error.TestFail("Test failed after run msr tools."
" Output: '%s'" % output)
......@@ -115,7 +115,7 @@ def run(test, params, env):
error.context("Check serial option in guest", logging.info)
session = _login()
output = session.cmd("lsusb -v")
if not ("EMPTY_STRING" in serial or "NO_EQUAL_STRING" in serial):
if "EMPTY_STRING" not in serial or "NO_EQUAL_STRING" not in serial:
# Verify in guest when serial is set to empty/null is meaningless.
_verify_string(serial, output, [serial])
_do_io_test_guest(session)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册