test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yu Jiang <yux.jiang@intel.com>
To: lijuan.tu@intel.com, dts@dpdk.org
Cc: Yu Jiang <yux.jiang@intel.com>
Subject: [dts][PATCH V1] tests/vm_hotplug: optimize script by using existed function
Date: Fri, 25 Feb 2022 18:09:13 +0000	[thread overview]
Message-ID: <20220225180913.2691504-1-yux.jiang@intel.com> (raw)

1, use existed function wait_link_status_up to check link's status.
2, use new method: is_interface_up to to ensure iface's link status before send_packets

Signed-off-by: Yu Jiang <yux.jiang@intel.com>
---
 tests/TestSuite_vm_hotplug.py | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/tests/TestSuite_vm_hotplug.py b/tests/TestSuite_vm_hotplug.py
index c3695b68..0b4c3476 100644
--- a/tests/TestSuite_vm_hotplug.py
+++ b/tests/TestSuite_vm_hotplug.py
@@ -237,28 +237,16 @@ class TestVmHotplug(TestCase):
             result.append(cap_num[0])
         return result
 
-    def check_link_status(self, vm_info):
-        loop = 1
-        while (loop <= 3):
-            out = vm_info.execute_cmd("show port info all", "testpmd> ", 120)
-            port_status = re.findall("Link\s*status:\s*([a-z]*)", out)
-            if ("down" not in port_status):
-                break
-            time.sleep(3)
-            loop += 1
-        self.verify("down" not in port_status, "port can not up after start")
-
     def verify_rxtx_only(self):
         # rxonly
         self.vm_testpmd.execute_cmd('set fwd rxonly')
         self.vm_testpmd.execute_cmd('set verbose 1')
         self.vm_testpmd.execute_cmd('port start all')
         self.vm_testpmd.execute_cmd('start')
-        self.check_link_status(self.vm_testpmd)
+        self.vm_testpmd.wait_link_status_up('all')
 
         self.send_packet()
-        out = self.vm0_dut.get_session_output()
-        time.sleep(1)
+        out = self.vm0_dut.get_session_output(timeout=20)
         self.verify(self.vf0_mac in out, 'vf0 receive packet fail')
         if self.device == 2:
             self.verify(self.vf1_mac in out, 'vf1 receive packet fail')
@@ -271,7 +259,7 @@ class TestVmHotplug(TestCase):
             iface_list.append(self.tester_intf1)
         self.start_tcpdump(iface_list)
         self.vm_testpmd.execute_cmd('start')
-        time.sleep(1)
+        self.vm_testpmd.wait_link_status_up('all')
         self.vm_testpmd.execute_cmd('stop')
         out = self.get_tcpdump_package(iface_list)
         for pkt_num in out:
@@ -303,6 +291,9 @@ class TestVmHotplug(TestCase):
         time.sleep(1)
 
     def send_packet(self):
+        # check tester's link status before send packet
+        for iface in [self.tester_intf0, self.tester_intf1]:
+            self.verify(self.tester.is_interface_up(intf=iface), "Wrong link status, should be up")
         self.vf0_mac = self.vm_testpmd.get_port_mac(0)
         pkts = []
         pkt1 = r'sendp([Ether(dst="%s")/IP()/UDP()/Raw(load="P"*26)], iface="%s")' % (self.vf0_mac, self.tester_intf)
-- 
2.25.1


             reply	other threads:[~2022-02-25 10:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 18:09 Yu Jiang [this message]
2022-03-15  3:22 ` Tu, Lijuan

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=20220225180913.2691504-1-yux.jiang@intel.com \
    --to=yux.jiang@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    /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).