From: Feng Yang <[email protected]>

1. Stop tcpdump by close()
Current we stop tcpdump by sending SIGSTOP to tcpdump process,
and do not do any clean up. e.g. release the lock.  Then send
SIGCOT to tcpdump process again. But if we fail continue tcpdump
process. Framework will think tcpdump still work and do not
start a new one in next case.
Then autotest could not refresh address_cache after guest's ip changed
So directly close() tcpdump, It will be started at the beginning of
next case.

2. kill netserver properly
netperf test doesn't handle all exceptions correctly, some exception
cause netserver isn't be killed, and the following netperf test will
fail. This patch will fix this problem.

Signed-off-by: Qingtang Zhou <[email protected]>
Signed-off-by: Feng Yang <[email protected]>
---
 client/virt/tests/netperf.py |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/client/virt/tests/netperf.py b/client/virt/tests/netperf.py
index 5fd1b25..8a80d13 100644
--- a/client/virt/tests/netperf.py
+++ b/client/virt/tests/netperf.py
@@ -45,14 +45,11 @@ def run_netperf(test, params, env):
     session_serial.cmd(setup_cmd % "/tmp", timeout=200)
     session_serial.cmd(params.get("netserver_cmd") % "/tmp")
 
-    tcpdump = env.get("tcpdump")
-    pid = None
-    if tcpdump:
+    if "tcpdump" in env and env["tcpdump"].is_alive():
         # Stop the background tcpdump process
         try:
-            pid = int(utils.system_output("pidof tcpdump"))
             logging.debug("Stopping the background tcpdump")
-            os.kill(pid, signal.SIGSTOP)
+            env["tcpdump"].close()
         except:
             pass
 
@@ -101,11 +98,9 @@ def run_netperf(test, params, env):
                 if b.is_alive():
                     completed = False
     finally:
-        for b in bg:
-            if b:
-                b.join()
-        session_serial.cmd_output("killall netserver")
-        if tcpdump and pid:
-            logging.debug("Resuming the background tcpdump")
-            logging.info("pid is %s" % pid)
-            os.kill(pid, signal.SIGCONT)
+        try:
+            for b in bg:
+                if b:
+                    b.join()
+        finally:
+            session_serial.cmd_output("killall netserver")
-- 
1.7.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to