diff options
author | Andrei Belov <defan@nginx.com> | 2020-12-23 18:30:17 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-12-23 18:30:17 +0300 |
commit | 53af12def0623006509c08a3e081371a697acbd1 (patch) | |
tree | 75036dbc04fa75dbcbf426b29ff4be1520a8dfc8 /test | |
parent | b7dba9006243f65e66d85a3a29841262c1c5dfef (diff) | |
download | unit-53af12def0623006509c08a3e081371a697acbd1.tar.gz unit-53af12def0623006509c08a3e081371a697acbd1.tar.bz2 |
Tests: ability to run unitd with specified "--user" option.
Diffstat (limited to '')
-rw-r--r-- | test/conftest.py | 46 |
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() |