From: "xu,gang" <gangx.xu@intel.com>
To: dts@dpdk.org
Cc: "xu,gang" <gangx.xu@intel.com>
Subject: [dts] [PATCH V1] add test suite ip_pipekine config file
Date: Fri, 18 Nov 2016 10:59:25 +0800 [thread overview]
Message-ID: <1479437968-4538-1-git-send-email-gangx.xu@intel.com> (raw)
Signed-off-by: xu,gang <gangx.xu@intel.com>
---
tests/TestSuite_ip_pipeline_config_file.py | 323 +++++++++++++++++++++++++++++
1 file changed, 323 insertions(+)
create mode 100644 tests/TestSuite_ip_pipeline_config_file.py
diff --git a/tests/TestSuite_ip_pipeline_config_file.py b/tests/TestSuite_ip_pipeline_config_file.py
new file mode 100644
index 0000000..99e1542
--- /dev/null
+++ b/tests/TestSuite_ip_pipeline_config_file.py
@@ -0,0 +1,323 @@
+#BSD LICENSE
+#
+# Copyright(c) 2010-2016 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 ip_pipeline_configuration file.
+"""
+
+import dts
+import string
+import time
+import re
+import os
+from test_case import TestCase
+from plotting import Plotting
+from settings import HEADER_SIZE
+from etgen import IxiaPacketGenerator
+from packet import Packet, sniff_packets, load_sniff_packets
+
+class Test_ip_pipeline_configuration_file(TestCase):
+
+ def set_up_all(self):
+ """
+ Run at the start of each test suite.
+ """
+ self.dut_ports = self.dut.get_ports(self.nic)
+ self.verify(len(self.dut_ports) >= 4, "Insufficient ports")
+ cores = self.dut.get_core_list("1S/4C/1T")
+ #self.coremask = dts.create_mask(cores)
+
+ self.dut.send_expect("chmod 777 /root/","#",30)
+ self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PORT_PCAP=.*$/"
+ + "CONFIG_RTE_PORT_PCAP=y/' config/common_base", "# ", 30)
+ self.dut.build_install_dpdk(self.target)
+
+ #unpack test configuration
+ cwd = os.getcwd()
+ self.tester.send_expect("cd %s/dep/" % cwd,"# ",50)
+ result = self.tester.send_expect("tar xzvf ip_pipeline.tar.gz","# ",50)
+ self.verify("error" not in result, "ip_pipeline unpack fail ")
+
+ self.update_ip_pipeline_config()
+
+ #copy configuration file to dut and unpack
+ self.dut.session.copy_file_to("dep/ip_pipeline.tar.gz")
+ put = self.dut.send_expect("tar zxvf ~/ip_pipeline.tar.gz -C ~","#",500)
+ #self.verify("error" not in put, "ip_pipeline unpack fail")
+
+ self.path = "./examples/ip_pipeline/build/ip_pipeline"
+
+ self.filepath = self.get_filepath()
+ # build sample app
+ out = self.dut.build_dpdk_apps("./examples/ip_pipeline")
+ self.verify("Error" not in out, "compilation error 1")
+ self.verify("No such file" not in out, "compilation error 2")
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ pass
+
+ def replace_pci(self,filename,old,new):
+ """
+ modify the file by new code
+ """
+ try:
+ lines = open(filename,'r').readlines()
+ flen = len(lines)
+ for i in range(flen):
+ if old in lines[i]:
+ lines[i] = lines[i].replace(old,new)
+ open(filename,'w').writelines(lines)
+ except Exception,e:
+ print e
+
+ def get_filepath(self):
+ filepatch = []
+ sourc_work_path = os.getcwd()
+ os.chdir("./dep")
+ rootdir = "ip_pipeline/"
+ for parent,dirnames,filenames in os.walk(rootdir):
+ for filename in filenames:
+ filepatch.append(os.path.join(parent,filename))
+ os.chdir(sourc_work_path)
+ return filepatch
+ def update_ip_pipeline_config(self):
+ """
+ modify the ip_pipeline cfg file's pci and pack again
+ """
+ po_rootdir = "dep/ip_pipeline/ip_pipeline_link_identification/"
+ for po_parent,po_dirnames,po_filenames in os.walk(po_rootdir):
+ for i in po_filenames:
+ filename = os.path.join(po_parent,i)
+ self.replace_pci(filename,"port0","%s" % self.dut.ports_info[0]['pci'])
+ self.replace_pci(filename,"port1","%s" % self.dut.ports_info[1]['pci'])
+ self.replace_pci(filename,"port2","%s" % self.dut.ports_info[2]['pci'])
+ self.replace_pci(filename,"port3","%s" % self.dut.ports_info[3]['pci'])
+ self.tester.send_expect("rm -rf ip_pipeline.tar.gz","#",10)
+ result = self.tester.send_expect("tar -czvf ip_pipeline.tar.gz ip_pipeline/","#",50)
+ self.verify("error" not in result, "ip_pipeline compression fail")
+ self.tester.send_expect("cd ../","#",10)
+
+ def scapy_send_package(self,num = 1):
+ """
+ Send a packet to port
+ """
+ txport = self.tester.get_local_port(self.dut_ports[0])
+ mac = self.dut.get_mac_address(self.dut_ports[0])
+ txItf = self.tester.get_interface(txport)
+ self.tester.scapy_append('sendp([Ether(dst="%s")/IP()/UDP()/Raw(\'X\'*18)], iface="%s",count=%s)' % (mac, txItf,num))
+ self.tester.scapy_execute()
+
+ def print_info(self,filename):
+ print "\033[1;31;40m"
+ print "Test failed on %s" % filename
+ print "\033[0m"
+ def test_ip_pipeline_rss(self):
+ failcase = []
+ for filename in self.filepath:
+ if "ip_pipeline_rss/" in filename:
+ cmd = self.path + " -p 0x3 -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",120)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.verify(len(failcase) == 0, "Failed cfg file nameon %s" % failcase)
+
+ def test_ip_pipeline_cfg(self):
+ failcase = []
+ for filename in self.filepath:
+ if "ip_pipeline_cfg/postive" in filename:
+ cmd = self.path + " -p 0x3 -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",120)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ #self.verify("Bye!" in out, "Test failed on %s" % filename)
+ elif "ip_pipeline_cfg/negative" in filename:
+ cmd = self.path + " -p 0x3 -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"# ",60)
+ if "error" not in out:
+ print out
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+ #self.verify("error" in out, "Test failed on %s" % filename)
+ self.verify(len(failcase) == 0, "Failed cfg file nameon %s" % failcase)
+
+ def test_ip_pipeline_cpu_utilization(self):
+ self.dut.send_expect("cd examples/ip_pipeline","#",50)
+ self.dut.send_expect("sed -i -e 's/pool_size = .*$/"
+ + "pool_size = 4096/' config/edge_router_downstream.cfg", "# ", 30)
+ cmd = "./build/ip_pipeline -p 0xf -f config/edge_router_downstream.cfg -s config/edge_router_downstream.sh"
+ out = self.dut.send_expect(cmd,"#p 1 route ls",50)
+ self.scapy_send_package(1000)
+ self.dut.send_expect("","pipeline> ",5)
+ out = self.dut.send_expect("t 1 headroom","pipeline> ",10)
+ self.dut.send_expect("quit","# ",10)
+ print out
+ self.verify(out > "50%" , "headroom error")
+ self.dut.send_expect("cd -","#",50)
+
+ def test_ip_pipeline_link_identification(self):
+ failcase = []
+ for filename in self.filepath:
+ if "ip_pipeline_link_identification/postive" in filename:
+ if "_f" in filename:
+ cmd = self.path + " -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",50)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ #self.verify("Bye!" in out, "Test failed on %s" % filename)
+ elif "_pf" in filename:
+ cmd = self.path + " -p f -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",50)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ elif "1p" in filename:
+ cmd = self.path + " -p 1 -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",50)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+
+
+# self.verify("Bye!" in out, "Test failed on %s" % filename)
+ elif "ip_pipeline_link_identification/negative" in filename:
+ if "_f" in filename:
+ cmd = self.path + " -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"# ",50)
+ if "error" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+ # self.verify("error" in out, "Test failed on %s" % filename)
+ elif "_1p" in filename:
+ cmd = self.path + " -p 1 -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"# ",50)
+ if "error" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+# self.verify("error" in out, "Test failed on %s" % filename)
+ elif "_3p" in filename:
+ cmd = self.path + " -p 3 -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"#",50)
+ if "error" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+# self.verify("error" in out, "Test failed on %s" % filename)
+ self.verify(len(failcase) == 0, "Failed cfg file nameon %s" % failcase)
+
+ def test_ip_pipeline_parser_cleanup(self):
+ failcase = []
+ for filename in self.filepath:
+ if "ip_pipeline_parser_cleanup/postive" in filename:
+ cmd = self.path + " -p 0x3 -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",50)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ #self.verify("Bye!" in out, "Test failed on %s" % filename)
+ elif "ip_pipeline_parser_cleanup/negative" in filename:
+ cmd = self.path + " -p 0x3 -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"# ",50)
+ if "error" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+ self.verify(len(failcase) == 0, "Failed cfg file nameon %s" % failcase)
+ # self.verify("error" in out, "Test failed on %s" % filename)
+
+ def test_ip_pipeline_source_sink(self):
+ failcase = []
+ for filename in self.filepath:
+ if "ip_pipeline_source_sink/postive" in filename:
+ self.dut.send_expect("cp ~/ip_pipeline/*.pcap ~","#",50)
+ if "_com" in filename:
+ cmd = self.path + " -f ~/%s" % filename
+ self.dut.send_expect(cmd,"PORT: Dumped",50)
+ time.sleep(10)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+
+ # self.verify("Bye!" in out, "Test failed on %s" % filename)
+ else:
+ cmd = self.path + " -f ~/%s" % filename
+ self.dut.send_expect(cmd,"[PIPELINE1]",50)
+ out = self.dut.send_expect("quit","# ",10)
+ if "Bye!" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+
+ # self.verify("Bye!" in out, "Test failed on %s" % filename)
+ self.dut.send_expect("rm -rf ~/*.pcap","#",50)
+ elif "ip_pipeline_source_sink/negative" in filename:
+ self.dut.send_expect("cp ~/ip_pipeline/*.pcap ~","#",50)
+ cmd = self.path + " -f ~/%s" % filename
+ out = self.dut.send_expect(cmd,"# ",50)
+ if "error" not in out:
+ self.print_info(filename)
+ failcase.append(filename)
+ self.dut.send_expect("quit","# ",10)
+# self.verify("error" in out, "Test failed on %s" % filename)
+ self.dut.send_expect("rm -rf ~/*.pcap","#",50)
+ self.verify(len(failcase) == 0, "Failed cfg file nameon %s" % failcase)
+ def tear_down(self):
+ """
+ Run after each test case.
+ """
+
+ self.dut.kill_all()
+ time.sleep(2)
+
+ def tear_down_all(self):
+ """
+ Run after each test suite.
+ """
+ self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PORT_PCAP=.*$/"
+ + "CONFIG_RTE_PORT_PCAP=n/' config/common_base", "# ", 30)
+ self.dut.build_install_dpdk(self.target)
+
--
1.9.3
next reply other threads:[~2016-11-18 2:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 2:59 xu,gang [this message]
2016-11-18 2:59 ` [dts] [PATCH V1] add test suite l2fwd-jobstats xu,gang
2016-11-18 3:18 ` Liu, Yong
2016-11-18 2:59 ` [dts] [PATCH V1] add test suite packet ordering xu,gang
2016-11-18 2:59 ` [dts] [PATCH V1] fix NIC binding error xu,gang
2016-11-23 2:00 ` Liu, Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479437968-4538-1-git-send-email-gangx.xu@intel.com \
--to=gangx.xu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).