From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C7575E62 for ; Tue, 14 Jul 2015 10:33:26 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 14 Jul 2015 01:33:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,470,1432623600"; d="scan'208";a="762040811" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 14 Jul 2015 01:33:25 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t6E8XNib016021; Tue, 14 Jul 2015 16:33:23 +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 t6E8XLIh016415; Tue, 14 Jul 2015 16:33:23 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t6E8XKJH016411; Tue, 14 Jul 2015 16:33:20 +0800 From: Yong Liu To: dts@dpdk.org Date: Tue, 14 Jul 2015 16:33:19 +0800 Message-Id: <1436862799-16379-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] Optimize vlan test suite routine and style 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, 14 Jul 2015 08:33:27 -0000 From: Marvin Liu Start testpmd command move to set_up function which will be called before every case. Optimize code style too. Signed-off-by: Marvin Liu diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py index 2f5dfd4..2b3de8a 100644 --- a/tests/TestSuite_vlan.py +++ b/tests/TestSuite_vlan.py @@ -32,11 +32,8 @@ """ DPDK Test suite. - Test the support of VLAN Offload Features by Poll Mode Drivers. - """ - import dts import time @@ -50,8 +47,6 @@ class TestVlan(TestCase): def set_up_all(self): """ Run at the start of each test suite. - - Vlan Prerequistites """ global dutRxPortId @@ -66,32 +61,21 @@ class TestVlan(TestCase): valports = [_ for _ in ports if self.tester.get_local_port(_) != -1] dutRxPortId = valports[0] dutTxPortId = valports[1] - portMask = dts.create_mask(valports[:2]) + self.portMask = dts.create_mask(valports[:2]) self.pmdout = PmdOutput(self.dut) - self.pmdout.start_testpmd("all", "--portmask=%s" % portMask ) - - self.dut.send_expect("set verbose 1", "testpmd> ") - out = self.dut.send_expect("set fwd mac", "testpmd> ") - - if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]: - self.dut.send_expect("set promisc all off", "testpmd> ") - self.dut.send_expect("vlan set filter on %s"%dutRxPortId, "testpmd> ") - - self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ") - self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error") self.vlan = 51 - + def start_tcpdump(self): port = self.tester.get_local_port(dutTxPortId) rxItf = self.tester.get_interface(port) - self.tester.send_expect("rm -rf ./vlan_test.cap","#") - self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& "%rxItf,"#" ) - + self.tester.send_expect("rm -rf ./vlan_test.cap", "#") + self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& " % rxItf, "#") + def get_tcpdump_package(self): - self.tester.send_expect("killall tcpdump","#") - return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap","#") + self.tester.send_expect("killall tcpdump", "#") + return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap", "#") def vlan_send_packet(self, vid, num=1): """ @@ -109,7 +93,6 @@ class TestVlan(TestCase): self.dmac = self.dut.get_mac_address(dutRxPortId) # FIXME send a burst with only num packet - self.tester.scapy_append('sendp([Ether(src="%s",dst="%s")/Dot1Q(vlan=%s)/IP(len=46)], iface="%s")' % (self.smac, self.dmac, vid, txItf)) self.tester.scapy_execute() @@ -118,34 +101,40 @@ class TestVlan(TestCase): """ Run before each test case. """ - pass + self.pmdout.start_testpmd("all", "--portmask=%s" % self.portMask) + + self.dut.send_expect("set verbose 1", "testpmd> ") + out = self.dut.send_expect("set fwd mac", "testpmd> ") + self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error") + + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]: + self.dut.send_expect("set promisc all off", "testpmd> ") + self.dut.send_expect("vlan set filter on %s" % dutRxPortId, "testpmd> ") + + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ") + def test_vlan_enable_receipt(self): """ Enable receipt of VLAN packets """ - if self.nic == "redrockcanyou" : + if self.nic == "redrockcanyou": print dts.RED("fm10k not support this case\n") return self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ") self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ") self.dut.send_expect("start", "testpmd> ", 120) out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20) - + self.start_tcpdump() self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() self.verify("vlan %d" % self.vlan in out, "Wrong vlan:" + out) - self.dut.send_expect("stop", "testpmd> ") - - def test_vlan_disable_receipt(self): """ Disable receipt of VLAN packets """ - - self.dut.send_expect("rx_vlan rm %d %s" % (self.vlan, dutRxPortId), "testpmd> ") self.dut.send_expect("start", "testpmd> ", 120) self.start_tcpdump() @@ -153,14 +142,12 @@ class TestVlan(TestCase): out = self.get_tcpdump_package() # fm10k switch will redirect package if not send to nic - if (not((self.nic == "redrockcanyou") and ("%s > %s"%(self.smac, self.dmac) in out))): + if(not((self.nic == "redrockcanyou") and ("%s > %s" % (self.smac, self.dmac) in out))): self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out) out = self.dut.send_expect("stop", "testpmd> ") - def test_vlan_strip_config_on(self): - self.dut.send_expect("vlan set strip on %s" % dutRxPortId, "testpmd> ", 20) self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ", 20) out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20) @@ -171,11 +158,9 @@ class TestVlan(TestCase): self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out) - out = self.dut.send_expect("quit", "#", 120) def test_vlan_strip_config_off(self): - - if self.nic == "redrockcanyou" : + if self.nic == "redrockcanyou": print dts.RED("fm10k not support this case\n") return self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ", 20) @@ -194,7 +179,6 @@ class TestVlan(TestCase): """ Enable VLAN header insertion in transmitted packets """ - port = self.tester.get_local_port(dutTxPortId,) intf = self.tester.get_interface(port) @@ -216,15 +200,12 @@ class TestVlan(TestCase): if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]: self.dut.send_expect("tx_vlan reset %s" % dutTxPortId, "testpmd> ", 30) self.dut.send_expect("stop", "testpmd> ", 30) - else: - self.dut.send_expect("quit", "# ", 30) def tear_down(self): """ Run after each test case. """ - pass - + self.dut.send_expect("quit", "# ", 30) def tear_down_all(self): """ -- 1.9.3