commit efcfd32f0be5fd6ad84b2ddfcec1f789021c5eec
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Fri Jun 1 16:29:32 2012 +0200
Interrupt exception handler in Iperf test
If TestIperf is interrupted with kill/intr signal it does not collect
the ShellProcess data. I added signal handler for both client and server
part so that in case of receiving interrupt exception the iperf process'
statistics output will be collected and available for inspection at end
of testing.
Tests/TestIperf.py | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/Tests/TestIperf.py b/Tests/TestIperf.py
index c65ed2d..07aaa98 100644
--- a/Tests/TestIperf.py
+++ b/Tests/TestIperf.py
@@ -11,6 +11,7 @@ from Common.TestsCommon import TestGeneric
from Common.ExecCmd import exec_cmd
from Common.ShellProcess import ShellProcess
import time
+import errno
class TestIperf(TestGeneric):
def _install_iperf(self):
@@ -37,7 +38,12 @@ class TestIperf(TestGeneric):
def run_client(self, cmd):
client = ShellProcess(cmd)
- client.wait()
+ try:
+ client.wait()
+ except OSError as e:
+ # we got interrupted, let's gather data
+ if e.errno == errno.EINTR:
+ client.kill()
client.read_nonblocking()
def run_server(self, cmd):
@@ -48,7 +54,13 @@ class TestIperf(TestGeneric):
server.read_nonblocking()
server.kill()
else:
- server.wait()
+ try:
+ server.wait()
+ except OSError as e:
+ if e.errno == errno.EINTR:
+ server.kill()
+
+ server.read_nonblocking()
def run(self):
self._keep_server_running = True
Show replies by date