From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E13091B427 for ; Fri, 15 Feb 2019 07:48:09 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2019 22:48:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,371,1544515200"; d="scan'208";a="134504363" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.240.176.135]) by orsmga002.jf.intel.com with ESMTP; 14 Feb 2019 22:48:07 -0800 From: Peng Yuan To: dts@dpdk.org Cc: Peng Yuan Date: Fri, 15 Feb 2019 14:52:00 +0800 Message-Id: <1550213520-7242-1-git-send-email-yuan.peng@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH]tests: encapsulate funtion for TestSuite_veb_switch 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: Fri, 15 Feb 2019 06:48:10 -0000 Encapsulate funtion for TestSuite_veb_switch.py Signed-off-by: Peng Yuan diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.py index 0dc570a..0b0089b 100644 --- a/tests/TestSuite_veb_switch.py +++ b/tests/TestSuite_veb_switch.py @@ -127,7 +127,30 @@ class TestVEBSwitching(TestCase): pkt.config_layer('ether', {'dst': vf_mac}) pkt.send_pkt(tx_port=itf) time.sleep(.5) - + + def count_packet(self, out, mac): + """ + Count packet sum number. + """ + lines = out.split("\r\n") + cnt = 0 + count_pkt = 0 + # count the packet received from specified mac address. + for line in lines: + line = line.strip() + if len(line) != 0 and line.startswith(("src=",)): + for item in line.split(" "): + item = item.strip() + if(item == ("src=%s" % mac)): + cnt = cnt + 1 + elif(item == "L4_UDP"): + cnt = cnt + 1 + if (cnt == 2): + count_pkt = count_pkt + 1 + cnt = 0 + print utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt) + return count_pkt + # Test cases. def set_up_all(self): """ @@ -207,8 +230,8 @@ class TestVEBSwitching(TestCase): def test_VEB_switching_inter_vfs(self): """ - Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffic to - VF1, and set the packet's DEST MAC to VF2, check if VF2 can receive + Kernel PF, then create 2VFs. VFs running dpdk testpmd, + send traffic from VF1 to VF2, check if VF2 can receive the packets. Check Inter VF-VF MAC switch. """ self.setup_env(driver='default') @@ -234,8 +257,8 @@ class TestVEBSwitching(TestCase): def test_VEB_switching_inter_vfs_mac_fwd(self): """ Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffic to - VF1, and set the packet's DEST MAC to VF2, check if VF2 can receive - the packets. Check Inter VF-VF MAC switch. + VF1 with VF1's MAC as packet's DEST MAC, set ether peer address to VF2's MAC. + Check if VF2 can receive the packets. Check Inter VF-VF MAC switch. """ self.setup_env(driver='default') self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120) @@ -344,27 +367,12 @@ class TestVEBSwitching(TestCase): out = self.dut.get_session_output(timeout=1) self.session_secondary.send_expect("stop", "testpmd>", 2) self.dut.send_expect("stop", "testpmd>", 2) - lines = out.split("\r\n") - cnt = 0 - count_pkt = 0 - # count the packet received by pf from vf. - for line in lines: - line = line.strip() - if len(line) != 0 and line.startswith(("src=",)): - for item in line.split(" "): - item = item.strip() - if(item == ("src=%s" % self.vf0_mac)): - cnt = cnt + 1 - elif(item == "L4_UDP"): - cnt = cnt + 1 - if (cnt == 2): - count_pkt = count_pkt + 1 - cnt = 0 - print utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt) + + count_pkt = self.count_packet(out, self.vf0_mac) vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx") pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx") - self.verify(vf0_tx_stats[0] > 0, "no packet was sent by VF0") - self.verify(count_pkt > 0, "no packet was received by PF") + self.verify(vf0_tx_stats[0] > 1000, "no packet was sent by VF0") + self.verify(count_pkt > 100, "no packet was received by PF") self.session_secondary.send_expect("quit", "# ") time.sleep(2) self.dut.send_expect("quit", "# ") @@ -388,7 +396,7 @@ class TestVEBSwitching(TestCase): vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx") print utils.GREEN("The number of UDP packets received by vf is %d." % vf0_rx_stats[0]) - self.verify(vf0_rx_stats[0] > 0, "no packet was received by VF0") + self.verify(vf0_rx_stats[0] > 100, "no packet was received by VF0") self.session_secondary.send_expect("quit", "# ") time.sleep(2) self.dut.send_expect("quit", "# ") -- 2.5.0