From: Nir Soffer <nsoffer(a)redhat.com>
Modify sanlock so we can run sanlock daemon in the tests as current
user:
- Add an option to set the runtime directory via SANLOCK_RUN_DIR
enviroment variable
- Add an option to disable privileged operations via
SANLOCK_PRIVILEGED=0 enviroment variable
Both options should not be used in production, so we log a warning when
they are enabled.
SANLOCK_RUN_DIR effects both "sanlock daemon", "sanlock client" and
usage of libsanlock and libsanlock_client libraries, so we can test both
the executable and the python bindings.
With these modifications and the existing command line options, we can
run sanlock daemon in the tests as the current user. A new test module
was added with:
- sanlock_daemon() fixture that start the daemon at the start of the test
session, and stop it at the end of the session.
- run() function that use modified environment to access the daemon.
The first test initialize a lockspace using "sanlock client init".
Nir Soffer (7):
Fix lockfile() to use the given "dir" argument
Add dir argument to sanlock_socket_address()
Move SANLK_RUN_DIR to sanlock_internal.h
Add environment variables helpers
Add SANLOCK_RUN_DIR environment variable
Add SANLOCK_PRIVILEGED environment variable
Start the daemon tests module
src/Makefile | 9 +++++---
src/client.c | 8 ++++++-
src/env.c | 34 +++++++++++++++++++++++++++
src/env.h | 15 ++++++++++++
src/lockfile.c | 7 +++---
src/main.c | 25 ++++++++++++++++----
src/sanlock_internal.h | 4 ++++
src/sanlock_sock.c | 4 ++--
src/sanlock_sock.h | 3 +--
tests/daemon_test.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 155 insertions(+), 17 deletions(-)
create mode 100644 src/env.c
create mode 100644 src/env.h
create mode 100644 tests/daemon_test.py
--
2.9.5