From: "Jiajia, Sun" <sunx.jiajia@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH v2 08/19] Add and move some functions because of the virtual tests and network device instantiation
Date: Fri, 22 May 2015 17:04:01 +0800 [thread overview]
Message-ID: <1432285452-14286-9-git-send-email-sunx.jiajia@intel.com> (raw)
In-Reply-To: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com>
From: sjiajiax <sunx.jiajia@intel.com>
Signed-off-by: sjiajiax <sunx.jiajia@intel.com>
---
framework/crb.py | 126 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 76 insertions(+), 50 deletions(-)
diff --git a/framework/crb.py b/framework/crb.py
index a699bfc..3160fa0 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -80,7 +80,9 @@ class Crb(object):
"""
Get the huge page number of CRB.
"""
- huge_pages = self.send_expect("awk '/HugePages_Total/ { print $2 }' /proc/meminfo", "# ")
+ huge_pages = self.send_expect(
+ "awk '/HugePages_Total/ { print $2 }' /proc/meminfo",
+ "# ", alt_session=True)
if huge_pages != "":
return int(huge_pages)
return 0
@@ -127,13 +129,15 @@ class Crb(object):
Force set remote interface link status in FreeBSD.
"""
eth = self.ports_info[port]['intf']
- self.send_expect("ifconfig %s %s" % (eth, status), "# ")
+ self.send_expect("ifconfig %s %s" %
+ (eth, status), "# ", alt_session=True)
def admin_ports_linux(self, eth, status):
"""
Force set remote interface link status in Linux.
"""
- self.send_expect("ip link set %s %s" % (eth, status), "# ")
+ self.send_expect("ip link set %s %s" %
+ (eth, status), "# ", alt_session=True)
def pci_devices_information(self):
"""
@@ -157,8 +161,9 @@ class Crb(object):
"""
Look for the NIC's information (PCI Id and card type).
"""
- out = self.send_expect("lspci -nn | grep -i eth", "# ")
- rexp = r"([\da-f]{2}:[\da-f]{2}.\d{1}) Ethernet .*?([\da-f]{4}:[\da-f]{4})"
+ out = self.send_expect(
+ "lspci -nn | grep -i eth", "# ", alt_session=True)
+ rexp = r"([\da-f]{2}:[\da-f]{2}.\d{1}) .*Eth.*?ernet .*?([\da-f]{4}:[\da-f]{4})"
pattern = re.compile(rexp)
match = pattern.findall(out)
self.pci_devices_info = []
@@ -169,7 +174,7 @@ class Crb(object):
"""
Look for the NIC's information (PCI Id and card type).
"""
- out = self.send_expect("pciconf -l", "# ")
+ out = self.send_expect("pciconf -l", "# ", alt_session=True)
rexp = r"pci0:([\da-f]{1,3}:[\da-f]{1,2}:\d{1}):\s*class=0x020000.*chip=0x([\da-f]{4})8086"
pattern = re.compile(rexp)
match = pattern.findall(out)
@@ -179,66 +184,69 @@ class Crb(object):
card_type = "8086:%s" % match[i][1]
self.pci_devices_info.append((match[i][0], card_type))
- def get_interface_name(self, bus_id, devfun_id=''):
+ def get_pci_dev_driver(self, bus_id, devfun_id):
"""
- Get interface name of specified pci device.
+ Get the driver of specified pci device.
"""
- get_interface_name = getattr(self, 'get_interface_name_%s' % self.get_os_type())
- return get_interface_name(bus_id, devfun_id)
+ get_pci_dev_driver = getattr(
+ self, 'get_pci_dev_driver_%s' % self.get_os_type())
+ return get_pci_dev_driver(bus_id, devfun_id)
- def get_interface_name_linux(self, bus_id, devfun_id):
+ def get_pci_dev_driver_linux(self, bus_id, devfun_id):
"""
- Get interface name of specified pci device on linux.
+ Get the driver of specified pci device on linux.
"""
- command = 'ls --color=never /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
- out = self.send_expect(command, '# ', verify=True)
- if out == -1:
- name = ""
- else:
- name = out.split()[0]
- return name
-
- def get_interface_name_freebsd(self, bus_id, devfun_id):
- """
- Get interface name of specified pci device on Freebsd.
- """
- out = self.send_expect("pciconf -l", "# ")
- rexp = r"(\w*)@pci0:%s" % bus_id
+ out = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/uevent" %
+ (bus_id, devfun_id), "# ", alt_session=True)
+ rexp = r"DRIVER=(.+?)\r"
pattern = re.compile(rexp)
- match = pattern.findall(out)
- return match[0]
+ match = pattern.search(out)
+ if not match:
+ return None
+ return match.group(1)
- def get_mac_addr(self, intf, bus_id='', devfun_id=''):
+ def get_pci_dev_driver_freebsd(self, bus_id, devfun_id):
"""
- Get mac address of specified pci device.
+ Get the driver of specified pci device.
"""
- get_mac_addr = getattr(self, 'get_mac_addr_%s' % self.get_os_type())
- return get_mac_addr(intf, bus_id, devfun_id)
+ return True
- def get_mac_addr_linux(self, intf, bus_id, devfun_id):
+ def get_pci_dev_id(self, bus_id, devfun_id):
"""
- Get mac address of specified pci device on linux.
+ Get the pci id of specified pci device.
"""
- command = ('cat /sys/bus/pci/devices/0000:%s:%s/net/%s/address' %
- (bus_id, devfun_id, intf))
- return self.send_expect(command, '# ')
+ get_pci_dev_id = getattr(
+ self, 'get_pci_dev_id_%s' % self.get_os_type())
+ return get_pci_dev_id(bus_id, devfun_id)
- def get_mac_addr_freebsd(self, intf, bus_id, devfun_id):
+ def get_pci_dev_id_linux(self, bus_id, devfun_id):
"""
- Get mac address of specified pci device on Freebsd.
+ Get the pci id of specified pci device on linux.
"""
- out = self.send_expect('ifconfig %s' % intf, '# ')
- rexp = r"ether ([\da-f:]*)"
+ out = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/uevent" %
+ (bus_id, devfun_id), "# ", alt_session=True)
+ rexp = r"PCI_ID=(.+)"
pattern = re.compile(rexp)
- match = pattern.findall(out)
- return match[0]
+ match = re.search(out)
+ if not match:
+ return None
+ return match.group(1)
def get_device_numa(self, bus_id, devfun_id):
"""
- Get numa id of specified pci device
+ Get numa number of specified pci device.
"""
- numa = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node" %
- (bus_id, devfun_id), "# ")
+ get_device_numa = getattr(
+ self, "get_device_numa_%s" % self.get_os_type())
+ return get_device_numa(bus_id, devfun_id)
+
+ def get_device_numa_linux(self, bus_id, devfun_id):
+ """
+ Get numa number of specified pci device on Linux.
+ """
+ numa = self.send_expect(
+ "cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node" %
+ (bus_id, devfun_id), "# ", alt_session=True)
try:
numa = int(numa)
@@ -259,14 +267,14 @@ class Crb(object):
Get ipv6 address of specified pci device on linux.
"""
out = self.send_expect("ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'"
- % intf, "# ")
+ % intf, "# ", alt_session=True)
return out.split('/')[0]
def get_ipv6_addr_freebsd(self, intf):
"""
Get ipv6 address of specified pci device on Freebsd.
"""
- out = self.send_expect('ifconfig %s' % intf, '# ')
+ out = self.send_expect('ifconfig %s' % intf, '# ', alt_session=True)
rexp = r"inet6 ([\da-f:]*)%"
pattern = re.compile(rexp)
match = pattern.findall(out)
@@ -275,6 +283,22 @@ class Crb(object):
return match[0]
+ def disable_ipv6(self, intf):
+ """
+ Disable ipv6 of of specified interface
+ """
+ if intf != 'N/A':
+ self.send_expect("sysctl net.ipv6.conf.%s.disable_ipv6=1" %
+ intf, "# ", alt_session=True)
+
+ def enable_ipv6(self, intf):
+ """
+ Enable ipv6 of of specified interface
+ """
+ if intf != 'N/A':
+ self.send_expect("sysctl net.ipv6.conf.%s.disable_ipv6=0" %
+ intf, "# ", alt_session=True)
+
def create_file(self, contents, fileName):
"""
Create file with contents and copy it to CRB.
@@ -318,7 +342,7 @@ class Crb(object):
if isinstance(self, Dut) and self.get_os_type() == 'freebsd':
expected = 'FreeBSD.*#'
- self.send_expect('uname', expected, 2)
+ self.send_expect('uname', expected, 2, alt_session=True)
def init_core_list(self):
"""
@@ -378,7 +402,9 @@ class Crb(object):
self.cores = []
cpuinfo = \
- self.send_expect("grep \"processor\\|physical id\\|core id\\|^$\" /proc/cpuinfo", "#")
+ self.send_expect(
+ "grep --color=never \"processor\\|physical id\\|core id\\|^$\" /proc/cpuinfo",
+ "#", alt_session=True)
cpuinfo = cpuinfo.split('\r\n\r\n')
for line in cpuinfo:
m = re.search("processor\t: (\d+)\r\n" +
--
1.9.3
next prev parent reply other threads:[~2015-05-22 9:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 9:03 [dts] [PATCH v2 00/19] *** Enable virtualization test for dts framework *** Jiajia, Sun
2015-05-22 9:03 ` [dts] [PATCH v2 01/19] Abstract the NIC device as the single class NetDevice Jiajia, Sun
2015-05-22 9:03 ` [dts] [PATCH v2 02/19] Add a base module for virtual test Jiajia, Sun
2015-05-22 9:03 ` [dts] [PATCH v2 03/19] Add QEMU KVM module based on virt_base module for KVM test cases Jiajia, Sun
2015-05-22 9:03 ` [dts] [PATCH v2 04/19] Add a module to manage the host resource Jiajia, Sun
2015-05-22 9:03 ` [dts] [PATCH v2 05/19] Add a module to instantiate the VM Jiajia, Sun
2015-05-25 6:10 ` Qiu, Michael
2015-05-25 9:14 ` Jiajia, SunX
2015-05-26 9:07 ` Qiu, Michael
2015-05-27 1:36 ` Jiajia, SunX
2015-05-22 9:03 ` [dts] [PATCH v2 06/19] Add a third-party module of qemu-guest-agent to manage VM Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 07/19] Move some general functions from dts.py to utils.py and settings.py Jiajia, Sun
2015-05-22 9:04 ` Jiajia, Sun [this message]
2015-05-22 9:04 ` [dts] [PATCH v2 09/19] Change and add some functions to support virtual test Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 10/19] add some exceptions to support framwork to handle virtual test exceptions Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 11/19] Add some codes to support virtual test log Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 12/19] Add some codes to make session to support virtual test Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 13/19] Add some base functions to get the device info in the testpmd Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 14/19] Change some codes to support network device instantiation and virtualization test Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 15/19] Add some codes to support network instantiation in the tester module Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 16/19] Make test_case know its suite name Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 17/19] Add a global virtualization config and a config related to SRIOV KVM suite Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 18/19] Add a test plan of how to test SRIOV on the KVM ENV Jiajia, Sun
2015-05-22 9:04 ` [dts] [PATCH v2 19/19] Add a test suite to verify the SRIOV feature " Jiajia, Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432285452-14286-9-git-send-email-sunx.jiajia@intel.com \
--to=sunx.jiajia@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).