summaryrefslogtreecommitdiffhomepage
path: root/test/conftest.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2020-12-23 18:30:17 +0300
committerAndrei Belov <defan@nginx.com>2020-12-23 18:30:17 +0300
commit53af12def0623006509c08a3e081371a697acbd1 (patch)
tree75036dbc04fa75dbcbf426b29ff4be1520a8dfc8 /test/conftest.py
parentb7dba9006243f65e66d85a3a29841262c1c5dfef (diff)
downloadunit-53af12def0623006509c08a3e081371a697acbd1.tar.gz
unit-53af12def0623006509c08a3e081371a697acbd1.tar.bz2
Tests: ability to run unitd with specified "--user" option.
Diffstat (limited to 'test/conftest.py')
-rw-r--r--test/conftest.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/test/conftest.py b/test/conftest.py
index c2a320de..d87e648b 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -48,6 +48,11 @@ def pytest_addoption(parser):
action="store_true",
help="Run unsafe tests",
)
+ parser.addoption(
+ "--user",
+ type=str,
+ help="Default user for non-privileged processes of unitd",
+ )
unit_instance = {}
@@ -60,6 +65,7 @@ def pytest_configure(config):
option.print_log = config.option.print_log
option.save_log = config.option.save_log
option.unsafe = config.option.unsafe
+ option.user = config.option.user
option.generated_tests = {}
option.current_dir = os.path.abspath(
@@ -283,26 +289,28 @@ def unit_run():
os.mkdir(temp_dir + '/state')
+ unitd_args = [
+ unitd,
+ '--no-daemon',
+ '--modules',
+ build_dir,
+ '--state',
+ temp_dir + '/state',
+ '--pid',
+ temp_dir + '/unit.pid',
+ '--log',
+ temp_dir + '/unit.log',
+ '--control',
+ 'unix:' + temp_dir + '/control.unit.sock',
+ '--tmp',
+ temp_dir,
+ ]
+
+ if option.user:
+ unitd_args.extend(['--user', option.user])
+
with open(temp_dir + '/unit.log', 'w') as log:
- unit_instance['process'] = subprocess.Popen(
- [
- unitd,
- '--no-daemon',
- '--modules',
- build_dir,
- '--state',
- temp_dir + '/state',
- '--pid',
- temp_dir + '/unit.pid',
- '--log',
- temp_dir + '/unit.log',
- '--control',
- 'unix:' + temp_dir + '/control.unit.sock',
- '--tmp',
- temp_dir,
- ],
- stderr=log,
- )
+ unit_instance['process'] = subprocess.Popen(unitd_args, stderr=log)
if not waitforfiles(temp_dir + '/control.unit.sock'):
_print_log()