From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C812EC324 for ; Thu, 21 May 2015 10:30:33 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 May 2015 01:30:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,467,1427785200"; d="scan'208";a="732947826" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 21 May 2015 01:30:32 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4L8UUXM008046; Thu, 21 May 2015 16:30:30 +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 t4L8USIN012780; Thu, 21 May 2015 16:30:30 +0800 Received: (from huilongx@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4L8USjO012776; Thu, 21 May 2015 16:30:28 +0800 From: huilongx xu To: dts@dpdk.org Date: Thu, 21 May 2015 16:30:18 +0800 Message-Id: <1432197020-12725-4-git-send-email-huilongx.xu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1432197020-12725-1-git-send-email-huilongx.xu@intel.com> References: <1432197020-12725-1-git-send-email-huilongx.xu@intel.com> Cc: jingguox.fu@intel.com Subject: [dts] [dts 3/5] [v2] add dynamic config test script 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: Thu, 21 May 2015 08:30:34 -0000 From: huilong xu Signed-off-by: huilong xu --- tests/TestSuite_dynamic_config.py | 262 +++++++++++++++++++++++++++++++++++++ 1 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 tests/TestSuite_dynamic_config.py diff --git a/tests/TestSuite_dynamic_config.py b/tests/TestSuite_dynamic_config.py new file mode 100644 index 0000000..d1ad49c --- /dev/null +++ b/tests/TestSuite_dynamic_config.py @@ -0,0 +1,262 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2015 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 dynamic driver configuration feature. + +""" + +import dts + +from test_case import TestCase + +# +# +# Test class. +# + + +class TestDynamicConfig(TestCase): + + # + # + # + # Test cases. + # + + def set_up_all(self): + """ + Run at the start of each test suite. + + + Dynamic config Prerequistites + """ + + # Based on h/w type, choose how many ports to use + self.dut_ports = self.dut.get_ports(self.nic) + print self.dut_ports + + # Verify that enough ports are available + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + self.verify(len(self.dut_ports) >= 2, "Insufficient ports") + else: + self.verify(len(self.dut_ports) >= 1, "Insufficient ports") + + # Prepare cores and ports + cores = self.dut.get_core_list('1S/2C/2T') + coreMask = dts.create_mask(cores) + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + portMask = dts.create_mask(self.dut_ports[:2]) + else: + portMask = dts.create_mask([self.dut_ports[0]]) + + # launch app + cmd = "./%s/build/app/test-pmd/testpmd -c %s -n 3 -- -i --rxpt=0 \ + --rxht=0 --rxwt=0 --txpt=39 --txht=0 --txwt=0 --portmask=%s" % (self.target, coreMask, portMask) + + self.dut.send_expect("%s" % cmd, "testpmd> ", 120) + + # get dest address from self.target port + out = self.dut.send_expect( + "show port info %d" % self.dut_ports[0], "testpmd> ") + + self.dest = self.dut.get_mac_address(self.dut_ports[0]) + mac_scanner = r"MAC address: (([\dA-F]{2}:){5}[\dA-F]{2})" + + ret = dts.regexp(out, mac_scanner) + + self.verify(ret is not None, "MAC address not found") + self.verify(cmp(ret.lower(), self.dest) == 0, "MAC address wrong") + self.verify("Promiscuous mode: enabled" in out, + "wrong default promiscuous value") + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + self.dut.send_expect("start", "testpmd> ", 120) + + def dynamic_config_send_packet(self, portid, destMac="00:11:22:33:44:55"): + """ + Send 1 packet to portid + """ + + itf = self.tester.get_interface(self.tester.get_local_port(portid)) + + self.tester.scapy_foreground() + self.tester.scapy_append( + 'sendp([Ether(dst="%s", src="52:00:00:00:00:00")], iface="%s")' % (destMac, itf)) + + self.tester.scapy_execute() + + def set_up(self): + """ + Run before each test case. + """ + pass + + def test_dynamic_config_default_mode(self): + """ + Dynamic config default mode test + """ + + portid = self.dut_ports[0] + + # get the current rx statistic + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # send one packet with different MAC address than the portid + self.dynamic_config_send_packet(portid) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int(pre_rxpkt) + + 1, "1st packet increasement check error") + + # send one packet with the portid MAC address + self.dynamic_config_send_packet(portid, self.dest) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int(pre_rxpkt) + + 1, "2nd packet increasement check error") + + def test_dynamic_config_disable_promiscuous(self): + """ + Dynamic config disable promiscuous test + """ + + portid = self.dut_ports[0] + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + self.dut.send_expect("set promisc all off", "testpmd> ") + out = self.dut.send_expect( + "show port stats %d" % self.dut_ports[1], "testpmd> ") + cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + + self.dynamic_config_send_packet(portid) + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect( + "show port stats %d" % self.dut_ports[1], "testpmd> ") + cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + self.verify(int(cur_rxpkt) == int( + pre_rxpkt), "1st packet increasment error") + self.dynamic_config_send_packet(portid, self.dest) + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect( + "show port stats %d" % self.dut_ports[1], "testpmd> ") + cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + self.verify(int(cur_rxpkt) == int( + pre_rxpkt) + 1, "2nd packet increasment error") + else: + self.dut.send_expect("set promisc %d off" % portid, "testpmd> ") + + # get the current rx statistic + out = self.dut.send_expect( + "show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # send one packet with different MAC address than the portid + self.dynamic_config_send_packet(portid) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect( + "show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int( + pre_rxpkt), "1st packet increasment error") + + # send one packet with the portid MAC address + self.dynamic_config_send_packet(portid, self.dest) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect( + "show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int( + pre_rxpkt) + 1, "2nd packet increasment error") + + def test_dynamic_config_enable_promiscuous(self): + """ + Dynamic config enable promiscuous test + """ + + portid = self.dut_ports[0] + + self.dut.send_expect("set promisc %d on" % portid, "testpmd> ") + + # get the current rx statistic + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # send one packet with different MAC address than the portid + self.dynamic_config_send_packet(portid) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int(pre_rxpkt) + + 1, "1st packet increasment error") + + # send one packet with the portid MAC address + self.dynamic_config_send_packet(portid, self.dest) + + pre_rxpkt = cur_rxpkt + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") + + # check the pakcet increasment + self.verify(int(cur_rxpkt) == int(pre_rxpkt) + + 1, "2nd packet increasment error") + + self.dut.send_expect("quit", "# ", 30) + + def tear_down(self): + """ + Run after each test case. + """ + pass + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 1.7.4.4