From: lihong <lihongx.ma@intel.com>
To: dts@dpdk.org
Cc: yinan.wang@intel.com, lihong <lihongx.ma@intel.com>
Subject: [dts] [patch V1] tests: add testsuite virtio user as exceptional path
Date: Thu, 4 Jul 2019 05:43:02 +0800 [thread overview]
Message-ID: <1562190182-24422-1-git-send-email-lihongx.ma@intel.com> (raw)
Signed-off-by: lihong <lihongx.ma@intel.com>
---
tests/TestSuite_virtio_user_as_exceptional_path.py | 244 +++++++++++++++++++++
1 file changed, 244 insertions(+)
create mode 100644 tests/TestSuite_virtio_user_as_exceptional_path.py
diff --git a/tests/TestSuite_virtio_user_as_exceptional_path.py b/tests/TestSuite_virtio_user_as_exceptional_path.py
new file mode 100644
index 0000000..84e17aa
--- /dev/null
+++ b/tests/TestSuite_virtio_user_as_exceptional_path.py
@@ -0,0 +1,244 @@
+# BSD LICENSE
+#
+# Copyright(c) <2019> Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+DPDK Test suite.
+
+Vhost exception path test suite.
+"""
+import re
+import time
+import utils
+from test_case import TestCase
+from settings import HEADER_SIZE
+from config import UserConf
+
+
+class TestVhostExceptionPath(TestCase):
+
+ def set_up_all(self):
+ # Get and verify the ports
+ self.dut_ports = self.dut.get_ports()
+ self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
+ # Get the port's socket and get the core for testpmd
+ self.pf = self.dut_ports[0]
+ netdev = self.dut.ports_info[self.pf]['port']
+ self.socket = netdev.get_nic_socket()
+ self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
+ self.virtio_ip1 = "1.1.1.2"
+ self.virtio_mac1 = "52:54:00:00:00:01"
+ self.memory_channel = self.dut.get_memory_channels()
+ config = UserConf('conf/vhost_gro.cfg')
+ conf = config.conf
+ section = config.get_sections()
+ self.verify('peerconf' in section,
+ 'Pls config peer info about intf in conf file vhost_gro.cfg')
+ params = conf._sections['peerconf']
+ self.pci = params['pci']
+ self.pci_drv = params['pci_drv']
+ self.peer_pci = params['peer']
+ self.nic_in_kernel = params['peer_intf']
+
+ for i in self.dut_ports:
+ port = self.dut.ports_info[i]['port']
+ port.bind_driver()
+ self.dut.send_expect(
+ "./usertools/dpdk-devbind.py -b igb_uio %s" %
+ self.pci, '#', 30)
+
+ # set diff arg about mem_socket base on socket number
+ if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
+ self.socket_mem = '1024'
+ else:
+ self.socket_mem = '1024,1024'
+
+ self.prepare_dpdk()
+
+ def set_up(self):
+ #
+ # Run before each test case.
+ #
+ # Clean the execution ENV
+ self.dut.send_expect("rm -rf ./vhost-net*", "#")
+ self.dut.send_expect("killall -s INT testpmd", "#")
+ self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
+ self.dut.send_expect("modprobe vhost-net", "#")
+
+ def launch_testpmd_exception_path(self):
+ self.testcmd = self.target + "/app/testpmd -c %s -n %d --socket-mem %s --legacy-mem" \
+ + " --vdev=virtio_user0,mac=%s,path=/dev/vhost-net,queue_size=1024 -- -i" \
+ + " --rxd=1024 --txd=1024"
+ self.coremask = utils.create_mask(self.cores)
+ self.testcmd_start = self.testcmd % (self.coremask, self.memory_channel,
+ self.socket_mem, self.virtio_mac1)
+ self.vhost_user = self.dut.new_session(suite="user")
+ self.vhost_user.send_expect("modprobe vhost-net", "#", 120)
+ self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
+ self.vhost_user.send_expect("set fwd csum", "testpmd> ", 120)
+ self.vhost_user.send_expect("stop", "testpmd> ", 120)
+ self.vhost_user.send_expect("port stop 0", "testpmd> ", 120)
+ self.vhost_user.send_expect("port stop 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("port config 0 tx_offload tcp_cksum on", "testpmd> ", 120)
+ self.vhost_user.send_expect("port config 0 tx_offload ipv4_cksum on", "testpmd> ", 120)
+ self.vhost_user.send_expect("csum set ip sw 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("csum set tcp hw 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("csum set ip hw 0", "testpmd> ", 120)
+ self.vhost_user.send_expect("csum set tcp hw 0", "testpmd> ", 120)
+ self.vhost_user.send_expect("tso set 1448 0", "testpmd> ", 120)
+ self.vhost_user.send_expect("port start 0", "testpmd> ", 120)
+ self.vhost_user.send_expect("port start 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("start", "testpmd> ", 120)
+
+ def prepare_tap_device(self):
+ self.dut.send_expect("ifconfig tap0 up", "#")
+ self.dut.send_expect("ifconfig tap0 1.1.1.2", "#")
+
+ def testpmd_reset(self):
+ self.vhost_user.send_expect("stop", "testpmd> ", 120)
+ self.vhost_user.send_expect("port stop 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("csum set ip sw 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("port start 1", "testpmd> ", 120)
+ self.vhost_user.send_expect("start", "testpmd> ", 120)
+
+ def config_kernel_nic_host(self):
+ #
+ self.dut.send_expect("ip netns del ns1", "#")
+ self.dut.send_expect("ip netns add ns1", "#")
+ self.dut.send_expect("ip link set %s netns ns1" % self.nic_in_kernel, "#")
+ self.dut.send_expect("ip netns exec ns1 ifconfig %s 1.1.1.8 up" % self.nic_in_kernel, "#")
+ self.dut.send_expect("ip netns exec ns1 ethtool -K %s gro on" % self.nic_in_kernel, "#")
+ self.dut.send_expect("ip netns exec ns1 ethtool -K %s tso on" % self.nic_in_kernel, "#")
+
+ def prepare_dpdk(self):
+ #
+ # Changhe the testpmd checksum fwd code for mac change
+ self.dut.send_expect(
+ "cp ./app/test-pmd/csumonly.c ./app/test-pmd/csumonly_backup.c",
+ "#")
+ self.dut.send_expect(
+ "sed -i '/ether_addr_copy(&peer_eth/i\#if 0' ./app/test-pmd/csumonly.c", "#")
+ self.dut.send_expect(
+ "sed -i '/parse_ethernet(eth_hdr, &info/i\#endif' ./app/test-pmd/csumonly.c", "#")
+ self.dut.build_install_dpdk(self.dut.target)
+
+ def unprepare_dpdk(self):
+ # Recovery the DPDK code to original
+ self.dut.send_expect(
+ "cp ./app/test-pmd/csumonly_backup.c ./app/test-pmd/csumonly.c ",
+ "#")
+ self.dut.send_expect("rm -rf ./app/test-pmd/csumonly_backup.c", "#")
+ self.dut.build_install_dpdk(self.dut.target)
+
+ def iperf_result_verify(self, vm_client):
+ '''
+ Get the iperf test result
+ '''
+ fmsg = vm_client.send_expect("cat /root/iperf_client.log", "#")
+ print fmsg
+ iperfdata = re.compile('[\d+]*.[\d+]* [M|G]bits/sec').findall(fmsg)
+ print iperfdata
+ self.verify(iperfdata, 'There no data about this case')
+ self.result_table_create(['Data', 'Unit'])
+ results_row = ['exception path']
+ results_row.append(iperfdata[-1])
+ self.result_table_add(results_row)
+ self.result_table_print()
+ self.output_result = "Iperf throughput is %s" % iperfdata[-1]
+ self.logger.info(self.output_result)
+
+ def test_vhost_exception_path_TAP_original(self):
+ self.config_kernel_nic_host()
+ self.launch_testpmd_exception_path()
+ self.dut.get_session_output(timeout=2)
+ time.sleep(5)
+ # Get the virtio-net device name
+ self.prepare_tap_device()
+ self.testpmd_reset()
+ self.dut.send_expect('ip netns exec ns1 iperf -s -i 1', '', 10)
+ self.iperf = self.dut.new_session(suite="iperf")
+ self.iperf.send_expect('rm /root/iperf_client.log', '#', 10)
+ self.iperf.send_expect('iperf -c 1.1.1.8 -i 1 -t 10 > /root/iperf_client.log &', '', 180)
+ time.sleep(30)
+ self.dut.send_expect('^C', '#', 10)
+ self.iperf_result_verify(self.iperf)
+ self.logger.info("TAP->virtio-user->Kernel_NIC %s " % (self.output_result))
+ self.iperf.send_expect('rm /root/iperf_client.log', '#', 10)
+ self.vhost_user.send_expect("quit", "#", 120)
+ self.dut.close_session(self.vhost_user)
+ self.dut.send_expect("ip netns del ns1", "#")
+ self.dut.close_session(self.iperf)
+
+ def test_vhost_exception_path_NIC_original(self):
+ self.config_kernel_nic_host()
+ self.launch_testpmd_exception_path()
+ time.sleep(5)
+ self.dut.get_session_output(timeout=2)
+ self.prepare_tap_device()
+ self.testpmd_reset()
+ self.iperf = self.dut.new_session(suite="iperf")
+ self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
+ self.iperf.send_expect('iperf -s -i 1', '', 180)
+ self.dut.send_expect('ip netns exec ns1 iperf -c 1.1.1.2 -i 1 -t 10 > /root/iperf_client.log &', '', 10)
+ time.sleep(30)
+ self.iperf.send_expect('^C', '#', 10)
+ self.iperf_result_verify(self.dut)
+ self.dut.get_session_output(timeout=2)
+ self.logger.info("Kernel_NIC<-virtio-user<-TAP %s " % (self.output_result))
+ self.dut.send_expect('rm /root/iperf_client.log', '#', 10)
+ self.vhost_user.send_expect("quit", "#", 120)
+ self.dut.close_session(self.vhost_user)
+ self.dut.send_expect("ip netns del ns1", "#")
+ self.dut.close_session(self.iperf)
+
+ def tear_down(self):
+ #
+ # Run after each test case.
+ #
+ self.dut.send_expect("killall -s INT testpmd", "#")
+ self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
+ self.dut.send_expect("rm -rf ./vhost-net", "#")
+ time.sleep(2)
+ self.dut.send_expect(
+ "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
+ self.dut.send_expect(
+ "./usertools/dpdk-devbind.py -b %s %s" %
+ (self.pci_drv, self.peer_pci), '# ', 30)
+
+ def tear_down_all(self):
+ """
+ Run after each test suite.
+ """
+ self.unprepare_dpdk()
+ self.dut.send_expect(
+ "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
+ self.dut.send_expect(
+ "./usertools/dpdk-devbind.py -b %s %s" %
+ (self.pci_drv, self.pci), '# ', 30)
--
2.7.4
next reply other threads:[~2019-07-04 5:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 21:43 lihong [this message]
2019-07-04 6:02 ` Wang, Yinan
2019-07-04 6:37 ` Ma, LihongX
2019-07-10 6:06 ` Tu, Lijuan
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=1562190182-24422-1-git-send-email-lihongx.ma@intel.com \
--to=lihongx.ma@intel.com \
--cc=dts@dpdk.org \
--cc=yinan.wang@intel.com \
/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).