From: Ondrej Lichtner olichtne@redhat.com
We shouldn't parse the netperf client output if the return code is non-zero. This patch also adds an additional check to the parse_output method that ensures that if the regular expression doesn't match the parsed output will be 0 so that the tester is notified of this problem.
Fixes #119
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- test_modules/Netperf.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py index 59a184c..ab4bafe 100644 --- a/test_modules/Netperf.py +++ b/test_modules/Netperf.py @@ -100,7 +100,10 @@ class Netperf(TestGeneric): pattern_sctp = "\d+\s+\d+\s+\d+\s+\d+.\d+\s+(\d+(.\d+){0,1})" r2 = re.search(pattern_sctp, output.lower())
- rate_in_kb = float(r2.group(1)) + if r2 is None: + rate_in_kb = 0.0 + else: + rate_in_kb = float(r2.group(1))
return {"rate": rate_in_kb*1000, "unit": "bps"} @@ -178,13 +181,15 @@ class Netperf(TestGeneric): logging.info("Netperf starting run %d" % i) client = ShellProcess(cmd) try: - rv += client.wait() + ret_code = client.wait() + rv += ret_code except OSError as e: if e.errno == errno.EINTR: client.kill() - output = client.read_nonblocking() - results.append(self._parse_output(output)) - rates.append(results[-1]["rate"]) + if ret_code == 0: + output = client.read_nonblocking() + results.append(self._parse_output(output)) + rates.append(results[-1]["rate"])
if runs > 1: res_data["results"] = results