From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C6FDD1B379 for ; Fri, 22 Dec 2017 10:33: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 orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 01:33:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,440,1508828400"; d="scan'208";a="20378026" Received: from dpdk-test47.sh.intel.com ([10.67.118.152]) by orsmga002.jf.intel.com with ESMTP; 22 Dec 2017 01:33:07 -0800 From: wang fei To: dts@dpdk.org Cc: wang fei Date: Fri, 22 Dec 2017 20:03:40 +0800 Message-Id: <1513944220-60610-1-git-send-email-feix.y.wang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V1 1/2] add new test suite to support nsh test 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, 22 Dec 2017 09:33:10 -0000 Signed-off-by: wang fei --- tests/TestSuite_nsh.py | 239 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 tests/TestSuite_nsh.py diff --git a/tests/TestSuite_nsh.py b/tests/TestSuite_nsh.py new file mode 100644 index 0000000..b6cae42 --- /dev/null +++ b/tests/TestSuite_nsh.py @@ -0,0 +1,239 @@ +# 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 support of NSH Feature by Poll Mode Drivers. + +""" + +import dts +import utils + + +from test_case import TestCase +from pmd_output import PmdOutput + + + +class TestNsh(TestCase): + def set_up_all(self): + """ + Run at the start of each test suite. + """ + ports = self.dut.get_ports() + # Verify that enough ports are available + self.verify(len(ports) >= 1, "Insufficient ports") + self.dutRxPort = ports[0] + self.portMask = utils.create_mask(ports[:1]) + self.testerTxPort = self.tester.get_local_port(self.dutRxPort) + self.inf = self.tester.get_interface(self.testerTxPort) + def build_test_pmd(self): + self.pmdout = PmdOutput(self.dut) + self.pmdout.start_testpmd("Default", "--portmask=%s" % self.portMask) + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + def scapy_send_packet(self, packet_type): + self.tester.scapy_foreground() + if packet_type == "ether+nsh": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x0,NSP=0x000002,NSI=0xff)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2")], iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip+icmp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2")/ICMP()],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip_frag": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2",frag=1,flags="MF")],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip+tcp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2")/TCP(sport=1024,dport=1025)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip+udp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2")/UDP(sport=1024,dport=1025)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ip+sctp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x1,NSP=0x000002,NSI=0xff)/IP(src="192.168.0.1",\ + dst="192.168.0.2")/SCTP(tag=1)/SCTPChunkData(data=\'X\' * 16)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2003::2")],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6+icmp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2003::2",nh=0x3A)/ICMP()],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6_frag": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2003::2")/IPv6ExtHdrFragment()],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6+tcp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2004::2")/TCP(sport=1024,dport=1025)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6+udp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2003::2")/UDP(sport=1024,dport=1025)],iface="%s")' % self.inf) + elif packet_type == "ether+nsh+ipv6+sctp": + self.tester.scapy_append('sendp([Ether(dst="00:00:00:00:01:00",type=0x894f)/NSH(Len=0x6,NextProto=0x2,NSP=0x000002,NSI=0xff)/IPv6(src="2001::1",\ + dst="2003::2",nh=0x84)/SCTP(tag=1)/SCTPChunkData(data=\'X\' * 16)],iface="%s")' % self.inf) + else: + raise "unknown packet" + self.tester.scapy_execute() + def check_nsh_packet(self, packet_type): + """ + DUT checks received packets type + Must be retrived after function scapy_send_packet() + """ + out = self.dut.get_session_output(timeout=2) + self.logger.info(out) + if packet_type == "ether+nsh": + self.verify("L2_ETHER_NSH" in out, "Ether+NSH Packet not detected") + elif packet_type == "ether+nsh+ip": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_NONFRAG" in out, "Ether+NSH+IP Packet not detected") + elif packet_type == "ether+nsh+ip+icmp": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_ICMP" in out, "Ether+NSH+IP+ICMP Packet not detected") + elif packet_type == "ether+nsh+ip_frag": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_FRAG" in out, "Ether+NSH+IP_Frag Packet not detected") + elif packet_type == "ether+nsh+ip+tcp": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_TCP" in out, "Ether+NSH+IP+TCP Packet not detected") + elif packet_type == "ether+nsh+ip+udp": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_UDP" in out, "Ether+NSH+IP+UDP Packet not detected") + elif packet_type == "ether+nsh+ip+sctp": + self.verify("L2_ETHER_NSH L3_IPV4_EXT_UNKNOWN L4_SCTP" in out, "Ether+NSH+IP+SCTP Packet not detected") + elif packet_type == "ether+nsh+ipv6": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_NONFRAG" in out, "Ether+NSH+IPV6 Packet not detected") + elif packet_type == "ether+nsh+ipv6+icmp": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_ICMP" in out, "Ether+NSH+IPV6+ICMP Packet not detected") + elif packet_type == "ether+nsh+ipv6_frag": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_FRAG" in out, "Ether+NSH+IPV6_FRAG Packet not detected") + elif packet_type == "ether+nsh+ipv6+tcp": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_TCP" in out, "Ether+NSH+IPV6+TCP Packet not detected") + elif packet_type == "ether+nsh+ipv6+udp": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_UDP" in out, "Ether+NSH+IPV6+UDP Packet not detected") + elif packet_type == "ether+nsh+ipv6+sctp": + self.verify("L2_ETHER_NSH L3_IPV6_EXT_UNKNOWN L4_SCTP" in out, "Ether+NSH+IPV6+SCTP Packet not detected") + else: + raise "Unrecognised NSH packet" + def test_nsh_packet_recognition(self): + self.build_test_pmd() + nsh_packet0 = "ether+nsh" + nsh_packet1 = "ether+nsh+ip" + nsh_packet2 = "ether+nsh+ip+icmp" + nsh_packet3 = "ether+nsh+ip_frag" + nsh_packet4 = "ether+nsh+ip+tcp" + nsh_packet5 = "ether+nsh+ip+udp" + nsh_packet6 = "ether+nsh+ip+sctp" + nsh_packet7 = "ether+nsh+ipv6" + nsh_packet8 = "ether+nsh+ipv6+icmp" + nsh_packet9 = "ether+nsh+ipv6_frag" + nsh_packet10 = "ether+nsh+ipv6+tcp" + nsh_packet11 = "ether+nsh+ipv6+udp" + nsh_packet12 = "ether+nsh+ipv6+sctp" + # send ether+nsh packet for recongition + self.scapy_send_packet(nsh_packet0) + self.check_nsh_packet(nsh_packet0) + # send ether+nsh+ip packet for recongition + self.scapy_send_packet(nsh_packet1) + self.check_nsh_packet(nsh_packet1) + # send ether+nsh+ip+icmp packet for recongition + self.scapy_send_packet(nsh_packet2) + self.check_nsh_packet(nsh_packet2) + # send ether+nsh+ip_frag packet for recongition + self.scapy_send_packet(nsh_packet3) + self.check_nsh_packet(nsh_packet3) + # ether+nsh+ip+tcp for recongition + self.scapy_send_packet(nsh_packet4) + self.check_nsh_packet(nsh_packet4) + # ether+nsh+ip+udp for recongition + self.scapy_send_packet(nsh_packet5) + self.check_nsh_packet(nsh_packet5) + # ether+nsh+ip+sctp for recongition + self.scapy_send_packet(nsh_packet6) + self.check_nsh_packet(nsh_packet6) + # ether+nsh+ipv6 for recongition + self.scapy_send_packet(nsh_packet7) + self.check_nsh_packet(nsh_packet7) + # ether+nsh+ipv6+icmp for recongition + self.scapy_send_packet(nsh_packet8) + self.check_nsh_packet(nsh_packet8) + # ether+nsh+ipv6_frag for recongition + self.scapy_send_packet(nsh_packet9) + self.check_nsh_packet(nsh_packet9) + # ether+nsh+ipv6+tcp for recongition + self.scapy_send_packet(nsh_packet10) + self.check_nsh_packet(nsh_packet10) + # ether+nsh+ipv6+udp for recongition + self.scapy_send_packet(nsh_packet11) + self.check_nsh_packet(nsh_packet11) + # ether+nsh+ipv6+sctp for recongition + self.scapy_send_packet(nsh_packet12) + self.check_nsh_packet(nsh_packet12) + 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.7.4