From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 1B7F5FFA for ; Mon, 6 Jul 2015 11:19:24 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 06 Jul 2015 02:19:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,414,1432623600"; d="scan'208";a="723557086" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 06 Jul 2015 02:19:24 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t669JLNP030624; Mon, 6 Jul 2015 17:19:21 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t669JJ00022034; Mon, 6 Jul 2015 17:19:21 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t669JJvW022030; Mon, 6 Jul 2015 17:19:19 +0800 From: Michael Qiu To: dts@dpdk.org Date: Mon, 6 Jul 2015 17:19:18 +0800 Message-Id: <1436174358-21999-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] tests: Add RRC support for queue_start_stop case 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: Mon, 06 Jul 2015 09:19:25 -0000 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 --- 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