From 70bdc86128c01cbc7da77aa82c9e40188e257a2d Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Jan 15 2018 16:30:04 +0000 Subject: Extract start_sanlock_deamon() helper This will allow testing sanlock lockfile by trying to start multiple instances, and also makes the fixture code cleaner. Signed-off-by: Nir Soffer --- diff --git a/tests/daemon_test.py b/tests/daemon_test.py index a3d299f..5c8c3c8 100644 --- a/tests/daemon_test.py +++ b/tests/daemon_test.py @@ -17,8 +17,7 @@ ENV["SANLOCK_RUN_DIR"] = "/tmp/sanlock" ENV["SANLOCK_PRIVILEGED"] = "0" -@pytest.fixture(scope="session") -def sanlock_daemon(): +def start_sanlock_daemon(): cmd = [SANLOCK, "daemon", # no fork and print all logging to stderr "-D", @@ -31,7 +30,12 @@ def sanlock_daemon(): # run as current user instead of "sanlock" "-U", ENV["USER"], "-G", ENV["USER"]] - p = subprocess.Popen(cmd, env=ENV) + return subprocess.Popen(cmd, env=ENV) + + +@pytest.fixture(scope="session") +def sanlock_daemon(): + p = start_sanlock_daemon() try: yield finally: