summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2022-12-15 08:17:39 -0800
committerKonstantin Pavlov <thresh@nginx.com>2022-12-15 08:17:39 -0800
commite22669f2728814aba82da14702d18bfa9685311e (patch)
treec9c9471dab359e8e33fca24c5d4f035ab5b278db /test/unit
parenta1d28488f9df8e28ee25ea438c275b96b9afe5b6 (diff)
parent4409a10ff0bd6bb45fb88716bd383cd867958a8a (diff)
downloadunit-e22669f2728814aba82da14702d18bfa9685311e.tar.gz
unit-e22669f2728814aba82da14702d18bfa9685311e.tar.bz2
Merged with the default branch.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/applications/lang/go.py6
-rw-r--r--test/unit/applications/lang/java.py2
-rw-r--r--test/unit/applications/lang/python.py1
-rw-r--r--test/unit/applications/websockets.py3
-rw-r--r--test/unit/check/go.py4
-rw-r--r--test/unit/check/njs.py6
-rw-r--r--test/unit/check/regex.py9
-rw-r--r--test/unit/check/tls.py13
-rw-r--r--test/unit/http.py7
-rw-r--r--test/unit/utils.py21
10 files changed, 45 insertions, 27 deletions
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
index 3db955f3..14e76362 100644
--- a/test/unit/applications/lang/go.py
+++ b/test/unit/applications/lang/go.py
@@ -67,7 +67,9 @@ replace unit.nginx.org/go => {replace_path}
print("\n$ GOPATH=" + env['GOPATH'] + " " + " ".join(args))
try:
- process = subprocess.run(args, env=env, cwd=temp_dir)
+ output = subprocess.check_output(
+ args, env=env, cwd=temp_dir, stderr=subprocess.STDOUT
+ )
except KeyboardInterrupt:
raise
@@ -75,7 +77,7 @@ replace unit.nginx.org/go => {replace_path}
except subprocess.CalledProcessError:
return None
- return process
+ return output
def load(self, script, name='app', **kwargs):
static_build = False
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index 50998978..c8936274 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -52,7 +52,7 @@ class TestApplicationJava(TestApplicationProto):
os.makedirs(classes_path)
classpath = (
- option.current_dir + '/build/tomcat-servlet-api-9.0.52.jar'
+ option.current_dir + '/build/tomcat-servlet-api-9.0.70.jar'
)
ws_jars = glob.glob(
diff --git a/test/unit/applications/lang/python.py b/test/unit/applications/lang/python.py
index 1e38f3fa..3768cf07 100644
--- a/test/unit/applications/lang/python.py
+++ b/test/unit/applications/lang/python.py
@@ -50,6 +50,7 @@ class TestApplicationPython(TestApplicationProto):
'protocol',
'targets',
'threads',
+ 'prefix',
):
if attr in kwargs:
app[attr] = kwargs.pop(attr)
diff --git a/test/unit/applications/websockets.py b/test/unit/applications/websockets.py
index d647ce9b..15f212ff 100644
--- a/test/unit/applications/websockets.py
+++ b/test/unit/applications/websockets.py
@@ -43,10 +43,9 @@ class TestApplicationWebsocket(TestApplicationProto):
'Sec-WebSocket-Version': 13,
}
- _, sock = self.get(
+ sock = self.get(
headers=headers,
no_recv=True,
- start=True,
)
resp = ''
diff --git a/test/unit/check/go.py b/test/unit/check/go.py
index 3d9d13e7..09ae641d 100644
--- a/test/unit/check/go.py
+++ b/test/unit/check/go.py
@@ -2,7 +2,5 @@ from unit.applications.lang.go import TestApplicationGo
def check_go():
- process = TestApplicationGo.prepare_env('empty')
-
- if process != None and process.returncode == 0:
+ if TestApplicationGo.prepare_env('empty') is not None:
return True
diff --git a/test/unit/check/njs.py b/test/unit/check/njs.py
new file mode 100644
index 00000000..433473a1
--- /dev/null
+++ b/test/unit/check/njs.py
@@ -0,0 +1,6 @@
+import re
+
+
+def check_njs(output_version):
+ if re.search('--njs', output_version):
+ return True
diff --git a/test/unit/check/regex.py b/test/unit/check/regex.py
index 734c0150..51cf966b 100644
--- a/test/unit/check/regex.py
+++ b/test/unit/check/regex.py
@@ -1,13 +1,8 @@
import re
-import subprocess
-def check_regex(unitd):
- output = subprocess.check_output(
- [unitd, '--version'], stderr=subprocess.STDOUT
- )
-
- if re.search('--no-regex', output.decode()):
+def check_regex(output_version):
+ if re.search('--no-regex', output_version):
return False
return True
diff --git a/test/unit/check/tls.py b/test/unit/check/tls.py
index b878ff7d..53ce5ffc 100644
--- a/test/unit/check/tls.py
+++ b/test/unit/check/tls.py
@@ -2,12 +2,11 @@ import re
import subprocess
-def check_openssl(unitd):
- subprocess.check_output(['which', 'openssl'])
+def check_openssl(output_version):
+ try:
+ subprocess.check_output(['which', 'openssl'])
+ except subprocess.CalledProcessError:
+ return None
- output = subprocess.check_output(
- [unitd, '--version'], stderr=subprocess.STDOUT
- )
-
- if re.search('--openssl', output.decode()):
+ if re.search('--openssl', output_version):
return True
diff --git a/test/unit/http.py b/test/unit/http.py
index b29667c9..c48a720f 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -102,7 +102,12 @@ class TestHTTP:
if 'read_buffer_size' in kwargs:
recvall_kwargs['buff_size'] = kwargs['read_buffer_size']
- resp = self.recvall(sock, **recvall_kwargs).decode(encoding)
+ resp = self.recvall(sock, **recvall_kwargs).decode(
+ encoding, errors='ignore'
+ )
+
+ else:
+ return sock
self.log_in(resp)
diff --git a/test/unit/utils.py b/test/unit/utils.py
index 43aaa81b..d6590b97 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -12,9 +12,15 @@ def public_dir(path):
for root, dirs, files in os.walk(path):
for d in dirs:
- os.chmod(os.path.join(root, d), 0o777)
+ try:
+ os.chmod(os.path.join(root, d), 0o777)
+ except FileNotFoundError:
+ pass
for f in files:
- os.chmod(os.path.join(root, f), 0o777)
+ try:
+ os.chmod(os.path.join(root, f), 0o777)
+ except FileNotFoundError:
+ pass
def waitforfiles(*files, timeout=50):
@@ -66,12 +72,19 @@ def waitforsocket(port):
pytest.fail('Can\'t connect to the 127.0.0.1:' + str(port))
-def findmnt():
+def check_findmnt():
try:
- out = subprocess.check_output(
+ return subprocess.check_output(
['findmnt', '--raw'], stderr=subprocess.STDOUT
).decode()
except FileNotFoundError:
+ return False
+
+
+def findmnt():
+ out = check_findmnt()
+
+ if not out:
pytest.skip('requires findmnt')
return out