summaryrefslogtreecommitdiffhomepage
path: root/test/unit/check/discover_available.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2023-06-12 14:16:59 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2023-06-12 14:16:59 +0100
commitce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4 (patch)
tree818e60eb10d7f2be90f25003b3a2b347314e966f /test/unit/check/discover_available.py
parenta3b9b49cfb091410ca8f3c8d9df24d1fe184f8e0 (diff)
downloadunit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.gz
unit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.bz2
Tests: prerequisites checking reworked.
Prerequisites check moved to the module level to simplify class structure. Discovery and prerequisites checks functions moved to the separate files. Introduced "require" fixture to provide per-test requirements check.
Diffstat (limited to 'test/unit/check/discover_available.py')
-rw-r--r--test/unit/check/discover_available.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/check/discover_available.py b/test/unit/check/discover_available.py
new file mode 100644
index 00000000..0942581b
--- /dev/null
+++ b/test/unit/check/discover_available.py
@@ -0,0 +1,47 @@
+import subprocess
+import sys
+
+from unit.check.chroot import check_chroot
+from unit.check.go import check_go
+from unit.check.isolation import check_isolation
+from unit.check.njs import check_njs
+from unit.check.node import check_node
+from unit.check.regex import check_regex
+from unit.check.tls import check_openssl
+from unit.check.unix_abstract import check_unix_abstract
+from unit.log import Log
+from unit.option import option
+
+
+def discover_available(unit):
+ output_version = subprocess.check_output(
+ [unit['unitd'], '--version'], stderr=subprocess.STDOUT
+ ).decode()
+
+ # wait for controller start
+
+ if Log.wait_for_record(r'controller started') is None:
+ Log.print_log()
+ sys.exit("controller didn't start")
+
+ # discover modules from log file
+
+ for module in Log.findall(r'module: ([a-zA-Z]+) (.*) ".*"$'):
+ versions = option.available['modules'].setdefault(module[0], [])
+ if module[1] not in versions:
+ versions.append(module[1])
+
+ # discover modules using check
+
+ option.available['modules']['go'] = check_go()
+ option.available['modules']['njs'] = check_njs(output_version)
+ option.available['modules']['node'] = check_node()
+ option.available['modules']['openssl'] = check_openssl(output_version)
+ option.available['modules']['regex'] = check_regex(output_version)
+
+ # Discover features using check. Features should be discovered after
+ # modules since some features can require modules.
+
+ option.available['features']['chroot'] = check_chroot()
+ option.available['features']['isolation'] = check_isolation()
+ option.available['features']['unix_abstract'] = check_unix_abstract()