From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 20E355587 for ; Fri, 18 Nov 2016 03:58:15 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 17 Nov 2016 18:58:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,655,1473145200"; d="scan'208";a="1086895237" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by fmsmga002.fm.intel.com with ESMTP; 17 Nov 2016 18:58:13 -0800 From: "xu,gang" To: dts@dpdk.org Cc: "xu,gang" Date: Fri, 18 Nov 2016 10:59:25 +0800 Message-Id: <1479437968-4538-1-git-send-email-gangx.xu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V1] add test suite ip_pipekine config file 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, 18 Nov 2016 02:58:16 -0000 Signed-off-by: xu,gang --- 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