From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 2D29FAABF for ; Tue, 17 Apr 2018 10:10:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 01:10:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,462,1517904000"; d="scan'208";a="32559089" Received: from unknown (HELO ubuntu.icx.intel.com) ([10.67.119.92]) by fmsmga007.fm.intel.com with ESMTP; 17 Apr 2018 01:10:50 -0700 From: lihong To: dts@dpdk.org Cc: lihong Date: Tue, 17 Apr 2018 09:02:22 +0800 Message-Id: <1523926942-1564-1-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V1] Add test suite about qemu mtu setting X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 08:10:56 -0000 Signed-off-by: lihong --- tests/TestSuite_vhost_qemu_mtu.py | 183 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 tests/TestSuite_vhost_qemu_mtu.py diff --git a/tests/TestSuite_vhost_qemu_mtu.py b/tests/TestSuite_vhost_qemu_mtu.py new file mode 100644 index 0000000..d241441 --- /dev/null +++ b/tests/TestSuite_vhost_qemu_mtu.py @@ -0,0 +1,183 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2018 Intel Corporation. All rights reserved. +# 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. +test the mtu seting. +""" +import re +import time +import utils +from test_case import TestCase +from virt_common import VM + + +class TestVhostUserSetMTU(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 + 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/3C/1T", socket=self.socket) + + self.host_mtu = [68, 9000, 65535] + self.virtio1_mac = "52:54:00:00:00:01" + self.vm_dut = None + + def set_up(self): + """ + Run before each test case. + """ + self.dut.send_expect("rm -rf ./vhost.out", "#") + self.dut.send_expect("rm -rf ./vhost-net*", "#") + self.dut.send_expect("killall -s INT vhost-switch", "#") + + def launch_testpmd(self): + self.testcmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c %s -n 4 --socket-mem 1024,1024" \ + + " --vdev 'net_vhost0,iface=vhost-net,queues=1' -- -i --nb-cores=1 --port-topology=chained" + self.coremask = utils.create_mask(self.cores) + self.testcmd_start = self.testcmd % (self.coremask) + + self.dut.send_expect(self.testcmd_start, "testpmd> ", 120) + self.dut.send_expect("start", "testpmd> ", 120) + + def start_onevm(self, mtu_value): + """ + Start One VM with one virtio device + The qemu version should greater than 2.9 + """ + + self.vm = VM(self.dut, 'vm0', 'vhost_sample') + vm_params = {} + vm_params['driver'] = 'vhost-user' + vm_params['opt_path'] = './vhost-net' + vm_params['opt_mac'] = self.virtio1_mac + vm_params['opt_settings'] = 'mrg_rxbuf=on,host_mtu=%d' % mtu_value + self.vm.set_vm_device(**vm_params) + + try: + self.vm_dut = self.vm.start() + if self.vm_dut is None: + out = self.vm.host_session.send_expect("%s -version" % self.vm.qemu_emulator, "#") + ver = re.findall('version (\S*)', out) + index = ver[0].find(".", 2) + ver_num = ver[0][0:index].replace(".", "") + self.verify(int(ver_num) >= 29, "The qemu version should greater than 2.9") + raise Exception("Set up VM ENV failed") + except Exception as e: + self.logger.error("ERROR: Failure for %s" % str(e)) + + return True + + def verify_vm_kernel(self): + """ + The vm kernel version shouled greater than 4.10 + """ + if(self.vm_dut is not None): + out = self.vm_dut.send_expect("uname -r", "#", 10) + index = out.find(".", 2) + cur_kernel = out[0:index] + ker_str = cur_kernel.replace(".", "") + self.verify(int(ker_str) >= 410, "The VM kernel version should grand than 4.10!!") + + def test_perf_vm_hostmtu_seting_testcase(self): + """ + Test seting of host_mtu + """ + self.launch_testpmd() + + for mtu in self.host_mtu: + self.start_onevm(mtu) + self.verify_vm_kernel() + + # verify the mtu in testpmd + vm_testpmd = self.target + "/app/testpmd -c 0x03 -n 3 -- -i" + self.vm_dut.send_expect(vm_testpmd, "testpmd>", 60) + out = self.vm_dut.send_expect("show port info 0", "testpmd>", 20) + lines = re.search("MTU:\s*(\d*)", out) + result = lines.group(1) + results = float(result) + self.verify(results == mtu, + "The seting host mtu:%d no equal the vm virtio testpmd mtu:%d" % (mtu, results)) + self.logger.info('The MTU setting in testpmd has passed, mtu in testpmd: %d' % results) + self.vm_dut.send_expect("quit", "#", 60) + + # verify the mtu in kernel driver + # unbind the vritio network device + for port in self.vm_dut.ports_info: + self.vm_intf = port['intf'] + pp = port['port'] + pp.bind_driver() + + findmtu = 0 + out = self.vm_dut.send_expect("ifconfig", "#", 20) + lines = re.findall("MTU:(.*)", out) + for line in lines: + dd = re.search("(\d*)(.*)", line) + result = dd.group(1) + results = float(result) + if results == mtu: + findmtu = 1 + break + self.verify(findmtu == 1, + "The seting host mtu:%d no equal the vm virtio mtu:%d" % (mtu, results)) + self.logger.info('The MTU setting of kernel network has passed, mtu in kernel driver:%d' % results) + + # verify the mtu in host testpmd + out = self.dut.send_expect("show port info 1", "testpmd>", 60) + lines = re.search("MTU:\s*(\d*)", out) + result = lines.group(1) + results = float(result) + self.verify(results == mtu, + "The seting host mtu:%d no equal the virtio mtu on host testpmd:%d" % (mtu, results)) + self.logger.info('The MTU setting in host testpmd has passed, mtu in testpmd: %d' % results) + + self.vm.stop() + + self.dut.send_expect("quit", "#", 60) + + def tear_down(self): + """ + Run after each test case. + Clear vhost-switch and qemu to avoid blocking the following TCs + """ + pass + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.7.4