summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobbie Harwood <rharwood@redhat.com>2016-12-07 20:15:14 +0000
committerSimo Sorce <simo@redhat.com>2017-01-12 11:52:20 -0500
commit422e51232422b5604bf3c121c4771e708cdb5774 (patch)
treef1cb2b931261bff68a852422fb9808edff278282
parent75cef8a29218ec6f55a979ce9e30535249d1dd3d (diff)
downloadgss-proxy-422e51232422b5604bf3c121c4771e708cdb5774.tar.gz
gss-proxy-422e51232422b5604bf3c121c4771e708cdb5774.tar.xz
gss-proxy-422e51232422b5604bf3c121c4771e708cdb5774.zip
Separate out test return checking logic
Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
-rw-r--r--proxy/tests/t_acquire.py7
-rwxr-xr-xproxy/tests/t_basic.py31
-rw-r--r--proxy/tests/t_impersonate.py7
-rw-r--r--proxy/tests/t_interpose.py3
-rw-r--r--proxy/tests/testlib.py8
5 files changed, 17 insertions, 39 deletions
diff --git a/proxy/tests/t_acquire.py b/proxy/tests/t_acquire.py
index a4c7498..f0cc2d7 100644
--- a/proxy/tests/t_acquire.py
+++ b/proxy/tests/t_acquire.py
@@ -28,9 +28,4 @@ def run(testdir, env, conf, expected_failure=False):
except subprocess.TimeoutExpired:
# p1.returncode is set to None here
pass
- if p1.returncode != 0 and not expected_failure:
- print_failure("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Acquire test returned %s" % str(p1.returncode))
- else:
- print_success("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Acquire test returned %s" % str(p1.returncode))
+ print_return(p1.returncode, "Acquire", expected_failure)
diff --git a/proxy/tests/t_basic.py b/proxy/tests/t_basic.py
index 5ab2477..f221e6f 100755
--- a/proxy/tests/t_basic.py
+++ b/proxy/tests/t_basic.py
@@ -43,31 +43,14 @@ def run(testdir, env, conf, expected_failure=False):
try:
p1.wait(30)
+ p2.wait(30)
except subprocess.TimeoutExpired:
- # p1.returncode is set to None here
+ # {p1,p2}.returncode are set to None here
pass
- if p1.returncode != 0 and not expected_failure:
- print_failure("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Init test returned %s" % str(p1.returncode))
- try:
- os.killpg(p2.pid, signal.SIGTERM)
- except OSError:
- pass
- else:
- print_success("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Init test returned %s" % str(p1.returncode))
+ print_return(p1.returncode, "Init", expected_failure)
+ print_return(p2.returncode, "Accept", expected_failure)
try:
- p2.wait(30)
- except subprocess.TimeoutExpired:
- # p2.returncode is set to None here
+ os.killpg(p1.pid, signal.SIGTERM)
+ os.killpg(p2.pid, signal.SIGTERM)
+ except OSError:
pass
- if p2.returncode != 0 and not expected_failure:
- print_failure("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Accept test returned %s" % str(p2.returncode))
- try:
- os.killpg(p1.pid, signal.SIGTERM)
- except OSError:
- pass
- else:
- print_success("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Accept test returned %s" % str(p2.returncode))
diff --git a/proxy/tests/t_impersonate.py b/proxy/tests/t_impersonate.py
index ea7c462..92a1d1d 100644
--- a/proxy/tests/t_impersonate.py
+++ b/proxy/tests/t_impersonate.py
@@ -27,9 +27,4 @@ def run(testdir, env, conf, expected_failure=False):
except subprocess.TimeoutExpired:
# p1.returncode is set to None here
pass
- if p1.returncode != 0 and not expected_failure:
- print_failure("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Impersonate test returned %s" % str(p1.returncode))
- else:
- print_success("SUCCESS" if p1.returncode == 0 else "FAILED",
- "Impersonate test returned %s" % str(p1.returncode))
+ print_return(p1.returncode, "Impersonate", expected_failure)
diff --git a/proxy/tests/t_interpose.py b/proxy/tests/t_interpose.py
index 82557c0..06a631b 100644
--- a/proxy/tests/t_interpose.py
+++ b/proxy/tests/t_interpose.py
@@ -24,5 +24,4 @@ def run(testdir, env, conf):
stdout=logfile, stderr=logfile,
env=ienv)
itest.wait()
- print_success("SUCCESS" if itest.returncode == 0 else "FAILED",
- "Interpose test returned %s" % str(itest.returncode))
+ print_return(itest.returncode, "Interpose", False)
diff --git a/proxy/tests/testlib.py b/proxy/tests/testlib.py
index 902585e..01ffdc8 100644
--- a/proxy/tests/testlib.py
+++ b/proxy/tests/testlib.py
@@ -37,7 +37,6 @@ except ImportError:
def print_keyed(status, key, text, io):
print("%s %s" % (format_key(status, key), text), file=io)
-
def print_success(key, text, io=sys.stderr):
print_keyed("success", key, text, io)
@@ -49,6 +48,13 @@ def print_failure(key, text, io=sys.stderr):
def print_warning(key, text, io=sys.stderr):
print_keyed("other", key, text, io)
+def print_return(ret, name, expected_failure):
+ if ret != 0 and not expected_failure:
+ print_failure("SUCCESS" if ret == 0 else "FAILED",
+ "%s test returned %s" % (name, str(ret)))
+ else:
+ print_success("SUCCESS" if ret == 0 else "FAILED",
+ "%s test returned %s" % (name, str(ret)))
WRAP_HOSTNAME = "kdc.gssproxy.dev"