未验证 提交 dc467c6a 编写于 作者: X Xu Han 提交者: GitHub

Merge pull request #1325 from hereischen/4-python3-commands

Python 3: [generic] replaced commands
import logging
import commands
import random
from avocado.utils import process
......@@ -177,7 +176,9 @@ def run(test, params, env):
logging.info("Waiting for the MTU to be OK")
wait_mtu_ok = 10
if not utils_misc.wait_for(is_mtu_ok, wait_mtu_ok, 0, 1):
logging.debug(commands.getoutput("ifconfig -a"))
logging.debug(process.system_output("ifconfig -a",
verbose=False, ignore_status=True,
shell=True))
test.error("MTU is not as expected even after %s "
"seconds" % wait_mtu_ok)
......@@ -198,7 +199,8 @@ def run(test, params, env):
session.close()
grep_cmd = "grep '%s.*%s' /proc/net/arp" % (guest_ip, ifname)
if process.system(grep_cmd, shell=True) == '0':
process.run("arp -d %s -i %s" % (guest_ip, ifname))
process.run("arp -d %s -i %s" % (guest_ip, ifname),
shell=True)
logging.info("Removing the temporary ARP entry successfully")
logging.info("Change back Bridge NICs MTU to %s" % mtu_default)
......
import logging
import os
import commands
import threading
import re
import time
......@@ -205,8 +204,12 @@ def run(test, params, env):
restart_network=True)
server_ctl_ip = vm.wait_for_get_address(1, timeout=5)
logging.debug(commands.getoutput("numactl --hardware"))
logging.debug(commands.getoutput("numactl --show"))
logging.debug(process.system_output("numactl --hardware",
verbose=False, ignore_status=True,
shell=True))
logging.debug(process.system_output("numactl --show",
verbose=False, ignore_status=True,
shell=True))
# pin guest vcpus/memory/vhost threads to last numa node of host by default
numa_node = _pin_vm_threads(vm, params.get("numa_node"))
......@@ -339,13 +342,18 @@ def start_test(server, server_ctl, host, clients, resultsdir, test_duration=60,
fd = open("%s/netperf-result.%s.RHS" % (resultsdir, time.time()), "w")
test.write_test_keyval({'kvm-userspace-ver':
commands.getoutput(ver_cmd).strip()})
process.system_output(ver_cmd,
verbose=False,
ignore_status=True,
shell=True
).strip()})
test.write_test_keyval({'guest-kernel-ver': ssh_cmd(server_ctl,
guest_ver_cmd).strip()})
test.write_test_keyval({'session-length': test_duration})
fd.write('### kvm-userspace-ver : %s\n' %
commands.getoutput(ver_cmd).strip())
process.system_output(ver_cmd, verbose=False,
ignore_status=True, shell=True).strip())
fd.write('### guest-kernel-ver : %s\n' % ssh_cmd(server_ctl,
guest_ver_cmd).strip())
fd.write('### kvm_version : %s\n' % os.uname()[2])
......@@ -436,7 +444,9 @@ def start_test(server, server_ctl, host, clients, resultsdir, test_duration=60,
fd.flush()
logging.debug("Remove temporary files")
commands.getoutput("rm -f /tmp/netperf.%s.nf" % ret['pid'])
process.system_output("rm -f /tmp/netperf.%s.nf" % ret['pid'],
verbose=False, ignore_status=True,
shell=True)
logging.info("Netperf thread completed successfully")
fd.close()
......
......@@ -2,7 +2,6 @@ import logging
import os
import glob
import re
import commands
import aexpect
......@@ -182,8 +181,11 @@ def run(test, params, env):
raw = " buf(k)| throughput(Mbit/s)"
logging.info(raw)
f.write("#ver# %s\n#ver# host kernel: %s\n" %
(commands.getoutput("rpm -q qemu-kvm"), os.uname()[2]))
desc = """#desc# The tests are sessions of "NTttcp", send buf number is %s. 'throughput' was taken from ntttcp's report.
(process.system_output("rpm -q qemu-kvm", shell=True,
verbose=False, ignore_status=True),
os.uname()[2]))
desc = """#desc# The tests are sessions of "NTttcp", send buf"
" number is %s. 'throughput' was taken from ntttcp's report.
#desc# How to read the results:
#desc# - The Throughput is measured in Mbit/sec.
#desc#
......
import logging
import time
import commands
import os
import re
from avocado.utils import process
from virttest import utils_test
from virttest.staging import utils_memory
......@@ -56,7 +56,7 @@ def run(test, params, env):
# Get dd speed in host
start_time = time.time()
cmd = "dd if=/dev/urandom of=/tmp/speed_test bs=4K count=256"
s, o = commands.getstatusoutput(cmd)
process.run(cmd, verbose=False, shell=True)
end_time = time.time()
dd_timeout = vmsm * (end_time - start_time) * 2
nr_hugepages = []
......@@ -100,11 +100,11 @@ def run(test, params, env):
cmd = "for i in `seq %s`; do dd if=/dev/urandom of=/space/$i" % count
cmd += " bs=4K count=1 & done"
logging.info("Start to make fragment in host")
s, o = commands.getstatusoutput(cmd)
s = process.system(cmd, verbose=False, shell=True)
if s != 0:
test.error("Can not dd in host")
finally:
s, o = commands.getstatusoutput("umount /space")
process.run("umount /space", verbose=False, shell=True)
bg = utils_test.BackgroundTest(nr_hugepage_check, (s_time, w_time))
bg.start()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册