summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--test/test_java_isolation_rootfs.py14
-rw-r--r--test/test_static_mount.py16
-rw-r--r--test/test_tls.py10
-rw-r--r--test/test_tls_sni.py4
-rw-r--r--test/unit/applications/lang/go.py5
-rw-r--r--test/unit/applications/lang/java.py20
-rw-r--r--test/unit/applications/tls.py2
-rw-r--r--test/unit/check/go.py7
8 files changed, 39 insertions, 39 deletions
diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py
index 91773981..eac86a0c 100644
--- a/test/test_java_isolation_rootfs.py
+++ b/test/test_java_isolation_rootfs.py
@@ -18,7 +18,7 @@ class TestJavaIsolationRootfs(TestApplicationJava):
os.chmod(option.temp_dir + '/tmp', 0o777)
try:
- process = subprocess.Popen(
+ subprocess.run(
[
"mount",
"--bind",
@@ -28,12 +28,10 @@ class TestJavaIsolationRootfs(TestApplicationJava):
stderr=subprocess.STDOUT,
)
- process.communicate()
-
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
pytest.fail('Can\'t run mount process.')
def teardown_method(self, is_su):
@@ -41,18 +39,16 @@ class TestJavaIsolationRootfs(TestApplicationJava):
return
try:
- process = subprocess.Popen(
+ subprocess.run(
["umount", "--lazy", option.temp_dir + "/jars"],
stderr=subprocess.STDOUT,
)
- process.communicate()
-
except KeyboardInterrupt:
raise
- except:
- pytest.fail('Can\'t run mount process.')
+ except subprocess.CalledProcessError:
+ pytest.fail('Can\'t run umount process.')
def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir):
if not is_su:
diff --git a/test/test_static_mount.py b/test/test_static_mount.py
index e34a8a07..82eda956 100644
--- a/test/test_static_mount.py
+++ b/test/test_static_mount.py
@@ -22,7 +22,7 @@ class TestStaticMount(TestApplicationProto):
Path(temp_dir + '/assets/mount/index.html').write_text('mount')
try:
- process = subprocess.Popen(
+ subprocess.check_output(
[
"mount",
"--bind",
@@ -32,35 +32,33 @@ class TestStaticMount(TestApplicationProto):
stderr=subprocess.STDOUT,
)
- process.communicate()
-
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
pytest.fail('Can\'t run mount process.')
self._load_conf(
{
"listeners": {"*:7080": {"pass": "routes"}},
- "routes": [{"action": {"share": temp_dir + "/assets/dir$uri"}}],
+ "routes": [
+ {"action": {"share": temp_dir + "/assets/dir$uri"}}
+ ],
}
)
yield
try:
- process = subprocess.Popen(
+ subprocess.check_output(
["umount", "--lazy", temp_dir + "/assets/dir/mount"],
stderr=subprocess.STDOUT,
)
- process.communicate()
-
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
pytest.fail('Can\'t run umount process.')
def test_static_mount(self, temp_dir, skip_alert):
diff --git a/test/test_tls.py b/test/test_tls.py
index d2d71141..01336765 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -32,7 +32,7 @@ class TestTLS(TestApplicationTLS):
def req(self, name='localhost', subject=None, x509=False):
subj = subject if subject is not None else '/CN=' + name + '/'
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'req',
@@ -87,7 +87,7 @@ basicConstraints = critical,CA:TRUE"""
f.write('')
def ca(self, cert='root', out='localhost'):
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'ca',
@@ -220,7 +220,7 @@ basicConstraints = critical,CA:TRUE"""
self.openssl_conf()
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'ecparam',
@@ -234,7 +234,7 @@ basicConstraints = critical,CA:TRUE"""
stderr=subprocess.STDOUT,
)
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'req',
@@ -589,7 +589,7 @@ basicConstraints = critical,CA:TRUE"""
app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]
- subprocess.call(['kill', '-9', app_id])
+ subprocess.check_output(['kill', '-9', app_id])
skip_alert(r'process .* %s.* exited on signal 9' % app_id)
diff --git a/test/test_tls_sni.py b/test/test_tls_sni.py
index e3aee4e3..d5f205cf 100644
--- a/test/test_tls_sni.py
+++ b/test/test_tls_sni.py
@@ -74,7 +74,7 @@ basicConstraints = critical,CA:TRUE"""
else '/'
)
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'req',
@@ -100,7 +100,7 @@ basicConstraints = critical,CA:TRUE"""
else '/'
)
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'ca',
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
index 6be1667b..367059e6 100644
--- a/test/unit/applications/lang/go.py
+++ b/test/unit/applications/lang/go.py
@@ -40,13 +40,12 @@ class TestApplicationGo(TestApplicationProto):
print("\n$ GOPATH=" + env['GOPATH'] + " " + " ".join(args))
try:
- process = subprocess.Popen(args, env=env)
- process.communicate()
+ process = subprocess.run(args, env=env)
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
return None
return process
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index 53b27b07..50998978 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -64,10 +64,17 @@ class TestApplicationJava(TestApplicationProto):
javac = [
'javac',
- '-target', '8', '-source', '8', '-nowarn',
- '-encoding', 'utf-8',
- '-d', classes_path,
- '-classpath', classpath + ':' + ws_jars[0],
+ '-target',
+ '8',
+ '-source',
+ '8',
+ '-nowarn',
+ '-encoding',
+ 'utf-8',
+ '-d',
+ classes_path,
+ '-classpath',
+ classpath + ':' + ws_jars[0],
]
javac.extend(src)
@@ -75,13 +82,12 @@ class TestApplicationJava(TestApplicationProto):
print("\n$ " + " ".join(javac))
try:
- process = subprocess.Popen(javac, stderr=subprocess.STDOUT)
- process.communicate()
+ subprocess.check_output(javac, stderr=subprocess.STDOUT)
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
pytest.fail('Can\'t run javac process.')
def load(self, script, **kwargs):
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py
index 583b618f..c7254235 100644
--- a/test/unit/applications/tls.py
+++ b/test/unit/applications/tls.py
@@ -15,7 +15,7 @@ class TestApplicationTLS(TestApplicationProto):
def certificate(self, name='default', load=True):
self.openssl_conf()
- subprocess.call(
+ subprocess.check_output(
[
'openssl',
'req',
diff --git a/test/unit/check/go.py b/test/unit/check/go.py
index 309091c0..cc17f0fe 100644
--- a/test/unit/check/go.py
+++ b/test/unit/check/go.py
@@ -11,7 +11,7 @@ def check_go(current_dir, temp_dir, test_dir):
env['GO111MODULE'] = 'auto'
try:
- process = subprocess.Popen(
+ process = subprocess.run(
[
'go',
'build',
@@ -20,8 +20,9 @@ def check_go(current_dir, temp_dir, test_dir):
test_dir + '/go/empty/app.go',
],
env=env,
+ stderr=subprocess.STDOUT,
+ stdout=subprocess.PIPE,
)
- process.communicate()
if process.returncode == 0:
return True
@@ -29,5 +30,5 @@ def check_go(current_dir, temp_dir, test_dir):
except KeyboardInterrupt:
raise
- except:
+ except subprocess.CalledProcessError:
return None