test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
@ 2015-09-22  7:23 haifeng
  2015-09-22  7:23 ` [dts] [PATCH 2/2] add TestSuite_pmdpcap rst " haifeng
  2015-09-23  2:29 ` [dts] [PATCH 1/2] add TestSuite_pmdpcap " Liu, Yong
  0 siblings, 2 replies; 5+ messages in thread
From: haifeng @ 2015-09-22  7:23 UTC (permalink / raw)
  To: dts

Signed-off-by: haifeng <haifengx.tang@intel.com>
---
 tests/TestSuite_pmdpcap.py | 186 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 186 insertions(+)
 create mode 100644 tests/TestSuite_pmdpcap.py

diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py
new file mode 100644
index 0000000..41e2cfe
--- /dev/null
+++ b/tests/TestSuite_pmdpcap.py
@@ -0,0 +1,186 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 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.
+
+'''
+'''
+from test_case import TestCase
+import dts
+
+from time import sleep
+from scapy.all import *
+
+
+#
+#
+# Test class.
+#
+class TestPmdPcap(TestCase):
+
+    pcap_file_sizes = [1000, 500]
+    dut_pcap_files_path = '/root/'
+
+    def set_up_all(self):
+        self.check_scapy_in_dut()
+
+        self.memory_channel = self.dut.get_memory_channels()
+
+        # Enable PCAP features and rebuild the package
+        self.pcap_config = self.get_pcap_compile_config()
+        self.dut.send_expect(
+            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=n$/CONFIG_RTE_LIBRTE_PMD_PCAP=y/' config/%s" % self.pcap_config, "# ")
+        self.dut.build_install_dpdk(self.target)
+
+        # make sure there is no interface to bind
+        # because if there is any interface bonded to igb_uio,
+        # it will result in packet transmiting failed
+        self.dut.restore_interfaces()
+
+    def get_pcap_compile_config(self):
+        config_head = "common_"
+        os_type = self.dut.get_os_type()
+        if os_type == "linux":
+            config_tail = os_type + "app"
+        elif os_type == "freebsd":
+            config_tail = "bsdapp"
+        else:
+            raise Exception(
+                "Unknow os type, please check to make sure pcap can work in OS [ %s ]" % os_type)
+
+        return config_head + config_tail
+
+    def create_pcap_file(self, filename, number_of_packets):
+        flow = []
+        for pkt_id in range(number_of_packets):
+            pkt_id = str(hex(pkt_id % 256))
+            flow.append(Ether(src='00:00:00:00:00:%s' % pkt_id[2:], dst='00:00:00:00:00:00') / IP(
+                src='192.168.1.1', dst='192.168.1.2') / ("X" * 26))
+
+        wrpcap(filename, flow)
+
+    def check_scapy_in_dut(self):
+        try:
+            self.dut.send_expect('scapy', '>>> ')
+            self.dut.send_expect('quit()', '# ')
+        except:
+            self.verify(False, 'Scapy is required in dut.')
+
+    def check_pcap_files(self, in_pcap, out_pcap, expected_frames):
+
+        # Check if the number of expected frames are in the output
+        result = self.dut.send_expect(
+            'tcpdump -n -e -r %s | wc -l' % out_pcap, '# ')
+        self.verify(str(expected_frames) in result,
+                    'Not all packets have been forwarded')
+
+        # Check if the frames in the input and output files match
+        self.dut.send_expect('scapy', '>>> ')
+        self.dut.send_expect('input=rdpcap("%s")' % in_pcap, '>>> ')
+        self.dut.send_expect('output=rdpcap("%s")' % out_pcap, '>>> ')
+        self.dut.send_expect(
+            'result=[input[i]==output[i] for i in xrange(len(input))]', '>>> ')
+        result = self.dut.send_expect('False in result', '>>> ')
+        self.dut.send_expect('quit()', '# ')
+
+        self.verify('True' not in result, 'In/Out packets do not match.')
+
+    def test_send_packets_with_one_device(self):
+        in_pcap = 'in_pmdpcap.pcap'
+        out_pcap = '/tmp/out_pmdpcap.pcap'
+
+        two_cores = self.dut.get_core_list("1S/2C/1T")
+        core_mask = dts.create_mask(two_cores)
+
+        self.create_pcap_file(in_pcap, TestPmdPcap.pcap_file_sizes[0])
+        self.dut.session.copy_file_to(in_pcap)
+
+        command = ("./{}/app/testpmd -c {} -n {} " +
+                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
+                   "-- -i --port-topology=chained")
+
+        self.dut.send_expect(command.format(self.target, core_mask,
+                             self.memory_channel,
+                             TestPmdPcap.dut_pcap_files_path + in_pcap,
+                             out_pcap), 'testpmd> ', 15)
+
+        self.dut.send_expect('start', 'testpmd> ')
+        sleep(2)
+        self.dut.send_expect('stop', 'testpmd> ')
+        self.dut.send_expect('quit', '# ')
+
+        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap,
+                              out_pcap, TestPmdPcap.pcap_file_sizes[0])
+
+    def test_send_packets_with_two_devices(self):
+
+        in_pcap1 = 'in1_pmdpcap.pcap'
+        out_pcap1 = '/tmp/out1_pmdpcap.pcap'
+
+        in_pcap2 = 'in2_pmdpcap.pcap'
+        out_pcap2 = '/tmp/out2_pmdpcap.pcap'
+
+        four_cores = self.dut.get_core_list("1S/4C/1T")
+        core_mask = dts.create_mask(four_cores)
+
+        self.create_pcap_file(in_pcap1, TestPmdPcap.pcap_file_sizes[0])
+        self.dut.session.copy_file_to(in_pcap1)
+        self.create_pcap_file(in_pcap2, TestPmdPcap.pcap_file_sizes[1])
+        self.dut.session.copy_file_to(in_pcap2)
+
+        command = ("./{}/app/testpmd -c {} -n {} " +
+                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
+                   "--vdev=eth_pcap1,rx_pcap={},tx_pcap={} " +
+                   "-- -i")
+
+        self.dut.send_expect(command.format(self.target, core_mask,
+                                            self.memory_channel,
+                                            TestPmdPcap.dut_pcap_files_path +
+                                            in_pcap1,
+                                            out_pcap1,
+                                            TestPmdPcap.dut_pcap_files_path +
+                                            in_pcap2,
+                                            out_pcap2), 'testpmd> ', 10)
+
+        self.dut.send_expect('start', 'testpmd> ')
+        sleep(2)
+        self.dut.send_expect('stop', 'testpmd> ')
+        self.dut.send_expect('quit', '# ')
+
+        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap1,
+                              out_pcap2, TestPmdPcap.pcap_file_sizes[0])
+
+        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap2,
+                              out_pcap1, TestPmdPcap.pcap_file_sizes[1])
+
+    def tear_down_all(self):
+        # Disable PCAP feature and rebuild the package
+        self.dut.send_expect(
+            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=y$/CONFIG_RTE_LIBRTE_PMD_PCAP=n/' config/%s" % self.pcap_config, "# ")
+        self.dut.set_target(self.target)
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH 2/2] add TestSuite_pmdpcap  rst into dts
  2015-09-22  7:23 [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts haifeng
@ 2015-09-22  7:23 ` haifeng
  2015-09-23  2:29 ` [dts] [PATCH 1/2] add TestSuite_pmdpcap " Liu, Yong
  1 sibling, 0 replies; 5+ messages in thread
From: haifeng @ 2015-09-22  7:23 UTC (permalink / raw)
  To: dts

Signed-off-by: haifeng <haifengx.tang@intel.com>
---
 test_plans/pmdpcap_test_plan.rst | 100 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100644 test_plans/pmdpcap_test_plan.rst

diff --git a/test_plans/pmdpcap_test_plan.rst b/test_plans/pmdpcap_test_plan.rst
new file mode 100644
index 0000000..d1434af
--- /dev/null
+++ b/test_plans/pmdpcap_test_plan.rst
@@ -0,0 +1,100 @@
+.. Copyright (c) <2010, 2011>, Intel Corporation
+   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.
+
+=========================
+Tespt PMD PCAP files test
+=========================
+
+This document provides tests for the userland Intel(R)
+82599 Gigabit Ethernet Controller (Niantic) Poll Mode Driver (PMD) when using
+pcap files as input and output.
+
+The core configurations description is:
+
+- 2C/1T: 2 Physical Cores, 1 Logical Core per physical core
+- 4C/1T: 4 Physical Cores, 1 Logical Core per physical core
+
+Prerequisites
+=============
+
+This test does not requires connections between DUT and tester as it is focused
+in PCAP devices created by Test PMD.
+
+It is Test PMD application itself which send and receibes traffic from and to
+PCAP files, no traffic generator is involved.
+
+
+Test Case: test_send_packets_with_one_device
+============================================
+
+It is necessary to generate the input pcap file for one interface test. The
+pcap file can be created using scapy. Create a file with 1000 frames with the 
+following structure::
+
+  Ether(src='00:00:00:00:00:<last Eth>', dst='00:00:00:00:00:00')/IP(src='192.168.1.1', dst='192.168.1.2')/("X"*26))
+
+<last Eth> goes from 0 to 255 and repeats.
+
+The linuxapp is started with the following parameters:
+
+::
+
+  -c 0xffffff -n 3 --vdev 'eth_pcap0;rx_pcap=in.pcap;tx_pcap=out.pcap' --
+  -i --port-topology=chained
+
+
+Start the application and the forwarding, by typing `start` in the command line 
+of the application. After a few seconds `stop` the forwarding and `quit` the 
+application.
+
+Check that the frames of in.pcap and out.pcap files are the same using scapy.
+
+Test Case: test_send_packets_with_two_devices
+=============================================
+
+Create 2 pcap files with 1000 and 500 frames as explained in 
+`test_send_packets_with_one_device` test case. 
+
+The linuxapp is started with the following parameters:
+
+::
+
+  -c 0xffffff -n 3 --vdev 'eth_pcap0;rx_pcap=in1.pcap;tx_pcap=out1.pcap,"eth_pcap1;rx_pcap=in2.pcap;tx_pcap=out2.pcap'
+  -- -i
+
+
+Start the application and the forwarding, by typing `start` in the command line 
+of the application. After a few seconds `stop` the forwarding and `quit` the 
+application.
+
+Check that the frames of the in1.pcap and out2.pcap, and in2.pcap and out1.pcap
+file are the same using scapy.
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
  2015-09-22  7:23 [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts haifeng
  2015-09-22  7:23 ` [dts] [PATCH 2/2] add TestSuite_pmdpcap rst " haifeng
@ 2015-09-23  2:29 ` Liu, Yong
  2015-09-24  2:46   ` Tang, HaifengX
  1 sibling, 1 reply; 5+ messages in thread
From: Liu, Yong @ 2015-09-23  2:29 UTC (permalink / raw)
  To: haifeng, dts

Haifeng,
Please add this case into default execution file.

On 09/22/2015 03:23 PM, haifeng wrote:
> Signed-off-by: haifeng <haifengx.tang@intel.com>
> ---
>   tests/TestSuite_pmdpcap.py | 186 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 186 insertions(+)
>   create mode 100644 tests/TestSuite_pmdpcap.py
>
> diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py
> new file mode 100644
> index 0000000..41e2cfe
> --- /dev/null
> +++ b/tests/TestSuite_pmdpcap.py
> @@ -0,0 +1,186 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2014 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.
> +
> +'''
> +'''
> +from test_case import TestCase
> +import dts
> +
> +from time import sleep
> +from scapy.all import *
> +
> +
> +#
> +#
> +# Test class.
> +#
> +class TestPmdPcap(TestCase):
> +
> +    pcap_file_sizes = [1000, 500]
> +    dut_pcap_files_path = '/root/'
> +
> +    def set_up_all(self):
> +        self.check_scapy_in_dut()
> +
> +        self.memory_channel = self.dut.get_memory_channels()
> +
> +        # Enable PCAP features and rebuild the package
> +        self.pcap_config = self.get_pcap_compile_config()
> +        self.dut.send_expect(
> +            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=n$/CONFIG_RTE_LIBRTE_PMD_PCAP=y/' config/%s" % self.pcap_config, "# ")
> +        self.dut.build_install_dpdk(self.target)
> +
> +        # make sure there is no interface to bind
> +        # because if there is any interface bonded to igb_uio,
> +        # it will result in packet transmiting failed
> +        self.dut.restore_interfaces()
> +
> +    def get_pcap_compile_config(self):
> +        config_head = "common_"
> +        os_type = self.dut.get_os_type()
> +        if os_type == "linux":
> +            config_tail = os_type + "app"
> +        elif os_type == "freebsd":
> +            config_tail = "bsdapp"
> +        else:
> +            raise Exception(
> +                "Unknow os type, please check to make sure pcap can work in OS [ %s ]" % os_type)
> +
> +        return config_head + config_tail
> +
> +    def create_pcap_file(self, filename, number_of_packets):
> +        flow = []
> +        for pkt_id in range(number_of_packets):
> +            pkt_id = str(hex(pkt_id % 256))
> +            flow.append(Ether(src='00:00:00:00:00:%s' % pkt_id[2:], dst='00:00:00:00:00:00') / IP(
> +                src='192.168.1.1', dst='192.168.1.2') / ("X" * 26))
> +
> +        wrpcap(filename, flow)
> +
> +    def check_scapy_in_dut(self):
> +        try:
> +            self.dut.send_expect('scapy', '>>> ')
> +            self.dut.send_expect('quit()', '# ')
> +        except:
> +            self.verify(False, 'Scapy is required in dut.')
> +
> +    def check_pcap_files(self, in_pcap, out_pcap, expected_frames):
> +
> +        # Check if the number of expected frames are in the output
> +        result = self.dut.send_expect(
> +            'tcpdump -n -e -r %s | wc -l' % out_pcap, '# ')
> +        self.verify(str(expected_frames) in result,
> +                    'Not all packets have been forwarded')
> +
> +        # Check if the frames in the input and output files match
> +        self.dut.send_expect('scapy', '>>> ')
> +        self.dut.send_expect('input=rdpcap("%s")' % in_pcap, '>>> ')
> +        self.dut.send_expect('output=rdpcap("%s")' % out_pcap, '>>> ')
> +        self.dut.send_expect(
> +            'result=[input[i]==output[i] for i in xrange(len(input))]', '>>> ')
> +        result = self.dut.send_expect('False in result', '>>> ')
> +        self.dut.send_expect('quit()', '# ')
> +
> +        self.verify('True' not in result, 'In/Out packets do not match.')
> +
> +    def test_send_packets_with_one_device(self):
> +        in_pcap = 'in_pmdpcap.pcap'
> +        out_pcap = '/tmp/out_pmdpcap.pcap'
> +
> +        two_cores = self.dut.get_core_list("1S/2C/1T")
> +        core_mask = dts.create_mask(two_cores)
> +
> +        self.create_pcap_file(in_pcap, TestPmdPcap.pcap_file_sizes[0])
> +        self.dut.session.copy_file_to(in_pcap)
> +
> +        command = ("./{}/app/testpmd -c {} -n {} " +
> +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> +                   "-- -i --port-topology=chained")
> +
> +        self.dut.send_expect(command.format(self.target, core_mask,
> +                             self.memory_channel,
> +                             TestPmdPcap.dut_pcap_files_path + in_pcap,
> +                             out_pcap), 'testpmd> ', 15)
> +
> +        self.dut.send_expect('start', 'testpmd> ')
> +        sleep(2)
> +        self.dut.send_expect('stop', 'testpmd> ')
> +        self.dut.send_expect('quit', '# ')
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap,
> +                              out_pcap, TestPmdPcap.pcap_file_sizes[0])
> +
> +    def test_send_packets_with_two_devices(self):
> +
> +        in_pcap1 = 'in1_pmdpcap.pcap'
> +        out_pcap1 = '/tmp/out1_pmdpcap.pcap'
> +
> +        in_pcap2 = 'in2_pmdpcap.pcap'
> +        out_pcap2 = '/tmp/out2_pmdpcap.pcap'
> +
> +        four_cores = self.dut.get_core_list("1S/4C/1T")
> +        core_mask = dts.create_mask(four_cores)
> +
> +        self.create_pcap_file(in_pcap1, TestPmdPcap.pcap_file_sizes[0])
> +        self.dut.session.copy_file_to(in_pcap1)
> +        self.create_pcap_file(in_pcap2, TestPmdPcap.pcap_file_sizes[1])
> +        self.dut.session.copy_file_to(in_pcap2)
> +
> +        command = ("./{}/app/testpmd -c {} -n {} " +
> +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> +                   "--vdev=eth_pcap1,rx_pcap={},tx_pcap={} " +
> +                   "-- -i")
> +
> +        self.dut.send_expect(command.format(self.target, core_mask,
> +                                            self.memory_channel,
> +                                            TestPmdPcap.dut_pcap_files_path +
> +                                            in_pcap1,
> +                                            out_pcap1,
> +                                            TestPmdPcap.dut_pcap_files_path +
> +                                            in_pcap2,
> +                                            out_pcap2), 'testpmd> ', 10)
> +
> +        self.dut.send_expect('start', 'testpmd> ')
> +        sleep(2)
> +        self.dut.send_expect('stop', 'testpmd> ')
> +        self.dut.send_expect('quit', '# ')
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap1,
> +                              out_pcap2, TestPmdPcap.pcap_file_sizes[0])
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap2,
> +                              out_pcap1, TestPmdPcap.pcap_file_sizes[1])
> +
> +    def tear_down_all(self):
> +        # Disable PCAP feature and rebuild the package
> +        self.dut.send_expect(
> +            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=y$/CONFIG_RTE_LIBRTE_PMD_PCAP=n/' config/%s" % self.pcap_config, "# ")
> +        self.dut.set_target(self.target)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
  2015-09-23  2:29 ` [dts] [PATCH 1/2] add TestSuite_pmdpcap " Liu, Yong
@ 2015-09-24  2:46   ` Tang, HaifengX
  2015-09-24  2:46     ` Liu, Yong
  0 siblings, 1 reply; 5+ messages in thread
From: Tang, HaifengX @ 2015-09-24  2:46 UTC (permalink / raw)
  To: Liu, Yong, dts


Hi yong :

You can merge the patch first. I will submit another patch to add the suite into cfg file .


thanks
-----Original Message-----
From: Liu, Yong 
Sent: Wednesday, September 23, 2015 10:30 AM
To: Tang, HaifengX; dts@dpdk.org
Subject: Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts

Haifeng,
Please add this case into default execution file.

On 09/22/2015 03:23 PM, haifeng wrote:
> Signed-off-by: haifeng <haifengx.tang@intel.com>
> ---
>   tests/TestSuite_pmdpcap.py | 186 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 186 insertions(+)
>   create mode 100644 tests/TestSuite_pmdpcap.py
>
> diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py 
> new file mode 100644 index 0000000..41e2cfe
> --- /dev/null
> +++ b/tests/TestSuite_pmdpcap.py
> @@ -0,0 +1,186 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2014 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.
> +
> +'''
> +'''
> +from test_case import TestCase
> +import dts
> +
> +from time import sleep
> +from scapy.all import *
> +
> +
> +#
> +#
> +# Test class.
> +#
> +class TestPmdPcap(TestCase):
> +
> +    pcap_file_sizes = [1000, 500]
> +    dut_pcap_files_path = '/root/'
> +
> +    def set_up_all(self):
> +        self.check_scapy_in_dut()
> +
> +        self.memory_channel = self.dut.get_memory_channels()
> +
> +        # Enable PCAP features and rebuild the package
> +        self.pcap_config = self.get_pcap_compile_config()
> +        self.dut.send_expect(
> +            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=n$/CONFIG_RTE_LIBRTE_PMD_PCAP=y/' config/%s" % self.pcap_config, "# ")
> +        self.dut.build_install_dpdk(self.target)
> +
> +        # make sure there is no interface to bind
> +        # because if there is any interface bonded to igb_uio,
> +        # it will result in packet transmiting failed
> +        self.dut.restore_interfaces()
> +
> +    def get_pcap_compile_config(self):
> +        config_head = "common_"
> +        os_type = self.dut.get_os_type()
> +        if os_type == "linux":
> +            config_tail = os_type + "app"
> +        elif os_type == "freebsd":
> +            config_tail = "bsdapp"
> +        else:
> +            raise Exception(
> +                "Unknow os type, please check to make sure pcap can 
> + work in OS [ %s ]" % os_type)
> +
> +        return config_head + config_tail
> +
> +    def create_pcap_file(self, filename, number_of_packets):
> +        flow = []
> +        for pkt_id in range(number_of_packets):
> +            pkt_id = str(hex(pkt_id % 256))
> +            flow.append(Ether(src='00:00:00:00:00:%s' % pkt_id[2:], dst='00:00:00:00:00:00') / IP(
> +                src='192.168.1.1', dst='192.168.1.2') / ("X" * 26))
> +
> +        wrpcap(filename, flow)
> +
> +    def check_scapy_in_dut(self):
> +        try:
> +            self.dut.send_expect('scapy', '>>> ')
> +            self.dut.send_expect('quit()', '# ')
> +        except:
> +            self.verify(False, 'Scapy is required in dut.')
> +
> +    def check_pcap_files(self, in_pcap, out_pcap, expected_frames):
> +
> +        # Check if the number of expected frames are in the output
> +        result = self.dut.send_expect(
> +            'tcpdump -n -e -r %s | wc -l' % out_pcap, '# ')
> +        self.verify(str(expected_frames) in result,
> +                    'Not all packets have been forwarded')
> +
> +        # Check if the frames in the input and output files match
> +        self.dut.send_expect('scapy', '>>> ')
> +        self.dut.send_expect('input=rdpcap("%s")' % in_pcap, '>>> ')
> +        self.dut.send_expect('output=rdpcap("%s")' % out_pcap, '>>> ')
> +        self.dut.send_expect(
> +            'result=[input[i]==output[i] for i in xrange(len(input))]', '>>> ')
> +        result = self.dut.send_expect('False in result', '>>> ')
> +        self.dut.send_expect('quit()', '# ')
> +
> +        self.verify('True' not in result, 'In/Out packets do not 
> + match.')
> +
> +    def test_send_packets_with_one_device(self):
> +        in_pcap = 'in_pmdpcap.pcap'
> +        out_pcap = '/tmp/out_pmdpcap.pcap'
> +
> +        two_cores = self.dut.get_core_list("1S/2C/1T")
> +        core_mask = dts.create_mask(two_cores)
> +
> +        self.create_pcap_file(in_pcap, TestPmdPcap.pcap_file_sizes[0])
> +        self.dut.session.copy_file_to(in_pcap)
> +
> +        command = ("./{}/app/testpmd -c {} -n {} " +
> +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> +                   "-- -i --port-topology=chained")
> +
> +        self.dut.send_expect(command.format(self.target, core_mask,
> +                             self.memory_channel,
> +                             TestPmdPcap.dut_pcap_files_path + in_pcap,
> +                             out_pcap), 'testpmd> ', 15)
> +
> +        self.dut.send_expect('start', 'testpmd> ')
> +        sleep(2)
> +        self.dut.send_expect('stop', 'testpmd> ')
> +        self.dut.send_expect('quit', '# ')
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap,
> +                              out_pcap, 
> + TestPmdPcap.pcap_file_sizes[0])
> +
> +    def test_send_packets_with_two_devices(self):
> +
> +        in_pcap1 = 'in1_pmdpcap.pcap'
> +        out_pcap1 = '/tmp/out1_pmdpcap.pcap'
> +
> +        in_pcap2 = 'in2_pmdpcap.pcap'
> +        out_pcap2 = '/tmp/out2_pmdpcap.pcap'
> +
> +        four_cores = self.dut.get_core_list("1S/4C/1T")
> +        core_mask = dts.create_mask(four_cores)
> +
> +        self.create_pcap_file(in_pcap1, TestPmdPcap.pcap_file_sizes[0])
> +        self.dut.session.copy_file_to(in_pcap1)
> +        self.create_pcap_file(in_pcap2, TestPmdPcap.pcap_file_sizes[1])
> +        self.dut.session.copy_file_to(in_pcap2)
> +
> +        command = ("./{}/app/testpmd -c {} -n {} " +
> +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> +                   "--vdev=eth_pcap1,rx_pcap={},tx_pcap={} " +
> +                   "-- -i")
> +
> +        self.dut.send_expect(command.format(self.target, core_mask,
> +                                            self.memory_channel,
> +                                            TestPmdPcap.dut_pcap_files_path +
> +                                            in_pcap1,
> +                                            out_pcap1,
> +                                            TestPmdPcap.dut_pcap_files_path +
> +                                            in_pcap2,
> +                                            out_pcap2), 'testpmd> ', 
> + 10)
> +
> +        self.dut.send_expect('start', 'testpmd> ')
> +        sleep(2)
> +        self.dut.send_expect('stop', 'testpmd> ')
> +        self.dut.send_expect('quit', '# ')
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap1,
> +                              out_pcap2, 
> + TestPmdPcap.pcap_file_sizes[0])
> +
> +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap2,
> +                              out_pcap1, 
> + TestPmdPcap.pcap_file_sizes[1])
> +
> +    def tear_down_all(self):
> +        # Disable PCAP feature and rebuild the package
> +        self.dut.send_expect(
> +            "sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=y$/CONFIG_RTE_LIBRTE_PMD_PCAP=n/' config/%s" % self.pcap_config, "# ")
> +        self.dut.set_target(self.target)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
  2015-09-24  2:46   ` Tang, HaifengX
@ 2015-09-24  2:46     ` Liu, Yong
  0 siblings, 0 replies; 5+ messages in thread
From: Liu, Yong @ 2015-09-24  2:46 UTC (permalink / raw)
  To: Tang, HaifengX, dts

Ok, please do not forget it.

> -----Original Message-----
> From: Tang, HaifengX
> Sent: Thursday, September 24, 2015 10:46 AM
> To: Liu, Yong; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
> 
> 
> Hi yong :
> 
> You can merge the patch first. I will submit another patch to add the
> suite into cfg file .
> 
> 
> thanks
> -----Original Message-----
> From: Liu, Yong
> Sent: Wednesday, September 23, 2015 10:30 AM
> To: Tang, HaifengX; dts@dpdk.org
> Subject: Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts
> 
> Haifeng,
> Please add this case into default execution file.
> 
> On 09/22/2015 03:23 PM, haifeng wrote:
> > Signed-off-by: haifeng <haifengx.tang@intel.com>
> > ---
> >   tests/TestSuite_pmdpcap.py | 186
> +++++++++++++++++++++++++++++++++++++++++++++
> >   1 file changed, 186 insertions(+)
> >   create mode 100644 tests/TestSuite_pmdpcap.py
> >
> > diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py
> > new file mode 100644 index 0000000..41e2cfe
> > --- /dev/null
> > +++ b/tests/TestSuite_pmdpcap.py
> > @@ -0,0 +1,186 @@
> > +# BSD LICENSE
> > +#
> > +# Copyright(c) 2010-2014 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.
> > +
> > +'''
> > +'''
> > +from test_case import TestCase
> > +import dts
> > +
> > +from time import sleep
> > +from scapy.all import *
> > +
> > +
> > +#
> > +#
> > +# Test class.
> > +#
> > +class TestPmdPcap(TestCase):
> > +
> > +    pcap_file_sizes = [1000, 500]
> > +    dut_pcap_files_path = '/root/'
> > +
> > +    def set_up_all(self):
> > +        self.check_scapy_in_dut()
> > +
> > +        self.memory_channel = self.dut.get_memory_channels()
> > +
> > +        # Enable PCAP features and rebuild the package
> > +        self.pcap_config = self.get_pcap_compile_config()
> > +        self.dut.send_expect(
> > +            "sed -i
> 's/CONFIG_RTE_LIBRTE_PMD_PCAP=n$/CONFIG_RTE_LIBRTE_PMD_PCAP=y/'
> config/%s" % self.pcap_config, "# ")
> > +        self.dut.build_install_dpdk(self.target)
> > +
> > +        # make sure there is no interface to bind
> > +        # because if there is any interface bonded to igb_uio,
> > +        # it will result in packet transmiting failed
> > +        self.dut.restore_interfaces()
> > +
> > +    def get_pcap_compile_config(self):
> > +        config_head = "common_"
> > +        os_type = self.dut.get_os_type()
> > +        if os_type == "linux":
> > +            config_tail = os_type + "app"
> > +        elif os_type == "freebsd":
> > +            config_tail = "bsdapp"
> > +        else:
> > +            raise Exception(
> > +                "Unknow os type, please check to make sure pcap can
> > + work in OS [ %s ]" % os_type)
> > +
> > +        return config_head + config_tail
> > +
> > +    def create_pcap_file(self, filename, number_of_packets):
> > +        flow = []
> > +        for pkt_id in range(number_of_packets):
> > +            pkt_id = str(hex(pkt_id % 256))
> > +            flow.append(Ether(src='00:00:00:00:00:%s' % pkt_id[2:],
> dst='00:00:00:00:00:00') / IP(
> > +                src='192.168.1.1', dst='192.168.1.2') / ("X" * 26))
> > +
> > +        wrpcap(filename, flow)
> > +
> > +    def check_scapy_in_dut(self):
> > +        try:
> > +            self.dut.send_expect('scapy', '>>> ')
> > +            self.dut.send_expect('quit()', '# ')
> > +        except:
> > +            self.verify(False, 'Scapy is required in dut.')
> > +
> > +    def check_pcap_files(self, in_pcap, out_pcap, expected_frames):
> > +
> > +        # Check if the number of expected frames are in the output
> > +        result = self.dut.send_expect(
> > +            'tcpdump -n -e -r %s | wc -l' % out_pcap, '# ')
> > +        self.verify(str(expected_frames) in result,
> > +                    'Not all packets have been forwarded')
> > +
> > +        # Check if the frames in the input and output files match
> > +        self.dut.send_expect('scapy', '>>> ')
> > +        self.dut.send_expect('input=rdpcap("%s")' % in_pcap, '>>> ')
> > +        self.dut.send_expect('output=rdpcap("%s")' % out_pcap, '>>> ')
> > +        self.dut.send_expect(
> > +            'result=[input[i]==output[i] for i in xrange(len(input))]',
> '>>> ')
> > +        result = self.dut.send_expect('False in result', '>>> ')
> > +        self.dut.send_expect('quit()', '# ')
> > +
> > +        self.verify('True' not in result, 'In/Out packets do not
> > + match.')
> > +
> > +    def test_send_packets_with_one_device(self):
> > +        in_pcap = 'in_pmdpcap.pcap'
> > +        out_pcap = '/tmp/out_pmdpcap.pcap'
> > +
> > +        two_cores = self.dut.get_core_list("1S/2C/1T")
> > +        core_mask = dts.create_mask(two_cores)
> > +
> > +        self.create_pcap_file(in_pcap, TestPmdPcap.pcap_file_sizes[0])
> > +        self.dut.session.copy_file_to(in_pcap)
> > +
> > +        command = ("./{}/app/testpmd -c {} -n {} " +
> > +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> > +                   "-- -i --port-topology=chained")
> > +
> > +        self.dut.send_expect(command.format(self.target, core_mask,
> > +                             self.memory_channel,
> > +                             TestPmdPcap.dut_pcap_files_path + in_pcap,
> > +                             out_pcap), 'testpmd> ', 15)
> > +
> > +        self.dut.send_expect('start', 'testpmd> ')
> > +        sleep(2)
> > +        self.dut.send_expect('stop', 'testpmd> ')
> > +        self.dut.send_expect('quit', '# ')
> > +
> > +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pcap,
> > +                              out_pcap,
> > + TestPmdPcap.pcap_file_sizes[0])
> > +
> > +    def test_send_packets_with_two_devices(self):
> > +
> > +        in_pcap1 = 'in1_pmdpcap.pcap'
> > +        out_pcap1 = '/tmp/out1_pmdpcap.pcap'
> > +
> > +        in_pcap2 = 'in2_pmdpcap.pcap'
> > +        out_pcap2 = '/tmp/out2_pmdpcap.pcap'
> > +
> > +        four_cores = self.dut.get_core_list("1S/4C/1T")
> > +        core_mask = dts.create_mask(four_cores)
> > +
> > +        self.create_pcap_file(in_pcap1, TestPmdPcap.pcap_file_sizes[0])
> > +        self.dut.session.copy_file_to(in_pcap1)
> > +        self.create_pcap_file(in_pcap2, TestPmdPcap.pcap_file_sizes[1])
> > +        self.dut.session.copy_file_to(in_pcap2)
> > +
> > +        command = ("./{}/app/testpmd -c {} -n {} " +
> > +                   "--vdev=eth_pcap0,rx_pcap={},tx_pcap={} " +
> > +                   "--vdev=eth_pcap1,rx_pcap={},tx_pcap={} " +
> > +                   "-- -i")
> > +
> > +        self.dut.send_expect(command.format(self.target, core_mask,
> > +                                            self.memory_channel,
> > +
> TestPmdPcap.dut_pcap_files_path +
> > +                                            in_pcap1,
> > +                                            out_pcap1,
> > +
> TestPmdPcap.dut_pcap_files_path +
> > +                                            in_pcap2,
> > +                                            out_pcap2), 'testpmd> ',
> > + 10)
> > +
> > +        self.dut.send_expect('start', 'testpmd> ')
> > +        sleep(2)
> > +        self.dut.send_expect('stop', 'testpmd> ')
> > +        self.dut.send_expect('quit', '# ')
> > +
> > +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path +
> in_pcap1,
> > +                              out_pcap2,
> > + TestPmdPcap.pcap_file_sizes[0])
> > +
> > +        self.check_pcap_files(TestPmdPcap.dut_pcap_files_path +
> in_pcap2,
> > +                              out_pcap1,
> > + TestPmdPcap.pcap_file_sizes[1])
> > +
> > +    def tear_down_all(self):
> > +        # Disable PCAP feature and rebuild the package
> > +        self.dut.send_expect(
> > +            "sed -i
> 's/CONFIG_RTE_LIBRTE_PMD_PCAP=y$/CONFIG_RTE_LIBRTE_PMD_PCAP=n/'
> config/%s" % self.pcap_config, "# ")
> > +        self.dut.set_target(self.target)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-24  2:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22  7:23 [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts haifeng
2015-09-22  7:23 ` [dts] [PATCH 2/2] add TestSuite_pmdpcap rst " haifeng
2015-09-23  2:29 ` [dts] [PATCH 1/2] add TestSuite_pmdpcap " Liu, Yong
2015-09-24  2:46   ` Tang, HaifengX
2015-09-24  2:46     ` Liu, Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).