[dts] [PATCH] TX preparation test suite

Liu, Yong yong.liu at intel.com
Thu May 4 05:23:33 CEST 2017


Thanks, applied.

> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Xueqin Lin
> Sent: Thursday, February 23, 2017 9:56 AM
> To: dts at dpdk.org
> Cc: Lin, Xueqin <xueqin.lin at intel.com>
> Subject: [dts] [PATCH] TX preparation test suite
> 
> ---
>  tests/TestSuite_tx_preparation.py | 172
> ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 172 insertions(+)
>  create mode 100644 tests/TestSuite_tx_preparation.py
> 
> diff --git a/tests/TestSuite_tx_preparation.py
> b/tests/TestSuite_tx_preparation.py
> new file mode 100644
> index 0000000..3ea42d5
> --- /dev/null
> +++ b/tests/TestSuite_tx_preparation.py
> @@ -0,0 +1,172 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2017 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 tx preparation feature
> +
> +"""
> +
> +import os
> +import time
> +import dut
> +from config import PortConf
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +from settings import FOLDERS
> +from packet import Packet
> +#
> +#
> +# Test class.
> +#
> +
> +
> +class TestTX_preparation(TestCase):
> +    #
> +    # Test cases.
> +    #
> +
> +    def set_up_all(self):
> +        """
> +        Run at the start of each test suite.
> +        """
> +        self.ports = self.dut.get_ports(self.nic)
> +        self.verify(len(self.ports) >= 1, "Insufficient number of ports.")
> +        self.used_dut_port = self.ports[0]
> +        tester_port = self.tester.get_local_port(self.used_dut_port)
> +        self.tester_intf = self.tester.get_interface(tester_port)
> +        self.tester.send_expect("ethtool -K %s rx off tx off tso off gso\
> +            off gro off lro off" %self.tester_intf, "#")
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        self.dut_testpmd = PmdOutput(self.dut)
> +        self.dut_testpmd.start_testpmd("Default", "--port-
> topology=chained")
> +        self.dmac = self.dut_testpmd.get_port_mac(0)
> +        self.dut_testpmd.execute_cmd('set fwd csum')
> +        self.dut_testpmd.execute_cmd('set verbose 1')
> +
> +    def start_tcpdump(self, rxItf):
> +
> +        self.tester.send_expect("rm -rf ./getPackageByTcpdump.cap", "#")
> +        self.tester.send_expect("tcpdump -Q in -i %s -n -e -vv -w\
> +            ./getPackageByTcpdump.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 ./getPackageByTcpdump.cap", "#")
> +
> +    def send_packet_verify(self, tsoflag = 0):
> +        """
> +        Send packet to portid and output
> +        """
> +        pkts = {'IPv4/cksum TCP': 'Ether(dst="%s")/IP()/TCP(flags=0x10)\
> +                    /Raw(RandString(50))' % self.dmac,
> +                'IPv4/bad IP cksum': 'Ether(dst="%s")/IP(chksum=0x1234)\
> +                    /TCP(flags=0x10)/Raw(RandString(50))' %self.dmac,
> +                'IPv4/bad TCP cksum':
> 'Ether(dst="%s")/IP()/TCP(flags=0x10,\
> +                    chksum=0x1234)/Raw(RandString(50))' %self.dmac,
> +                'IPv4/large pkt': 'Ether(dst="%s")/IP()/TCP(flags=0x10)\
> +                    /Raw(RandString(1400))' %self.dmac,
> +                'IPv4/bad cksum/large pkt':
> 'Ether(dst="%s")/IP(chksum=0x1234)\
> +                    /TCP(flags=0x10,chksum=0x1234)/Raw(RandString(1400))'
> +                    %self.dmac,
> +                'IPv6/cksum TCP':
> 'Ether(dst="%s")/IPv6()/TCP(flags=0x10)\
> +                    /Raw(RandString(50))' %self.dmac,
> +                'IPv6/cksum UDP': 'Ether(dst="%s")/IPv6()/UDP()\
> +                    /Raw(RandString(50))' %self.dmac,
> +                'IPv6/bad TCP cksum':
> 'Ether(dst="%s")/IPv6()/TCP(flags=0x10,\
> +                    chksum=0x1234)/Raw(RandString(50))' %self.dmac,
> +                'IPv6/large pkt':
> 'Ether(dst="%s")/IPv6()/TCP(flags=0x10)\
> +                    /Raw(RandString(1400))' %self.dmac }
> +
> +        for packet_type in pkts.keys():
> +            self.start_tcpdump(self.tester_intf)
> +            self.tester.scapy_append(
> +                'sendp([%s], iface="%s")' % (pkts[packet_type],
> self.tester_intf))
> +            self.tester.scapy_execute()
> +            out = self.get_tcpdump_package()
> +            if packet_type == 'IPv6/cksum UDP':
> +                self.verify("udp sum ok" in out,
> +                    "Failed to check UDP checksum correctness!!!")
> +            else :
> +                self.verify("cksum" in out, "Failed to check IP/TCP
> checksum!!!")
> +                self.verify("correct" in out and "incorrect" not in out,
> +                    "Failed to check IP/TCP/UDP checksum correctness!!!")
> +
> +            if tsoflag == 1:
> +                 if packet_type in\
> +                    ['IPv4/large pkt', 'IPv6/large pkt', 'IPv4/bad
> cksum/large pkt']:
> +                    self.verify("length 800" in out and "length 600" in
> out,
> +                        "Failed to verify TSO correctness for large
> packets!!!")
> +
> +
> +    def test_tx_preparation_NonTSO(self):
> +        """
> +        ftag functional test
> +        """
> +        self.dut_testpmd.execute_cmd('tso set 0 0')
> +        self.dut_testpmd.execute_cmd('start')
> +
> +        self.send_packet_verify()
> +        self.dut_testpmd.execute_cmd('stop')
> +        self.dut_testpmd.quit()
> +
> +    def test_tx_preparation_TSO(self):
> +        """
> +        ftag functional test
> +        """
> +        self.dut_testpmd.execute_cmd('tso set 800 0')
> +        self.dut_testpmd.execute_cmd('start')
> +
> +        self.send_packet_verify(1)
> +        self.dut_testpmd.execute_cmd('stop')
> +        self.dut_testpmd.quit()
> +
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        pass
> +
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """
> +        self.dut.kill_all()
> --
> 2.5.5



More information about the dts mailing list