Tests: fixing tests interrupt in terminal.
KeyboardInterrupt re-raised.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -134,6 +134,9 @@ class TestStatic(TestApplicationProto):
|
||||
open(temp_dir + '/ф а', 'a').close()
|
||||
utf8 = True
|
||||
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
|
||||
except:
|
||||
utf8 = False
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user