From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50389A0032; Fri, 24 Jun 2022 11:46:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CC6840A8A; Fri, 24 Jun 2022 11:46:10 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id EC4AB4069D for ; Fri, 24 Jun 2022 11:46:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656063969; x=1687599969; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=U8ouH7flScAbde57Efk+JjbGLAEiWd7XfrGoWIq3ctg=; b=nxnkKgTGbXRaR13+8IrBpHqI5SvFwK/yrpDvFQzPAon59YACyOhl90fJ t9JSkbwocZUSuZzZLc84A/CRACH9byhyma/VtWDv4OzIifu1Uf7YcTp+8 CGByPeM4GlXMo1PDq2QeInhvZsLkfy08J2GBKAopJIb4VM2f3fwM92Q7o wgs8RwSNF5W8X4mXA0x1tsFbr+R+RlAKvuZcyHPM2b+pFBDqWyoUbeNEb 54EmMIkG4BWWbH9nNQrLvCY0iMQ0STNvQpmcql4m04ShBQ5d6w0YMK+Bx vFUWEtQmbQSwdR0SRXQ8TFZ8jHAnYTk9MMXqVm8/wMZN5uYDrzQdPmeE4 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="269696266" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="269696266" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 02:46:07 -0700 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="621669770" Received: from unknown (HELO localhost.localdomain) ([10.239.252.222]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 02:46:06 -0700 From: Wei Ling To: dts@dpdk.org Cc: Wei Ling Subject: [dts][PATCH V2 2/2] tests/vhost_qemu_mtu: add new testsuite vhost_qemu_mtu Date: Fri, 24 Jun 2022 05:43:31 -0400 Message-Id: <20220624094331.2891595-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Add new testsuite for automation test. Signed-off-by: Wei Ling --- v2: -delete unused method start_vm_testpmd. tests/TestSuite_vhost_qemu_mtu.py | 116 ++++++++++++++++++++++++++++++ 1 file changed, 116 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 00000000..a71b7b6e --- /dev/null +++ b/tests/TestSuite_vhost_qemu_mtu.py @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Intel Corporation +# + +import re + +import framework.utils as utils +from framework.pmd_output import PmdOutput +from framework.test_case import TestCase +from framework.virt_common import VM + + +class TestVhostQemuMTU(TestCase): + def set_up_all(self): + self.dut_ports = self.dut.get_ports() + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) + self.cores_list = self.dut.get_core_list("all", socket=self.ports_socket) + self.verify( + len(self.cores_list) >= 4, + "There has not enough cores to test this suite %s" % self.suite_name, + ) + self.vhost_core_list = self.cores_list[0:2] + self.vm_num = 1 + self.base_dir = self.dut.base_dir.replace("~", "/root") + self.vhost_user = self.dut.new_session(suite="vhost-user") + self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user) + + def set_up(self): + """ + run before each test case. + """ + self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#") + self.dut.send_expect("killall -s INT dpdk-testpmd", "#") + self.dut.send_expect("killall -s INT qemu-system-x86_64", "#") + self.vm_dut = [] + self.vm = [] + + def start_vhost_testpmd(self): + """ + start testpmd on vhost + """ + vdevs = ["net_vhost0,iface=vhost-net0,queues=1"] + ports = [self.dut.ports_info[self.dut_ports[0]]["pci"]] + param = "--txd=512 --rxd=128 --nb-cores=1 --port-topology=chained" + self.vhost_user_pmd.start_testpmd( + cores=self.vhost_core_list, + param=param, + vdevs=vdevs, + ports=ports, + prefix="vhost-user", + ) + self.vhost_user_pmd.execute_cmd("set fwd mac") + self.vhost_user_pmd.execute_cmd("start") + + def start_vms(self, vm_config="vhost_sample", mtu=9000): + """ + start two VM, each VM has one virtio device + """ + for i in range(self.vm_num): + vm_dut = None + vm_info = VM(self.dut, "vm%d" % i, vm_config) + vm_params = {} + vm_params["driver"] = "vhost-user" + vm_params["opt_path"] = self.base_dir + "/vhost-net%d" % i + vm_params["opt_mac"] = "52:54:00:00:00:0%d" % (i + 1) + vm_params["opt_settings"] = "mrg_rxbuf=on,host_mtu=%d" % mtu + vm_info.set_vm_device(**vm_params) + try: + vm_dut = vm_info.start(set_target=False) + if vm_dut is None: + raise Exception("Set up VM ENV failed") + except Exception as e: + print(utils.RED("Failure for %s" % str(e))) + self.verify(vm_dut is not None, "start vm failed") + self.vm_dut.append(vm_dut) + self.vm.append(vm_info) + + def check_mtu_value_in_vm(self, mtu): + vm1_intf = self.vm_dut[0].ports_info[0]["intf"] + out = self.vm_dut[0].send_expect("ifconfig %s" % vm1_intf, "#", 10) + self.verify("mtu %d" % mtu in out, "Check MTU value in VM FAILED!") + + def check_mtu_value_in_testpmd(self, mtu): + out = self.vhost_user_pmd.execute_cmd("show port info 1") + self.verify("MTU: %d" % mtu in out, "Check MTU value in testpmd FAILED!") + + def stop_all_apps(self): + for i in range(len(self.vm)): + self.vm[i].stop() + self.vm_dut.remove(self.vm_dut[i]) + self.vm.remove(self.vm[i]) + self.vhost_user_pmd.quit() + + def test_mtu_in_virtio_net(self): + """ + Test Case: Test the MTU in virtio-net + """ + MTU_LIST = [9000, 68, 65535] + for expected_mtu in MTU_LIST: + self.start_vhost_testpmd() + self.start_vms(mtu=expected_mtu) + self.check_mtu_value_in_vm(mtu=expected_mtu) + self.check_mtu_value_in_testpmd(mtu=expected_mtu) + self.stop_all_apps() + + def tear_down(self): + """ + run after each test case. + """ + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.25.1