From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id A727E5934 for ; Wed, 4 May 2016 08:19:47 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 03 May 2016 23:19:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,575,1455004800"; d="scan'208";a="798390505" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 03 May 2016 23:19:48 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u446JjRm003563; Wed, 4 May 2016 14:19:45 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u446Jgcq016788; Wed, 4 May 2016 14:19:44 +0800 Received: (from yufengmx@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u446JgiH016784; Wed, 4 May 2016 14:19:42 +0800 From: Yufen Mo To: dts@dpdk.org Cc: yufengmx Date: Wed, 4 May 2016 14:19:38 +0800 Message-Id: <1462342778-16746-2-git-send-email-yufengx.mo@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1462342778-16746-1-git-send-email-yufengx.mo@intel.com> References: <1462342778-16746-1-git-send-email-yufengx.mo@intel.com> Subject: [dts] [PATCH V1]dpdk ethtool update test script and test plan 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: Wed, 04 May 2016 06:19:48 -0000 From: yufengmx change vlan packet check number,add process to resize linux ethtool eeprom dump data content, ignore auto test link connect status on FVL. update related test cases' test plan. Signed-off-by: yufengmx --- tests/TestSuite_userspace_ethtool.py | 89 +++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py index c479093..a0f4018 100644 --- a/tests/TestSuite_userspace_ethtool.py +++ b/tests/TestSuite_userspace_ethtool.py @@ -38,12 +38,12 @@ import dts import time import re from test_case import TestCase -from pmd_output import PmdOutput from packet import Packet, sniff_packets, load_sniff_packets import random from etgen import IxiaPacketGenerator from settings import HEADER_SIZE from settings import SCAPY2IXIA +from utils import RED class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): @@ -127,6 +127,22 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): else: return 1518 + def resize_linux_eeprom_file(self, dpdk_eeprom_file, linux_eeprom_file): + basePath = "/root/dpdk/" + with open( basePath + dpdk_eeprom_file, 'rb') as fpDpdk: + dpdk_bytes = fpDpdk.read() + dpdk_length = len(dpdk_bytes) + + with open( basePath + linux_eeprom_file, 'rb') as fplinux: + linux_bytes = fplinux.read() + linux_length = len(linux_bytes) + + self.verify(dpdk_length <= linux_length, + "linux ethtool haven't dump out enough data as dpdk ethtool") + + with open( basePath + linux_eeprom_file, 'wb') as fplinux: + fplinux.write(linux_bytes[:dpdk_length]) + def strip_md5(self, filename): md5_info = self.dut.send_expect("md5sum %s" % filename, "# ") md5_pattern = r"(\w+) (\w+)" @@ -155,30 +171,33 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): version = m.group(3) print dts.GREEN("Detect port %s with %s driver\n" % (port, driver)) - # check link status dump function - for port in self.ports: - tester_port = self.tester.get_local_port(port) - intf = self.tester.get_interface(tester_port) - self.tester.send_expect("ip link set dev %s down" % intf, "# ") - # wait for link stable - time.sleep(5) - - out = self.dut.send_expect("link", "EthApp>", 60) - link_pattern = r"Port (\d+): (.*)" - link_infos = out.split("\r\n") - for link_info in link_infos: - m = re.match(link_pattern, link_info) - if m: - port = m.group(1) - status = m.group(2) - self.verify(status == "Down", "Userspace tool failed to detect link down") - - for port in self.ports: - tester_port = self.tester.get_local_port(port) - intf = self.tester.get_interface(tester_port) - self.tester.send_expect("ip link set dev %s up" % intf, "# ") - # wait for link stable - time.sleep(5) + # ethtool doesn't support port disconnect by tools of linux + # only detect physical link disconnect status + if self.nic.startswith("fortville") == False: + # check link status dump function + for port in self.ports: + tester_port = self.tester.get_local_port(port) + intf = self.tester.get_interface(tester_port) + self.tester.send_expect("ip link set dev %s down" % intf, "# ") + # wait for link stable + time.sleep(5) + + out = self.dut.send_expect("link", "EthApp>", 60) + link_pattern = r"Port (\d+): (.*)" + link_infos = out.split("\r\n") + for link_info in link_infos: + m = re.match(link_pattern, link_info) + if m: + port = m.group(1) + status = m.group(2) + self.verify(status == "Down", "Userspace tool failed to detect link down") + + for port in self.ports: + tester_port = self.tester.get_local_port(port) + intf = self.tester.get_interface(tester_port) + self.tester.send_expect("ip link set dev %s up" % intf, "# ") + # wait for link stable + time.sleep(5) # check port stats function pkt = Packet(pkt_type='UDP') @@ -271,8 +290,10 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): for index in range(len(self.ports)): md5 = self.strip_md5(portsinfo[index]['eeprom_file']) + self.resize_linux_eeprom_file( portsinfo[index]['eeprom_file'], portsinfo[index]['ethtool_eeprom']) md5_ref = self.strip_md5(portsinfo[index]['ethtool_eeprom']) - print dts.GREEN("Reference eeprom md5 %s" % md5_ref) + print dts.GREEN("Reference eeprom md5 %s" % md5) + print dts.GREEN("Reference eeprom md5_ref %s" % md5_ref) self.verify(md5 == md5_ref, "Dumped eeprom not same as linux dumped") def test_ring_parameter(self): @@ -323,7 +344,6 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): tester_port = self.tester.get_local_port(port) intf = self.tester.get_interface(tester_port) pkt.send_pkt(tx_port=intf) - time.sleep(2) rx_pkts, tx_pkts = self.strip_portstats(port) self.verify(rx_pkts == ori_rx_pkts + 1, "Failed to Rx vlan packet") self.verify(tx_pkts == ori_tx_pkts + 1, "Failed to Tx vlan packet") @@ -372,8 +392,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): inst = sniff_packets(intf, timeout=5) pkt.send_pkt(tx_port=intf) pkts = load_sniff_packets(inst) - self.verify(len(pkts) == 2, "Packet not forwarded as expected") - src_mac = pkts[1].strip_layer_element("layer2", "src") + self.verify(len(pkts) == 1, "Packet not forwarded as expected") + src_mac = pkts[0].strip_layer_element("layer2", "src") self.verify(src_mac == valid_mac, "Forwarded packet not match default mac") # check multicase will not be valid mac @@ -405,11 +425,17 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): rx_pkts, tx_pkts = self.strip_portstats(index) self.verify(rx_pkts == ori_rx_pkts, "Failed to stop port") # restart port and check packet can normally forwarded + time.sleep(2) self.dut.send_expect("open %d" % index, "EthApp>") # wait few time for port ready - time.sleep(0.5) + rx_pkts, tx_pkts = self.strip_portstats(index) + time.sleep(2) pkt.send_pkt(tx_port=intf) rx_pkts_open, tx_pkts_open = self.strip_portstats(index) + if rx_pkts_open != rx_pkts + 1: + RED( "Failed to reopen port rx") + if tx_pkts_open != tx_pkts + 1: + RED( "Failed to reopen port tx") self.verify(rx_pkts_open == rx_pkts + 1, "Failed to reopen port rx") self.verify(tx_pkts_open == tx_pkts + 1, "Failed to reopen port tx") @@ -430,11 +456,12 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator): self.tester.send_expect("ifconfig %s mtu 9000" % (intf), "# ") for mtu in mtus: self.dut.send_expect("mtu %d %d" % (index, mtu), "EthApp>") + ori_rx_pkts, _ = self.strip_portstats(index) pkt_size = mtu + HEADER_SIZE['eth'] pkt = Packet(pkt_len=pkt_size) pkt.send_pkt(tx_port=intf) rx_pkts, _ = self.strip_portstats(index) - self.verify(rx_pkts == 1, "Packet match mtu not forwarded as expected") + self.verify(rx_pkts == ori_rx_pkts, "Packet match mtu not forwarded as expected") pkt = Packet(pkt_len=mtu + 1) pkt.send_pkt(tx_port=intf) rx_pkts_over, _ = self.strip_portstats(index) -- 1.9.3