[V1] framework/*: modify command line that list opened files

Message ID 20220518054636.1416-1-junx.dong@intel.com (mailing list archive)
State Accepted
Headers
Series [V1] framework/*: modify command line that list opened files |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-suite-test success Testing OK

Commit Message

Jun Dong May 18, 2022, 5:46 a.m. UTC
  In some framework scenario, needing to use lsof command to query opened 
files that occupied specific ports and to do something about the it. now
add -n options to the command to skip reverse resolution of domain name
when querying to avoid timeout in network offline env.

Signed-off-by: Jun Dong <junx.dong@intel.com>
---
 framework/dut.py      | 2 +-
 framework/qemu_kvm.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Tu, Lijuan May 18, 2022, 2:08 p.m. UTC | #1
On Wed, 18 May 2022 13:46:36 +0800, Jun Dong <junx.dong@intel.com> wrote:
> In some framework scenario, needing to use lsof command to query opened 
> files that occupied specific ports and to do something about the it. now
> add -n options to the command to skip reverse resolution of domain name
> when querying to avoid timeout in network offline env.
> 
> Signed-off-by: Jun Dong <junx.dong@intel.com>


Applied, thanks
  

Patch

diff --git a/framework/dut.py b/framework/dut.py
index 6a8fc957..82b8fb01 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -1345,7 +1345,7 @@  class Dut(Crb):
                 port.enable_ipv6()
 
     def check_port_occupied(self, port):
-        out = self.alt_session.send_expect("lsof -i:%d" % port, "# ")
+        out = self.alt_session.send_expect("lsof -n -i:%d" % port, "# ")
         if out == "":
             return False
         else:
diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 5615263b..b617c389 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -1115,7 +1115,7 @@  class QEMUKvm(VirtBase):
         if connected failed will return None
         """
         shell_reg = r"(.*)# "
-        scan_cmd = "lsof -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
+        scan_cmd = "lsof -n -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
 
         try:
             # assume serial is not connect
@@ -1910,7 +1910,7 @@  class QEMUKvm(VirtBase):
                 pass
             self.host_dut.send_expect("", "# ")
         elif self.control_type == "telnet":
-            scan_cmd = "lsof -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
+            scan_cmd = "lsof -n -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
             proc_info = self.host_dut.send_expect(scan_cmd, "#")
             try:
                 pid = int(proc_info)