test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests: Add RRC support for queue_start_stop case
@ 2015-07-06  9:19 Michael Qiu
  2015-07-06  9:28 ` [dts] [PATCH] Add folder Depends in settings Michael Qiu
  2015-07-07  6:30 ` [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case Michael Qiu
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Qiu @ 2015-07-06  9:19 UTC (permalink / raw)
  To: dts

queue_start_stop case does not support RRC yet, this patch
is to enbale this.

Also change the patch file to change to source code.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 dep/macfwd_log.patch                |  10 +++
 tests/TestSuite_queue_start_stop.py | 166 ++++++++++++++++++------------------
 2 files changed, 92 insertions(+), 84 deletions(-)
 create mode 100644 dep/macfwd_log.patch

diff --git a/dep/macfwd_log.patch b/dep/macfwd_log.patch
new file mode 100644
index 0000000..0f657f8
--- /dev/null
+++ b/dep/macfwd_log.patch
@@ -0,0 +1,10 @@
+--- app/test-pmd/macfwd.c.org	2015-07-02 10:51:12.821246109 +0800
++++ app/test-pmd/macfwd.c	2015-07-02 10:50:11.343243319 +0800
+@@ -102,6 +102,7 @@
+ 				 nb_pkt_per_burst);
+ 	if (unlikely(nb_rx == 0))
+ 		return;
++	printf("ports %u queue %u receive %u packages\n", fs->rx_port, fs->rx_queue, nb_rx);
+ 
+ #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
+ 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index 1c4b7b7..d7190a9 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,6 +44,7 @@ import re
 import os
 from test_case import TestCase
 from pmd_output import PmdOutput
+from settings import FOLDERS
 
 #
 #
@@ -69,7 +70,16 @@ class TestQueueStartStop(TestCase):
         """
         Run before each test case.
         """
-        pass
+        patch_file = FOLDERS["Depends"] + r'/macfwd_log.patch'
+        patch_dst = "/tmp/"
+
+        # dpdk patch and build
+        try:
+            self.dut.session.copy_file_to(patch_file, patch_dst)
+            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", True)
+            self.dut.build_dpdk_apps('./app/test-pmd')
+        except Exception, e:
+            raise IOError("dpdk setup failure: %s" % e)
 
     def check_forwarding(self, ports, nic, testerports=[None, None], pktSize=64, received=True):
         self.send_packet(ports[0], ports[1], self.nic, testerports[1], pktSize, received)
@@ -84,7 +94,8 @@ class TestQueueStartStop(TestCase):
             txitf = self.tester.get_interface(self.tester.get_local_port(txPort))
         else:
             itf = testerports
-        mac = self.dut.get_mac_address(txPort)
+        smac = self.tester.get_mac(self.tester.get_local_port(txPort))
+        dmac = self.dut.get_mac_address(txPort)
 
         self.tester.scapy_background()
         self.tester.scapy_append('p=sniff(iface="%s",count=1,timeout=5)' % rxitf)
@@ -94,7 +105,7 @@ class TestQueueStartStop(TestCase):
 
         pktlen = pktSize - 14
         padding = pktlen - 20
-        self.tester.scapy_append('sendp([Ether(dst="%s")/IP()/Raw(load="P"*%s)], iface="%s")' % (mac, padding, txitf))
+        self.tester.scapy_append('sendp([Ether(src="%s", dst="%s")/IP()/Raw(load="P"*%s)], iface="%s")' % (smac, dmac, padding, txitf))
 
         self.tester.scapy_execute()
         time.sleep(3)
@@ -105,102 +116,89 @@ class TestQueueStartStop(TestCase):
         else:
             self.verify('PPP' not in out, "stop queue failed")
 
-    def add_code_to_dpdk(self, file_name, standard_row, add_rows, offset=0):
+    def patch_hotfix_dpdk(self, patch_dir, on = True):
         """
-        this function for add code in dpdk src code file.
-        file: source code full path
-        standard_row: standard row for find the place that add code
-        offset: need offset row number
-        add_rows:add source code
-
-        return: source code lines
+        This function is to apply or remove patch for dpdk.
+        patch_dir: the abs path of the patch
+        on: True for apply, False for remove
         """
-        file_handel = open(file_name, "r+w")
-        source_lines = file_handel.readlines()
-
-        write_lines = source_lines
-
-        # get the index that need add code
-        index = -1
-        for line in write_lines:
-            if standard_row in line:
-                index = write_lines.index(line) + offset
-                break
-
-        # add source code and re-write the file
-        # print write_lines,index
-        for line in add_rows:
-            write_lines.insert(index, line)
-            index += 1
-        # print write_lines
-        file_handel.seek(file_handel.tell() * -1, 2)
-        file_handel.writelines(write_lines)
-        file_handel.close()
-
-        return source_lines
+        try:
+            if on:
+                self.dut.send_expect("patch -p0 < %s" % patch_dir, "#")
+            else:
+                self.dut.send_expect("patch -p0 -R < %s" % patch_dir, "#")
+        except Exception, e:
+            raise ValueError("patch_hotfix_dpdk failure: %s" % e)
 
     def test_queue_start_stop(self):
         """
-        queue start/stop test for fortville nic
+        queue start/stop test
         """
-        self.dut.session.copy_file_from(r'%s/app/test-pmd/macfwd.c' % self.dut.base_dir)
-        fwdmac_file = 'macfwd.c'
-        printf_lines = ['printf("ports %u queue %u revice %u packages", fs->rx_port, fs->rx_queue, nb_rx);\n', r'printf("\n");',"\n"]
-        sourcelines = self.add_code_to_dpdk(fwdmac_file, r'(unlikely(nb_rx == 0)', printf_lines, 2)
-        self.dut.session.copy_file_to(fwdmac_file)
-        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-pmd/macfwd.c' % self.dut.base_dir, "#")
-        self.dut.build_dpdk_apps('./app/test-pmd')
-
-        self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --portmask=0x3", "testpmd>", 120)
-        self.dut.send_expect("set fwd mac", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic)
-
-        # stop rx queue test
-        print "test stop rx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic, received=False)
-
-        # start rx queue test
-        print "test start rx queue stop tx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
-        self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic, received=False)
-        out = self.dut.send_expect("\n", "testpmd>")
-        # print out
-        self.verify("ports 0 queue 0 revice 1 packages" in out, "start queue revice package failed")
-
-        # start tx queue test
-        print "test start rx and tx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
-        self.dut.send_expect("port 1 txq 0 start", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic)
-        self.dut.send_expect("quit", "testpmd>")
-
-        # recover testpmd changed
-        file_handel = open(fwdmac_file, "w")
-        file_handel.writelines(sourcelines)
-        file_handel.close()
-        self.dut.session.copy_file_to(fwdmac_file)
-        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-pmd/macfwd.c' % self.dut.base_dir, "#")
+        #dpdk start
+        try:
+            self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i", "testpmd>", 120)
+            self.dut.send_expect("set fwd mac", "testpmd>")
+            self.dut.send_expect("set promisc all off", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic)
+        except Exception, e:
+            raise IOError("dpdk start and first forward failure: %s" % e)
+
+            # stop rx queue test
+        try:
+            print "test stop rx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic, received=False)
+
+            # start rx queue test
+            print "test start rx queue stop tx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
+            self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic, received=False)
+            out = self.dut.send_expect("\n", "testpmd>")
+        except Exception, e:
+            raise IOError("queue start/stop forward failure: %s" % e)
+
+        self.verify("ports 0 queue 0 receive 1 packages" in out, "start queue revice package failed, out = %s"%out)
+
+        try:
+            # start tx queue test
+            print "test start rx and tx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 1 txq 0 start", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic)
+        except Exception, e:
+            raise IOError("queue start/stop forward failure: %s" % e)
 
     def tear_down(self):
         """
         Run after each test case.
         """
+        patch_dst = "/tmp/"
+
+        try:
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("quit", "testpmd>")
+        except:
+            print "Failed to quit testpmd"
+
         self.dut.kill_all()
 
+        try:
+            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", False)
+        except Exception, e:
+            print "patch_hotfix_dpdk remove failure :%s" %e
+
     def tear_down_all(self):
         """
         Run after each test suite.
         """
         self.dut.kill_all()
-        #self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
-        #self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
-        #self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
-- 
1.9.3

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

* [dts] [PATCH] Add folder Depends in settings
  2015-07-06  9:19 [dts] [PATCH] tests: Add RRC support for queue_start_stop case Michael Qiu
@ 2015-07-06  9:28 ` Michael Qiu
  2015-07-07  6:30 ` [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case Michael Qiu
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Qiu @ 2015-07-06  9:28 UTC (permalink / raw)
  To: dts

dep folder need to be set in settings

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/settings.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/framework/settings.py b/framework/settings.py
index 3a70804..54ccbb1 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -39,6 +39,7 @@ FOLDERS = {
     'Framework': 'framework',
     'Testscripts': 'tests',
     'Configuration': 'conf',
+    'Depends': 'dep',
 }
 
 """
-- 
1.9.3

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

* [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case
  2015-07-06  9:19 [dts] [PATCH] tests: Add RRC support for queue_start_stop case Michael Qiu
  2015-07-06  9:28 ` [dts] [PATCH] Add folder Depends in settings Michael Qiu
@ 2015-07-07  6:30 ` Michael Qiu
  2015-07-08  5:18   ` Liu, Yong
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Qiu @ 2015-07-07  6:30 UTC (permalink / raw)
  To: dts

queue_start_stop case does not support RRC yet, this patch
is to enbale this.

Also change the patch file to change to source code.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 v2 --> v1
      Add portmask to testpmd commanline

 dep/macfwd_log.patch                |  10 +++
 tests/TestSuite_queue_start_stop.py | 166 ++++++++++++++++++------------------
 2 files changed, 92 insertions(+), 84 deletions(-)
 create mode 100644 dep/macfwd_log.patch

diff --git a/dep/macfwd_log.patch b/dep/macfwd_log.patch
new file mode 100644
index 0000000..0f657f8
--- /dev/null
+++ b/dep/macfwd_log.patch
@@ -0,0 +1,10 @@
+--- app/test-pmd/macfwd.c.org	2015-07-02 10:51:12.821246109 +0800
++++ app/test-pmd/macfwd.c	2015-07-02 10:50:11.343243319 +0800
+@@ -102,6 +102,7 @@
+ 				 nb_pkt_per_burst);
+ 	if (unlikely(nb_rx == 0))
+ 		return;
++	printf("ports %u queue %u receive %u packages\n", fs->rx_port, fs->rx_queue, nb_rx);
+ 
+ #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
+ 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index 1c4b7b7..d62cc8c 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,6 +44,7 @@ import re
 import os
 from test_case import TestCase
 from pmd_output import PmdOutput
+from settings import FOLDERS
 
 #
 #
@@ -69,7 +70,16 @@ class TestQueueStartStop(TestCase):
         """
         Run before each test case.
         """
-        pass
+        patch_file = FOLDERS["Depends"] + r'/macfwd_log.patch'
+        patch_dst = "/tmp/"
+
+        # dpdk patch and build
+        try:
+            self.dut.session.copy_file_to(patch_file, patch_dst)
+            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", True)
+            self.dut.build_dpdk_apps('./app/test-pmd')
+        except Exception, e:
+            raise IOError("dpdk setup failure: %s" % e)
 
     def check_forwarding(self, ports, nic, testerports=[None, None], pktSize=64, received=True):
         self.send_packet(ports[0], ports[1], self.nic, testerports[1], pktSize, received)
@@ -84,7 +94,8 @@ class TestQueueStartStop(TestCase):
             txitf = self.tester.get_interface(self.tester.get_local_port(txPort))
         else:
             itf = testerports
-        mac = self.dut.get_mac_address(txPort)
+        smac = self.tester.get_mac(self.tester.get_local_port(txPort))
+        dmac = self.dut.get_mac_address(txPort)
 
         self.tester.scapy_background()
         self.tester.scapy_append('p=sniff(iface="%s",count=1,timeout=5)' % rxitf)
@@ -94,7 +105,7 @@ class TestQueueStartStop(TestCase):
 
         pktlen = pktSize - 14
         padding = pktlen - 20
-        self.tester.scapy_append('sendp([Ether(dst="%s")/IP()/Raw(load="P"*%s)], iface="%s")' % (mac, padding, txitf))
+        self.tester.scapy_append('sendp([Ether(src="%s", dst="%s")/IP()/Raw(load="P"*%s)], iface="%s")' % (smac, dmac, padding, txitf))
 
         self.tester.scapy_execute()
         time.sleep(3)
@@ -105,102 +116,89 @@ class TestQueueStartStop(TestCase):
         else:
             self.verify('PPP' not in out, "stop queue failed")
 
-    def add_code_to_dpdk(self, file_name, standard_row, add_rows, offset=0):
+    def patch_hotfix_dpdk(self, patch_dir, on = True):
         """
-        this function for add code in dpdk src code file.
-        file: source code full path
-        standard_row: standard row for find the place that add code
-        offset: need offset row number
-        add_rows:add source code
-
-        return: source code lines
+        This function is to apply or remove patch for dpdk.
+        patch_dir: the abs path of the patch
+        on: True for apply, False for remove
         """
-        file_handel = open(file_name, "r+w")
-        source_lines = file_handel.readlines()
-
-        write_lines = source_lines
-
-        # get the index that need add code
-        index = -1
-        for line in write_lines:
-            if standard_row in line:
-                index = write_lines.index(line) + offset
-                break
-
-        # add source code and re-write the file
-        # print write_lines,index
-        for line in add_rows:
-            write_lines.insert(index, line)
-            index += 1
-        # print write_lines
-        file_handel.seek(file_handel.tell() * -1, 2)
-        file_handel.writelines(write_lines)
-        file_handel.close()
-
-        return source_lines
+        try:
+            if on:
+                self.dut.send_expect("patch -p0 < %s" % patch_dir, "#")
+            else:
+                self.dut.send_expect("patch -p0 -R < %s" % patch_dir, "#")
+        except Exception, e:
+            raise ValueError("patch_hotfix_dpdk failure: %s" % e)
 
     def test_queue_start_stop(self):
         """
-        queue start/stop test for fortville nic
+        queue start/stop test
         """
-        self.dut.session.copy_file_from(r'%s/app/test-pmd/macfwd.c' % self.dut.base_dir)
-        fwdmac_file = 'macfwd.c'
-        printf_lines = ['printf("ports %u queue %u revice %u packages", fs->rx_port, fs->rx_queue, nb_rx);\n', r'printf("\n");',"\n"]
-        sourcelines = self.add_code_to_dpdk(fwdmac_file, r'(unlikely(nb_rx == 0)', printf_lines, 2)
-        self.dut.session.copy_file_to(fwdmac_file)
-        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-pmd/macfwd.c' % self.dut.base_dir, "#")
-        self.dut.build_dpdk_apps('./app/test-pmd')
-
-        self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --portmask=0x3", "testpmd>", 120)
-        self.dut.send_expect("set fwd mac", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic)
-
-        # stop rx queue test
-        print "test stop rx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic, received=False)
-
-        # start rx queue test
-        print "test start rx queue stop tx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
-        self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic, received=False)
-        out = self.dut.send_expect("\n", "testpmd>")
-        # print out
-        self.verify("ports 0 queue 0 revice 1 packages" in out, "start queue revice package failed")
-
-        # start tx queue test
-        print "test start rx and tx queue"
-        self.dut.send_expect("stop", "testpmd>")
-        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
-        self.dut.send_expect("port 1 txq 0 start", "testpmd>")
-        self.dut.send_expect("start", "testpmd>")
-        self.check_forwarding([0, 1], self.nic)
-        self.dut.send_expect("quit", "testpmd>")
-
-        # recover testpmd changed
-        file_handel = open(fwdmac_file, "w")
-        file_handel.writelines(sourcelines)
-        file_handel.close()
-        self.dut.session.copy_file_to(fwdmac_file)
-        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-pmd/macfwd.c' % self.dut.base_dir, "#")
+        #dpdk start
+        try:
+            self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --portmask=0x3", "testpmd>", 120)
+            self.dut.send_expect("set fwd mac", "testpmd>")
+            self.dut.send_expect("set promisc all off", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic)
+        except Exception, e:
+            raise IOError("dpdk start and first forward failure: %s" % e)
+
+            # stop rx queue test
+        try:
+            print "test stop rx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic, received=False)
+
+            # start rx queue test
+            print "test start rx queue stop tx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
+            self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic, received=False)
+            out = self.dut.send_expect("\n", "testpmd>")
+        except Exception, e:
+            raise IOError("queue start/stop forward failure: %s" % e)
+
+        self.verify("ports 0 queue 0 receive 1 packages" in out, "start queue revice package failed, out = %s"%out)
+
+        try:
+            # start tx queue test
+            print "test start rx and tx queue"
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("port 1 txq 0 start", "testpmd>")
+            self.dut.send_expect("start", "testpmd>")
+            self.check_forwarding([0, 1], self.nic)
+        except Exception, e:
+            raise IOError("queue start/stop forward failure: %s" % e)
 
     def tear_down(self):
         """
         Run after each test case.
         """
+        patch_dst = "/tmp/"
+
+        try:
+            self.dut.send_expect("stop", "testpmd>")
+            self.dut.send_expect("quit", "testpmd>")
+        except:
+            print "Failed to quit testpmd"
+
         self.dut.kill_all()
 
+        try:
+            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", False)
+        except Exception, e:
+            print "patch_hotfix_dpdk remove failure :%s" %e
+
     def tear_down_all(self):
         """
         Run after each test suite.
         """
         self.dut.kill_all()
-        #self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
-        #self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
-        #self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
+        self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
-- 
1.9.3

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

* Re: [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case
  2015-07-07  6:30 ` [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case Michael Qiu
@ 2015-07-08  5:18   ` Liu, Yong
  0 siblings, 0 replies; 4+ messages in thread
From: Liu, Yong @ 2015-07-08  5:18 UTC (permalink / raw)
  To: Qiu, Michael, dts

Thanks, applied into 1.1 branch.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Michael Qiu
> Sent: Tuesday, July 07, 2015 2:31 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case
> 
> queue_start_stop case does not support RRC yet, this patch
> is to enbale this.
> 
> Also change the patch file to change to source code.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  v2 --> v1
>       Add portmask to testpmd commanline
> 
>  dep/macfwd_log.patch                |  10 +++
>  tests/TestSuite_queue_start_stop.py | 166 ++++++++++++++++++-------------
> -----
>  2 files changed, 92 insertions(+), 84 deletions(-)
>  create mode 100644 dep/macfwd_log.patch
> 
> diff --git a/dep/macfwd_log.patch b/dep/macfwd_log.patch
> new file mode 100644
> index 0000000..0f657f8
> --- /dev/null
> +++ b/dep/macfwd_log.patch
> @@ -0,0 +1,10 @@
> +--- app/test-pmd/macfwd.c.org	2015-07-02 10:51:12.821246109 +0800
> ++++ app/test-pmd/macfwd.c	2015-07-02 10:50:11.343243319 +0800
> +@@ -102,6 +102,7 @@
> + 				 nb_pkt_per_burst);
> + 	if (unlikely(nb_rx == 0))
> + 		return;
> ++	printf("ports %u queue %u receive %u packages\n", fs->rx_port, fs-
> >rx_queue, nb_rx);
> +
> + #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
> + 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
> diff --git a/tests/TestSuite_queue_start_stop.py
> b/tests/TestSuite_queue_start_stop.py
> index 1c4b7b7..d62cc8c 100644
> --- a/tests/TestSuite_queue_start_stop.py
> +++ b/tests/TestSuite_queue_start_stop.py
> @@ -44,6 +44,7 @@ import re
>  import os
>  from test_case import TestCase
>  from pmd_output import PmdOutput
> +from settings import FOLDERS
> 
>  #
>  #
> @@ -69,7 +70,16 @@ class TestQueueStartStop(TestCase):
>          """
>          Run before each test case.
>          """
> -        pass
> +        patch_file = FOLDERS["Depends"] + r'/macfwd_log.patch'
> +        patch_dst = "/tmp/"
> +
> +        # dpdk patch and build
> +        try:
> +            self.dut.session.copy_file_to(patch_file, patch_dst)
> +            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", True)
> +            self.dut.build_dpdk_apps('./app/test-pmd')
> +        except Exception, e:
> +            raise IOError("dpdk setup failure: %s" % e)
> 
>      def check_forwarding(self, ports, nic, testerports=[None, None],
> pktSize=64, received=True):
>          self.send_packet(ports[0], ports[1], self.nic, testerports[1],
> pktSize, received)
> @@ -84,7 +94,8 @@ class TestQueueStartStop(TestCase):
>              txitf =
> self.tester.get_interface(self.tester.get_local_port(txPort))
>          else:
>              itf = testerports
> -        mac = self.dut.get_mac_address(txPort)
> +        smac = self.tester.get_mac(self.tester.get_local_port(txPort))
> +        dmac = self.dut.get_mac_address(txPort)
> 
>          self.tester.scapy_background()
>          self.tester.scapy_append('p=sniff(iface="%s",count=1,timeout=5)' %
> rxitf)
> @@ -94,7 +105,7 @@ class TestQueueStartStop(TestCase):
> 
>          pktlen = pktSize - 14
>          padding = pktlen - 20
> -
> self.tester.scapy_append('sendp([Ether(dst="%s")/IP()/Raw(load="P"*%s)],
> iface="%s")' % (mac, padding, txitf))
> +        self.tester.scapy_append('sendp([Ether(src="%s",
> dst="%s")/IP()/Raw(load="P"*%s)], iface="%s")' % (smac, dmac, padding,
> txitf))
> 
>          self.tester.scapy_execute()
>          time.sleep(3)
> @@ -105,102 +116,89 @@ class TestQueueStartStop(TestCase):
>          else:
>              self.verify('PPP' not in out, "stop queue failed")
> 
> -    def add_code_to_dpdk(self, file_name, standard_row, add_rows,
> offset=0):
> +    def patch_hotfix_dpdk(self, patch_dir, on = True):
>          """
> -        this function for add code in dpdk src code file.
> -        file: source code full path
> -        standard_row: standard row for find the place that add code
> -        offset: need offset row number
> -        add_rows:add source code
> -
> -        return: source code lines
> +        This function is to apply or remove patch for dpdk.
> +        patch_dir: the abs path of the patch
> +        on: True for apply, False for remove
>          """
> -        file_handel = open(file_name, "r+w")
> -        source_lines = file_handel.readlines()
> -
> -        write_lines = source_lines
> -
> -        # get the index that need add code
> -        index = -1
> -        for line in write_lines:
> -            if standard_row in line:
> -                index = write_lines.index(line) + offset
> -                break
> -
> -        # add source code and re-write the file
> -        # print write_lines,index
> -        for line in add_rows:
> -            write_lines.insert(index, line)
> -            index += 1
> -        # print write_lines
> -        file_handel.seek(file_handel.tell() * -1, 2)
> -        file_handel.writelines(write_lines)
> -        file_handel.close()
> -
> -        return source_lines
> +        try:
> +            if on:
> +                self.dut.send_expect("patch -p0 < %s" % patch_dir, "#")
> +            else:
> +                self.dut.send_expect("patch -p0 -R < %s" % patch_dir, "#")
> +        except Exception, e:
> +            raise ValueError("patch_hotfix_dpdk failure: %s" % e)
> 
>      def test_queue_start_stop(self):
>          """
> -        queue start/stop test for fortville nic
> +        queue start/stop test
>          """
> -        self.dut.session.copy_file_from(r'%s/app/test-pmd/macfwd.c' %
> self.dut.base_dir)
> -        fwdmac_file = 'macfwd.c'
> -        printf_lines = ['printf("ports %u queue %u revice %u packages",
> fs->rx_port, fs->rx_queue, nb_rx);\n', r'printf("\n");',"\n"]
> -        sourcelines = self.add_code_to_dpdk(fwdmac_file,
> r'(unlikely(nb_rx == 0)', printf_lines, 2)
> -        self.dut.session.copy_file_to(fwdmac_file)
> -        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-
> pmd/macfwd.c' % self.dut.base_dir, "#")
> -        self.dut.build_dpdk_apps('./app/test-pmd')
> -
> -        self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --
> portmask=0x3", "testpmd>", 120)
> -        self.dut.send_expect("set fwd mac", "testpmd>")
> -        self.dut.send_expect("start", "testpmd>")
> -        self.check_forwarding([0, 1], self.nic)
> -
> -        # stop rx queue test
> -        print "test stop rx queue"
> -        self.dut.send_expect("stop", "testpmd>")
> -        self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
> -        self.dut.send_expect("start", "testpmd>")
> -        self.check_forwarding([0, 1], self.nic, received=False)
> -
> -        # start rx queue test
> -        print "test start rx queue stop tx queue"
> -        self.dut.send_expect("stop", "testpmd>")
> -        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
> -        self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
> -        self.dut.send_expect("start", "testpmd>")
> -        self.check_forwarding([0, 1], self.nic, received=False)
> -        out = self.dut.send_expect("\n", "testpmd>")
> -        # print out
> -        self.verify("ports 0 queue 0 revice 1 packages" in out, "start
> queue revice package failed")
> -
> -        # start tx queue test
> -        print "test start rx and tx queue"
> -        self.dut.send_expect("stop", "testpmd>")
> -        self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
> -        self.dut.send_expect("port 1 txq 0 start", "testpmd>")
> -        self.dut.send_expect("start", "testpmd>")
> -        self.check_forwarding([0, 1], self.nic)
> -        self.dut.send_expect("quit", "testpmd>")
> -
> -        # recover testpmd changed
> -        file_handel = open(fwdmac_file, "w")
> -        file_handel.writelines(sourcelines)
> -        file_handel.close()
> -        self.dut.session.copy_file_to(fwdmac_file)
> -        self.dut.send_expect('scp  /root/macfwd.c %s/app/test-
> pmd/macfwd.c' % self.dut.base_dir, "#")
> +        #dpdk start
> +        try:
> +            self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -
> i --portmask=0x3", "testpmd>", 120)
> +            self.dut.send_expect("set fwd mac", "testpmd>")
> +            self.dut.send_expect("set promisc all off", "testpmd>")
> +            self.dut.send_expect("start", "testpmd>")
> +            self.check_forwarding([0, 1], self.nic)
> +        except Exception, e:
> +            raise IOError("dpdk start and first forward failure: %s" % e)
> +
> +            # stop rx queue test
> +        try:
> +            print "test stop rx queue"
> +            self.dut.send_expect("stop", "testpmd>")
> +            self.dut.send_expect("port 0 rxq 0 stop", "testpmd>")
> +            self.dut.send_expect("start", "testpmd>")
> +            self.check_forwarding([0, 1], self.nic, received=False)
> +
> +            # start rx queue test
> +            print "test start rx queue stop tx queue"
> +            self.dut.send_expect("stop", "testpmd>")
> +            self.dut.send_expect("port 0 rxq 0 start", "testpmd>")
> +            self.dut.send_expect("port 1 txq 0 stop", "testpmd>")
> +            self.dut.send_expect("start", "testpmd>")
> +            self.check_forwarding([0, 1], self.nic, received=False)
> +            out = self.dut.send_expect("\n", "testpmd>")
> +        except Exception, e:
> +            raise IOError("queue start/stop forward failure: %s" % e)
> +
> +        self.verify("ports 0 queue 0 receive 1 packages" in out, "start
> queue revice package failed, out = %s"%out)
> +
> +        try:
> +            # start tx queue test
> +            print "test start rx and tx queue"
> +            self.dut.send_expect("stop", "testpmd>")
> +            self.dut.send_expect("port 1 txq 0 start", "testpmd>")
> +            self.dut.send_expect("start", "testpmd>")
> +            self.check_forwarding([0, 1], self.nic)
> +        except Exception, e:
> +            raise IOError("queue start/stop forward failure: %s" % e)
> 
>      def tear_down(self):
>          """
>          Run after each test case.
>          """
> +        patch_dst = "/tmp/"
> +
> +        try:
> +            self.dut.send_expect("stop", "testpmd>")
> +            self.dut.send_expect("quit", "testpmd>")
> +        except:
> +            print "Failed to quit testpmd"
> +
>          self.dut.kill_all()
> 
> +        try:
> +            self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", False)
> +        except Exception, e:
> +            print "patch_hotfix_dpdk remove failure :%s" %e
> +
>      def tear_down_all(self):
>          """
>          Run after each test suite.
>          """
>          self.dut.kill_all()
> -        #self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
> -        #self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
> -        #self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
> +        self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#")
> +        self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#")
> +        self.dut.send_expect("rm -rf ./app/test-pmd/build", "#")
> --
> 1.9.3

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

end of thread, other threads:[~2015-07-08  5:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06  9:19 [dts] [PATCH] tests: Add RRC support for queue_start_stop case Michael Qiu
2015-07-06  9:28 ` [dts] [PATCH] Add folder Depends in settings Michael Qiu
2015-07-07  6:30 ` [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case Michael Qiu
2015-07-08  5:18   ` 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).