test suite reviews and discussions
 help / color / mirror / Atom feed
From: Wenjie Li <wenjiex.a.li@intel.com>
To: dts@dpdk.org
Cc: Wenjie Li <wenjiex.a.li@intel.com>
Subject: [dts] [PATCH V1] tests/ip_pipeline:optimize script
Date: Wed, 21 Aug 2019 13:31:30 +0000	[thread overview]
Message-ID: <1566394290-25816-1-git-send-email-wenjiex.a.li@intel.com> (raw)

optimize script, including:
1. could support both 2 and 4 ports nic
2. could support 1 socket env for pfdpdk_vf_l2fwd_pipeline 
3. add two functions update_cli and launch_ip_pipeline 
4. write simliar code into a loop to make it concise

Signed-off-by: Wenjie Li <wenjiex.a.li@intel.com>
---
 tests/TestSuite_ip_pipeline.py | 719 ++++++++++-----------------------
 1 file changed, 217 insertions(+), 502 deletions(-)

diff --git a/tests/TestSuite_ip_pipeline.py b/tests/TestSuite_ip_pipeline.py
index f05b5cd..e7bc59b 100644
--- a/tests/TestSuite_ip_pipeline.py
+++ b/tests/TestSuite_ip_pipeline.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -62,6 +62,7 @@ from scapy.arch import get_if_hwaddr
 from scapy.sendrecv import sniff
 from scapy.sendrecv import sendp
 
+
 class TestIPPipeline(TestCase):
 
     def get_flow_direction_param_of_tcpdump(self):
@@ -158,14 +159,9 @@ class TestIPPipeline(TestCase):
             self.dut.generate_sriov_vfs_by_port(self.dut_ports[port_num], 1, driver)
             self.sriov_vfs_port.append(self.dut.ports_info[self.dut_ports[port_num]]['vfs_port'])
         if driver == 'default':
-            self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf0_interface, self.vf0_mac), "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf1_interface, self.vf1_mac), "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf2_interface, self.vf2_mac), "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf3_interface, self.vf3_mac), "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 spoofchk off" % self.pf0_interface, "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 spoofchk off" % self.pf1_interface, "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 spoofchk off" % self.pf2_interface, "# ", 3)
-            self.dut.send_expect("ip link set %s vf 0 spoofchk off" % self.pf3_interface, "# ", 3)
+            for i in range(len(self.dut_ports)):
+                self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_intf[i], self.vf_mac[i]), "# ", 3)
+                self.dut.send_expect("ip link set %s vf 0 spoofchk off" % self.pf_intf[i], "# ", 3)
 
         try:
             for port_num in range(port_nums):
@@ -193,29 +189,19 @@ class TestIPPipeline(TestCase):
         Run at the start of each test suite.
         """
         self.dut_ports = self.dut.get_ports()
-        self.port_nums = 4
-        self.verify(len(self.dut_ports) >= self.port_nums,
+        self.port_nums = [2, 4]
+        self.verify(len(self.dut_ports) in self.port_nums,
                     "Insufficient ports for speed testing")
 
-        self.dut_p0_pci = self.dut.get_port_pci(self.dut_ports[0])
-        self.dut_p1_pci = self.dut.get_port_pci(self.dut_ports[1])
-        self.dut_p2_pci = self.dut.get_port_pci(self.dut_ports[2])
-        self.dut_p3_pci = self.dut.get_port_pci(self.dut_ports[3])
-
-        self.dut_p0_mac = self.dut.get_mac_address(self.dut_ports[0])
-        self.dut_p1_mac = self.dut.get_mac_address(self.dut_ports[1])
-        self.dut_p2_mac = self.dut.get_mac_address(self.dut_ports[2])
-        self.dut_p3_mac = self.dut.get_mac_address(self.dut_ports[3])
-
-        self.pf0_interface = self.dut.ports_info[self.dut_ports[0]]['intf']
-        self.pf1_interface = self.dut.ports_info[self.dut_ports[1]]['intf']
-        self.pf2_interface = self.dut.ports_info[self.dut_ports[2]]['intf']
-        self.pf3_interface = self.dut.ports_info[self.dut_ports[3]]['intf']
-
-        self.vf0_mac = "00:11:22:33:44:55"
-        self.vf1_mac = "00:11:22:33:44:56"
-        self.vf2_mac = "00:11:22:33:44:57"
-        self.vf3_mac = "00:11:22:33:44:58"
+        self.dut_pci = []
+        self.dut_mac = []
+        self.pf_intf = []
+        self.vf_mac = []
+        for i in range(len(self.dut_ports)):
+            self.dut_pci.append(self.dut.ports_info[i]['pci'])
+            self.dut_mac.append(self.dut.ports_info[i]['mac'])
+            self.pf_intf.append(self.dut.ports_info[i]['intf'])
+            self.vf_mac.append("00:11:22:33:44:5%d" % (i+5))
 
         self.sriov_vfs_port = []
         self.session_secondary = self.dut.new_session()
@@ -231,433 +217,220 @@ class TestIPPipeline(TestCase):
         """
         pass
 
-    def test_routing_pipeline(self):
-        """
-        routing pipeline
-        """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/route.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/route.cli" % self.dut_p1_pci
+    def update_cli(self, cli_file):
+        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/%s" % (self.dut_pci[0], cli_file)
         self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/route.cli" % self.dut_p2_pci
+        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/%s" % (self.dut_pci[1], cli_file)
         self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/route.cli" % self.dut_p3_pci
+        if len(self.dut_ports) == 4:
+            cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/%s" % (self.dut_pci[2], cli_file)
+            self.dut.send_expect(cmd, "# ", 20)
+            cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/%s" % (self.dut_pci[3], cli_file)
+            self.dut.send_expect(cmd, "# ", 20)
+        cmd = "sed -i -e 's/default action fwd port 4/default action fwd port %s/' ./examples/ip_pipeline/examples/%s" % (len(self.dut_ports), cli_file)
         self.dut.send_expect(cmd, "# ", 20)
 
+    def launch_ip_pipeline(self, cli_file):
         IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/route.cli"
-
+        DUT_PORTS = ""
+        self.max_ports = len(self.dut_ports)
+        if cli_file == "tap.cli":
+            self.max_ports = 2
+        for i in range(self.max_ports):
+            DUT_PORTS = DUT_PORTS + " -w %s" % self.dut_pci[i]
+        SCRIPT_FILE = "./examples/ip_pipeline/examples/%s" % cli_file
         cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "30:31:32:33:34:35", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/route_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.0.0.1")/Raw(load="X"*26)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 0, pcap_file, filters)
-        dst_mac_list = []
-        for packet in sniff_pkts:
-            dst_mac_list.append(packet.getlayer(0).dst)
-        self.verify( "a0:a1:a2:a3:a4:a5" in dst_mac_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/route_1.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.64.0.1")/Raw(load="X"*26)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.64.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_mac_list = []
-        for packet in sniff_pkts:
-            dst_mac_list.append(packet.getlayer(0).dst)
-        self.verify( "b0:b1:b2:b3:b4:b5" in dst_mac_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/route_2.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.128.0.1")/Raw(load="X"*26)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.128.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 2, pcap_file, filters)
-        dst_mac_list = []
-        for packet in sniff_pkts:
-            dst_mac_list.append(packet.getlayer(0).dst)
-        self.verify( "c0:c1:c2:c3:c4:c5" in dst_mac_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/route_3.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.192.0.1")/Raw(load="X"*26)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.192.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 3, pcap_file, filters)
-        dst_mac_list = []
-        for packet in sniff_pkts:
-            dst_mac_list.append(packet.getlayer(0).dst)
-        self.verify( "d0:d1:d2:d3:d4:d5" in dst_mac_list, "rule 3 test fail")
+        rte_string = "30:31:32:33:34:35"
+        if cli_file == "route.cli":
+            rte_string = "30:31:32:33:34:35"
+        elif cli_file == "firewall.cli":
+            rte_string = "fwd port 1"
+        elif cli_file == "flow.cli":
+            rte_string = "fwd port 3"
+        elif cli_file == "l2fwd.cli":
+            rte_string = "fwd port 2"
+        elif cli_file == "tap.cli":
+            rte_string = "fwd port 3"
+        elif cli_file == "rss.cli":
+            rte_string = "PIPELINE3 enable"
+            cmd = "{0} -c 0x1f -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
+        self.dut.send_expect(cmd, "%s" % rte_string, 60)
 
-        sleep(1)
-        cmd = "^C"
-        self.dut.send_expect(cmd, "# ", 20)
+    def test_routing_pipeline(self):
+        """
+        routing pipeline
+        """
+        self.update_cli("route.cli")
+        self.launch_ip_pipeline("route.cli")
+
+        verify_list = ["a0:a1:a2:a3:a4:a5", "b0:b1:b2:b3:b4:b5", "c0:c1:c2:c3:c4:c5", "d0:d1:d2:d3:d4:d5"]
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/route_%d.pcap' % i
+            dst_ip = "100.%d.0.1" % (i * 64)
+            pkt = [Ether(dst=self.dut_mac[0])/IP(dst=dst_ip)/Raw(load="X" * 26)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "dst host %s" % dst_ip
+            sniff_pkts = self.send_and_sniff_pkts(0, i, pcap_file, filters)
+            dst_mac_list = []
+            for packet in sniff_pkts:
+                dst_mac_list.append(packet.getlayer(0).dst)
+            self.verify(verify_list[i] in dst_mac_list, "rule %d test fail" % i)
 
     def test_firewall_pipeline(self):
         """
         firewall pipeline
         """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/firewall.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/firewall.cli" % self.dut_p1_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/firewall.cli" % self.dut_p2_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/firewall.cli" % self.dut_p3_pci
-        self.dut.send_expect(cmd, "# ", 20)
-
-        IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/firewall.cli"
-
-        cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "fwd port 3", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/fw_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.0.0.1")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.0.0.1" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/fw_1.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.64.0.1")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.64.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.64.0.1" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/fw_2.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.128.0.1")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.128.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.128.0.1" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/fw_3.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(dst="100.192.0.1")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.192.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.192.0.1" in dst_ip_list, "rule 3 test fail")
-
-        sleep(1)
-        cmd = "^C"
-        self.dut.send_expect(cmd, "# ", 20)
+        self.update_cli("firewall.cli")
+        self.launch_ip_pipeline("firewall.cli")
+
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/fw_%d.pcap' % i
+            dst_ip = "100.%d.0.1" % (i*64)
+            pkt = [Ether(dst=self.dut_mac[0])/IP(dst=dst_ip)/TCP(sport=100,dport=200)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "dst host %s" % dst_ip
+            sniff_pkts = self.send_and_sniff_pkts(0, i, pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
     def test_flow_pipeline(self):
         """
         flow pipeline
         """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/flow.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/flow.cli" % self.dut_p1_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/flow.cli" % self.dut_p2_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/flow.cli" % self.dut_p3_pci
-        self.dut.send_expect(cmd, "# ", 20)
-
-        IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/flow.cli"
-
-        cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "fwd port 3", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/fl_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.10",dst="200.0.0.10")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.10" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/fl_1.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.11",dst="200.0.0.11")/TCP(sport=101,dport=201)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.11" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/fl_2.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.12",dst="200.0.0.12")/TCP(sport=102,dport=202)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.12" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/fl_3.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.13",dst="200.0.0.13")/TCP(sport=103,dport=203)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.13" in dst_ip_list, "rule 3 test fail")
-
-        sleep(1)
-        cmd = "^C"
-        self.dut.send_expect(cmd, "# ", 20)
+        self.update_cli("flow.cli")
+        self.launch_ip_pipeline("flow.cli")
+
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/fl_%d.pcap' % i
+            src_ip = "100.0.0.%d" % (i+10)
+            dst_ip = "200.0.0.%d" % (i+10)
+            sport = i + 100
+            dport = i + 200
+            pkt = [Ether(dst=self.dut_mac[0])/IP(src=src_ip,dst=dst_ip)/TCP(sport=sport,dport=dport)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "tcp"
+            sniff_pkts = self.send_and_sniff_pkts(0, i, pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
     def test_l2fwd_pipeline(self):
         """
         l2fwd pipeline
         """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/l2fwd.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/l2fwd.cli" % self.dut_p1_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/l2fwd.cli" % self.dut_p2_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/l2fwd.cli" % self.dut_p3_pci
-        self.dut.send_expect(cmd, "# ", 20)
-
-        IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/l2fwd.cli"
-
-        cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "fwd port 2", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/pt_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.10",dst="200.0.0.10")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.10" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/pt_1.pcap'
-        pkt = [Ether(dst=self.dut_p1_mac)/IP(src="100.0.0.11",dst="200.0.0.11")/TCP(sport=101,dport=201)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(1, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.11" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/pt_2.pcap'
-        pkt = [Ether(dst=self.dut_p2_mac)/IP(src="100.0.0.12",dst="200.0.0.12")/TCP(sport=102,dport=202)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(2, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.12" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/pt_3.pcap'
-        pkt = [Ether(dst=self.dut_p3_mac)/IP(src="100.0.0.13",dst="200.0.0.13")/TCP(sport=103,dport=203)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(3, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.13" in dst_ip_list, "rule 3 test fail")
-
-        sleep(1)
-        cmd = "^C"
-        self.dut.send_expect(cmd, "# ", 20)
+        self.update_cli("l2fwd.cli")
+        self.launch_ip_pipeline("l2fwd.cli")
+
+        from_port_list = [0, 1, 2, 3]
+        to_port_list = [1, 0, 3, 2]
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/pt_%d.pcap' % i
+            src_ip = "100.0.0.%d" % (i+10)
+            dst_ip = "200.0.0.%d" % (i+10)
+            sport = i + 100
+            dport = i + 200
+            pkt = [Ether(dst=self.dut_mac[i])/IP(src=src_ip,dst=dst_ip)/TCP(sport=sport,dport=dport)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "tcp"
+            sniff_pkts = self.send_and_sniff_pkts(from_port_list[i], to_port_list[i], pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
     def test_pfdpdk_vf_l2fwd_pipeline(self):
         """
         VF l2fwd pipeline, PF bound to DPDK driver
         """
-        self.setup_env(self.port_nums, driver=self.drivername)
+        self.setup_env(len(self.dut_ports), driver=self.drivername)
         self.dut.send_expect("sed -i '/^link LINK/d' ./examples/ip_pipeline/examples/l2fwd.cli", "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK3 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[3][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK2 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[2][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK1 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[1][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK0 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[0][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
+        for i in range(len(self.dut_ports)):
+            cmd = "sed -i '/mempool MEMPOOL0/a\link LINK%d dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' " \
+                  "./examples/ip_pipeline/examples/l2fwd.cli" % (i, self.sriov_vfs_port[i][0].pci)
+            self.dut.send_expect(cmd, "# ", 20)
 
         TESTPMD = "./%s/app/testpmd" % self.target
         IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PF_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        PF_SCRIPT_FILE = "--file-prefix=pf --socket-mem 1024,1024"
-
-        DUT_VF_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.sriov_vfs_port[0][0].pci, self.sriov_vfs_port[1][0].pci, self.sriov_vfs_port[2][0].pci, self.sriov_vfs_port[3][0].pci)
+        DUT_PF_PORTS = ""
+        DUT_VF_PORTS = ""
+        for i in range(len(self.dut_ports)):
+            DUT_PF_PORTS = DUT_PF_PORTS + " -w %s" % self.dut_pci[i]
+            DUT_VF_PORTS = DUT_VF_PORTS + " -w %s" % self.sriov_vfs_port[i][0].pci
+        PF_SCRIPT_FILE = "--file-prefix=pf --socket-mem 1024"
+        socket_num = self.dut.send_expect("lscpu | grep Socket | awk -F ' ' {'print $2'}", "#")
+        if int(socket_num) >= 2:
+            PF_SCRIPT_FILE = "--file-prefix=pf --socket-mem 1024,1024"
         VF_SCRIPT_FILE = "./examples/ip_pipeline/examples/l2fwd.cli"
 
         pf_cmd = "{0} -c 0xf0 -n 4 {1} {2} -- -i".format(TESTPMD, DUT_PF_PORTS, PF_SCRIPT_FILE)
         self.dut.send_expect(pf_cmd, "testpmd> ", 60)
-        self.dut.send_expect("set vf mac addr 0 0 %s" % self.vf0_mac, "testpmd> ", 30)
-        self.dut.send_expect("set vf mac addr 1 0 %s" % self.vf1_mac, "testpmd> ", 30)
-        self.dut.send_expect("set vf mac addr 2 0 %s" % self.vf2_mac, "testpmd> ", 30)
-        self.dut.send_expect("set vf mac addr 3 0 %s" % self.vf3_mac, "testpmd> ", 30)
-
+        for i in range(len(self.dut_ports)):
+            self.dut.send_expect("set vf mac addr %s 0 %s" % (i, self.vf_mac[i]), "testpmd> ", 30)
         vf_cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_VF_PORTS, VF_SCRIPT_FILE)
-        self.session_secondary.send_expect(vf_cmd, "fwd port 2", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/pt_0.pcap'
-        pkt = [Ether(dst=self.vf0_mac)/IP(src="100.0.0.10",dst="200.0.0.10")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.10" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/pt_1.pcap'
-        pkt = [Ether(dst=self.vf1_mac)/IP(src="100.0.0.11",dst="200.0.0.11")/TCP(sport=101,dport=201)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(1, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.11" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/pt_2.pcap'
-        pkt = [Ether(dst=self.vf2_mac)/IP(src="100.0.0.12",dst="200.0.0.12")/TCP(sport=102,dport=202)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(2, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.12" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/pt_3.pcap'
-        pkt = [Ether(dst=self.vf3_mac)/IP(src="100.0.0.13",dst="200.0.0.13")/TCP(sport=103,dport=203)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(3, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.13" in dst_ip_list, "rule 3 test fail")
+        self.session_secondary.send_expect(vf_cmd, "fwd port 1", 60)
+
+        from_port_list = [0, 1, 2, 3]
+        to_port_list = [1, 0, 3, 2]
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/pt_%d.pcap' % i
+            src_ip = "100.0.0.%d" % (i+10)
+            dst_ip = "200.0.0.%d" % (i+10)
+            sport = i + 100
+            dport = i + 200
+            pkt = [Ether(dst=self.vf_mac[i])/IP(src=src_ip,dst=dst_ip)/TCP(sport=sport,dport=dport)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "tcp"
+            sniff_pkts = self.send_and_sniff_pkts(from_port_list[i], to_port_list[i], pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
         sleep(1)
-        self.destroy_env(self.port_nums, driver=self.drivername)
+        self.destroy_env(len(self.dut_ports), driver=self.drivername)
 
     def test_pfkernel_vf_l2fwd_pipeline(self):
         """
         VF l2fwd pipeline, PF bound to kernel driver
         """
-        self.setup_env(self.port_nums, driver='default')
+        self.setup_env(len(self.dut_ports), driver='default')
         self.dut.send_expect("sed -i '/^link LINK/d' ./examples/ip_pipeline/examples/l2fwd.cli", "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK3 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[3][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK2 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[2][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK1 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[1][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i '/mempool MEMPOOL0/a\link LINK0 dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' ./examples/ip_pipeline/examples/l2fwd.cli" % self.sriov_vfs_port[0][0].pci
-        self.dut.send_expect(cmd, "# ", 20)
+        for i in range(len(self.dut_ports)):
+            cmd = "sed -i '/mempool MEMPOOL0/a\link LINK%d dev %s rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on' " \
+                  "./examples/ip_pipeline/examples/l2fwd.cli" % (i, self.sriov_vfs_port[i][0].pci)
+            self.dut.send_expect(cmd, "# ", 20)
 
         IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_VF_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.sriov_vfs_port[0][0].pci, self.sriov_vfs_port[1][0].pci, self.sriov_vfs_port[2][0].pci, self.sriov_vfs_port[3][0].pci)
+        DUT_VF_PORTS = ""
+        for i in range(len(self.dut_ports)):
+            DUT_VF_PORTS = DUT_VF_PORTS + " -w %s" % self.sriov_vfs_port[i][0].pci
         VF_SCRIPT_FILE = "./examples/ip_pipeline/examples/l2fwd.cli"
 
         vf_cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_VF_PORTS, VF_SCRIPT_FILE)
         self.session_secondary.send_expect(vf_cmd, "fwd port 2", 60)
 
-        #rule 0 test
-        pcap_file = '/tmp/pt_0.pcap'
-        pkt = [Ether(dst=self.vf0_mac)/IP(src="100.0.0.10",dst="200.0.0.10")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.10" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/pt_1.pcap'
-        pkt = [Ether(dst=self.vf1_mac)/IP(src="100.0.0.11",dst="200.0.0.11")/TCP(sport=101,dport=201)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(1, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.11" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/pt_2.pcap'
-        pkt = [Ether(dst=self.vf2_mac)/IP(src="100.0.0.12",dst="200.0.0.12")/TCP(sport=102,dport=202)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(2, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.12" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/pt_3.pcap'
-        pkt = [Ether(dst=self.vf3_mac)/IP(src="100.0.0.13",dst="200.0.0.13")/TCP(sport=103,dport=203)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(3, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.13" in dst_ip_list, "rule 3 test fail")
+        from_port_list = [0, 1, 2, 3]
+        to_port_list = [1, 0, 3, 2]
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/pt_%d.pcap' % i
+            src_ip = "100.0.0.%d" % (i+10)
+            dst_ip = "200.0.0.%d" % (i+10)
+            sport = i + 100
+            dport = i + 200
+            pkt = [Ether(dst=self.vf_mac[i])/IP(src=src_ip,dst=dst_ip)/TCP(sport=sport,dport=dport)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "tcp"
+            sniff_pkts = self.send_and_sniff_pkts(from_port_list[i], to_port_list[i], pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
         sleep(1)
-        self.destroy_env(self.port_nums, driver=self.drivername)
+        self.destroy_env(len(self.dut_ports), driver=self.drivername)
         for port_id in self.dut_ports:
             port = self.dut.ports_info[port_id]['port']
             port.bind_driver(driver=self.drivername)
@@ -666,18 +439,8 @@ class TestIPPipeline(TestCase):
         """
         pipeline with tap
         """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/tap.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/tap.cli" % self.dut_p1_pci
-        self.dut.send_expect(cmd, "# ", 20)
-
-        IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/tap.cli"
-
-        cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "fwd port 3", 60)
+        self.update_cli("tap.cli")
+        self.launch_ip_pipeline("tap.cli")
 
         tap_session = self.dut.new_session()
         cmd = "ip link set br1 down; brctl delbr br1"
@@ -686,27 +449,24 @@ class TestIPPipeline(TestCase):
         tap_session.send_expect(cmd, "# ", 20)
         cmd = "ifconfig TAP0 up;  ifconfig TAP1 up; ifconfig br1 up"
         tap_session.send_expect(cmd, "# ", 20)
-        #rule 0 test
-        pcap_file = '/tmp/tap_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.10",dst="200.0.0.10")/TCP(sport=100,dport=200)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.10" in dst_ip_list, "link 1 failed to receive packet")
-
-        #rule 1 test
-        pcap_file = '/tmp/tap_1.pcap'
-        pkt = [Ether(dst=self.dut_p1_mac)/IP(src="100.0.0.11",dst="200.0.0.11")/TCP(sport=101,dport=201)/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "tcp"
-        sniff_pkts = self.send_and_sniff_pkts(1, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "200.0.0.11" in dst_ip_list, "link 0 failed to receive packet")
+
+
+        from_port_list = [0, 1]
+        to_port_list = [1, 0]
+        for i in range(self.max_ports):
+            pcap_file = '/tmp/pt_%d.pcap' % i
+            src_ip = "100.0.0.%d" % (i+10)
+            dst_ip = "200.0.0.%d" % (i+10)
+            sport = i + 100
+            dport = i + 200
+            pkt = [Ether(dst=self.dut_mac[i])/IP(src=src_ip,dst=dst_ip)/TCP(sport=sport,dport=dport)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "tcp"
+            sniff_pkts = self.send_and_sniff_pkts(from_port_list[i], to_port_list[i], pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
         sleep(1)
         cmd = "^C"
@@ -720,76 +480,31 @@ class TestIPPipeline(TestCase):
         """
         rss pipeline
         """
-        cmd = "sed -i -e 's/0000:02:00.0/%s/' ./examples/ip_pipeline/examples/rss.cli" % self.dut_p0_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:02:00.1/%s/' ./examples/ip_pipeline/examples/rss.cli" % self.dut_p1_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.0/%s/' ./examples/ip_pipeline/examples/rss.cli" % self.dut_p2_pci
-        self.dut.send_expect(cmd, "# ", 20)
-        cmd = "sed -i -e 's/0000:06:00.1/%s/' ./examples/ip_pipeline/examples/rss.cli" % self.dut_p3_pci
-        self.dut.send_expect(cmd, "# ", 20)
-
-        IP_PIPELINE = "./examples/ip_pipeline/build/ip_pipeline"
-        DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\
-                    .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci)
-        SCRIPT_FILE = "./examples/ip_pipeline/examples/rss.cli"
-
-        cmd = "{0} -c 0x1f -n 4 {1} -- -s {2}".format(IP_PIPELINE, DUT_PORTS, SCRIPT_FILE)
-        self.dut.send_expect(cmd, "PIPELINE3 enable", 60)
-
-        #rule 0 test
-        pcap_file = '/tmp/rss_0.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.10.1",dst="100.0.20.2")/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.20.2"
-        sniff_pkts = self.send_and_sniff_pkts(0, 0, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.0.20.2" in dst_ip_list, "rule 0 test fail")
-
-        #rule 1 test
-        pcap_file = '/tmp/rss_1.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.0",dst="100.0.0.1")/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.0.1"
-        sniff_pkts = self.send_and_sniff_pkts(0, 1, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.0.0.1" in dst_ip_list, "rule 1 test fail")
-
-        #rule 2 test
-        pcap_file = '/tmp/rss_2.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.10.1",dst="100.0.0.2")/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.0.2"
-        sniff_pkts = self.send_and_sniff_pkts(0, 2, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.0.0.2" in dst_ip_list, "rule 2 test fail")
-
-        #rule 3 test
-        pcap_file = '/tmp/rss_3.pcap'
-        pkt = [Ether(dst=self.dut_p0_mac)/IP(src="100.0.0.1",dst="100.0.10.2")/Raw(load="X"*6)]
-        self.write_pcap_file(pcap_file, pkt)
-        filters = "dst host 100.0.10.2"
-        sniff_pkts = self.send_and_sniff_pkts(0, 3, pcap_file, filters)
-        dst_ip_list = []
-        for packet in sniff_pkts:
-            dst_ip_list.append(packet.getlayer(1).dst)
-        self.verify( "100.0.10.2" in dst_ip_list, "rule 3 test fail")
-
-        sleep(1)
-        cmd = "^C"
-        self.dut.send_expect(cmd, "# ", 20)
+        self.update_cli("rss.cli")
+        self.launch_ip_pipeline("rss.cli")
+
+        verify_list = ["100.0.20.2", "100.0.0.1", "100.0.0.2", "100.0.10.2"]
+        src_ip_list = ["100.0.10.1", "100.0.0.0", "100.0.10.1", "100.0.0.1"]
+        for i in range(len(self.dut_ports)):
+            pcap_file = '/tmp/rss_%d.pcap' % i
+            src_ip = src_ip_list[i]
+            dst_ip = verify_list[i]
+            pkt = [Ether(dst=self.dut_mac[0])/IP(src=src_ip,dst=dst_ip)/Raw(load="X"*6)]
+            self.write_pcap_file(pcap_file, pkt)
+            filters = "dst host %s" % dst_ip
+            sniff_pkts = self.send_and_sniff_pkts(0, i, pcap_file, filters)
+            dst_ip_list = []
+            for packet in sniff_pkts:
+                dst_ip_list.append(packet.getlayer(1).dst)
+            self.verify(dst_ip in dst_ip_list, "rule %d test fail" % i)
 
     def tear_down(self):
         """
         Run after each test case.
         """
-        pass
+        sleep(1)
+        cmd = "^C"
+        self.dut.send_expect(cmd, "# ", 20)
 
     def tear_down_all(self):
         """
-- 
2.17.1


             reply	other threads:[~2019-08-21  4:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 13:31 Wenjie Li [this message]
2019-08-23 13:01 Wenjie Li
2019-08-23  4:12 ` Zhu, ShuaiX

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=1566394290-25816-1-git-send-email-wenjiex.a.li@intel.com \
    --to=wenjiex.a.li@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).