summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/conftest.py11
-rw-r--r--test/test_go_isolation.py2
-rw-r--r--test/test_java_isolation_rootfs.py10
-rw-r--r--test/test_python_application.py4
-rw-r--r--test/test_static.py3
-rw-r--r--test/test_tls.py4
-rw-r--r--test/unit/applications/lang/go.py6
-rw-r--r--test/unit/applications/lang/java.py8
-rw-r--r--test/unit/check/go.py3
-rw-r--r--test/unit/http.py10
10 files changed, 52 insertions, 9 deletions
diff --git a/test/conftest.py b/test/conftest.py
index 9aaf7640..3edc471d 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -215,7 +215,7 @@ def run(request):
# print unit.log in case of error
- if request.node.rep_call.failed:
+ if hasattr(request.node, 'rep_call') and request.node.rep_call.failed:
_print_log()
# remove unit.log
@@ -284,6 +284,11 @@ def unit_stop():
retcode = p.wait(15)
if retcode:
return 'Child process terminated with code ' + str(retcode)
+
+ except KeyboardInterrupt:
+ p.kill()
+ raise
+
except:
p.kill()
return 'Could not terminate unit'
@@ -403,6 +408,10 @@ def waitforsocket(port):
sock.connect(('127.0.0.1', port))
ret = True
break
+
+ except KeyboardInterrupt:
+ raise
+
except:
sock.close()
time.sleep(0.1)
diff --git a/test/test_go_isolation.py b/test/test_go_isolation.py
index c68925b9..e3a0a210 100644
--- a/test/test_go_isolation.py
+++ b/test/test_go_isolation.py
@@ -36,7 +36,7 @@ class TestGoIsolation(TestApplicationGo):
try:
nogroup_gid = grp.getgrnam('nogroup').gr_gid
nogroup = 'nogroup'
- except:
+ except KeyError:
nogroup_gid = grp.getgrnam('nobody').gr_gid
nogroup = 'nobody'
diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py
index 4f9e9834..02d35a62 100644
--- a/test/test_java_isolation_rootfs.py
+++ b/test/test_java_isolation_rootfs.py
@@ -31,8 +31,11 @@ class TestJavaIsolationRootfs(TestApplicationJava):
process.communicate()
+ except KeyboardInterrupt:
+ raise
+
except:
- pytest.fail('Cann\'t run mount process.')
+ pytest.fail('Can\'t run mount process.')
def teardown_method(self, is_su):
if not is_su:
@@ -46,8 +49,11 @@ class TestJavaIsolationRootfs(TestApplicationJava):
process.communicate()
+ except KeyboardInterrupt:
+ raise
+
except:
- pytest.fail('Cann\'t run mount process.')
+ pytest.fail('Can\'t run mount process.')
def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir):
if not is_su:
diff --git a/test/test_python_application.py b/test/test_python_application.py
index 871d8bc0..83b0c8f4 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -730,7 +730,7 @@ last line: 987654321
try:
group_id = grp.getgrnam(group).gr_gid
- except:
+ except KeyError:
group = 'nogroup'
group_id = grp.getgrnam(group).gr_gid
@@ -775,7 +775,7 @@ last line: 987654321
try:
grp.getgrnam(group)
group = True
- except:
+ except KeyError:
group = False
if group:
diff --git a/test/test_static.py b/test/test_static.py
index de8b71cc..a65928ca 100644
--- a/test/test_static.py
+++ b/test/test_static.py
@@ -134,6 +134,9 @@ class TestStatic(TestApplicationProto):
open(temp_dir + '/ф а', 'a').close()
utf8 = True
+ except KeyboardInterrupt:
+ raise
+
except:
utf8 = False
diff --git a/test/test_tls.py b/test/test_tls.py
index 7be426b1..4cf8d22c 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -486,6 +486,10 @@ basicConstraints = critical,CA:TRUE"""
resp = self.get_ssl(
headers={'Host': 'localhost', 'Connection': 'close'}, sock=sock
)
+
+ except KeyboardInterrupt:
+ raise
+
except:
resp = None
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
index 518cd017..866dec47 100644
--- a/test/unit/applications/lang/go.py
+++ b/test/unit/applications/lang/go.py
@@ -34,10 +34,16 @@ class TestApplicationGo(TestApplicationProto):
option.test_dir + '/go/' + script + '/' + name + '.go',
]
+ if option.detailed:
+ print("\n$ GOPATH=" + env['GOPATH'] + " " + " ".join(args))
+
try:
process = subprocess.Popen(args, env=env)
process.communicate()
+ except KeyboardInterrupt:
+ raise
+
except:
return None
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index e1bd5e0c..0ff85187 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -71,12 +71,18 @@ class TestApplicationJava(TestApplicationProto):
]
javac.extend(src)
+ if option.detailed:
+ print("\n$ " + " ".join(javac))
+
try:
process = subprocess.Popen(javac, stderr=subprocess.STDOUT)
process.communicate()
+ except KeyboardInterrupt:
+ raise
+
except:
- pytest.fail('Cann\'t run javac process.')
+ pytest.fail('Can\'t run javac process.')
def load(self, script, **kwargs):
self.prepare_env(script)
diff --git a/test/unit/check/go.py b/test/unit/check/go.py
index dd2150eb..35b0c2d5 100644
--- a/test/unit/check/go.py
+++ b/test/unit/check/go.py
@@ -25,5 +25,8 @@ def check_go(current_dir, temp_dir, test_dir):
if process.returncode == 0:
return True
+ except KeyboardInterrupt:
+ raise
+
except:
return None
diff --git a/test/unit/http.py b/test/unit/http.py
index 5f073439..8d964978 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -187,6 +187,10 @@ class TestHTTP(TestUnit):
try:
part = sock.recv(buff_size)
+
+ except KeyboardInterrupt:
+ raise
+
except:
break
@@ -242,7 +246,8 @@ class TestHTTP(TestUnit):
try:
last_size = int(chunks[-2], 16)
- except:
+
+ except ValueError:
pytest.fail('Invalid zero size chunk')
if last_size != 0 or chunks[-1] != b'':
@@ -252,7 +257,8 @@ class TestHTTP(TestUnit):
while len(chunks) >= 2:
try:
size = int(chunks.pop(0), 16)
- except:
+
+ except ValueError:
pytest.fail('Invalid chunk size %s' % str(size))
if size == 0: