diff mbox

tests: Fix parse process memory

Message ID 20170718064435.32672-1-chenr.fnst@cn.fujitsu.com
State Changes Requested
Headers show

Commit Message

Chen Rong July 18, 2017, 6:44 a.m. UTC
Ingore processes with name that contains 'sudo',
Don't throw the exception when read memory failed.

Signed-off-by: Chen Rong <chenr.fnst@cn.fujitsu.com>
---
 tests/hwsim/test_ap_psk.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Jouni Malinen July 18, 2017, 10:46 a.m. UTC | #1
On Tue, Jul 18, 2017 at 02:44:35PM +0800, Chen Rong wrote:
> Ingore processes with name that contains 'sudo',
> Don't throw the exception when read memory failed.

Could you please provide more details on why these changes are needed?
What kind of test environment are you using? I have not seen either of
these changes being needed in anything I've tested with so far.
Chen Rong July 19, 2017, 1:07 a.m. UTC | #2
I use "sudo ./run-tests.py sae_key_lifetime_in_memory" to test the case.

It tells me that "Skip test case: Password not found while associated".

I found that find_wpas_process() return the process which contains 
"sudo", I think it's

not the right process. so I skip "sudo" and ignore the exception(exist 
in my environment),

then I can get the password from memory.


在 2017年07月18日 18:46, Jouni Malinen 写道:
> On Tue, Jul 18, 2017 at 02:44:35PM +0800, Chen Rong wrote:
>> Ingore processes with name that contains 'sudo',
>> Don't throw the exception when read memory failed.
> Could you please provide more details on why these changes are needed?
> What kind of test environment are you using? I have not seen either of
> these changes being needed in anything I've tested with so far.
>
diff mbox

Patch

diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py
index 21523e0..4e6bdd3 100644
--- a/tests/hwsim/test_ap_psk.py
+++ b/tests/hwsim/test_ap_psk.py
@@ -1701,6 +1701,8 @@  def find_wpas_process(dev):
     ifname = dev.ifname
     err, data = dev.cmd_execute(['ps', 'ax'])
     for l in data.splitlines():
+        if "sudo" in l:
+            continue
         if "wpa_supplicant" not in l:
             continue
         if "-i" + ifname not in l:
@@ -1729,11 +1731,14 @@  def read_process_memory(pid, key=None):
             for name in [ "[heap]", "[stack]" ]:
                 if name in l:
                     logger.info("%s 0x%x-0x%x is at %d-%d" % (name, start, end, len(buf), len(buf) + (end - start)))
-            mem.seek(start)
-            data = mem.read(end - start)
-            buf += data
-            if key and key in data:
-                logger.info("Key found in " + l)
+            try:
+                mem.seek(start)
+                data = mem.read(end - start)
+                buf += data
+                if key and key in data:
+                    logger.info("Key found in " + l)
+            except Exception as e:
+                continue
     logger.info("Total process memory read: %d bytes" % len(buf))
     return buf