diff options
author | Marcel Waldvogel <marcel.waldvogel@uni-konstanz.de> | 2018-06-24 11:58:15 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-06-16 16:27:11 +0200 |
commit | b1608daf27a38f223afa4dda1930d4999c183178 (patch) | |
tree | 2c57a4aa08ca3a5fdd8e7bbead78eb864b70b053 /systemd/test/test_daemon.py | |
parent | a2471e236906503a2079fe9806303ff31e832cbd (diff) | |
download | python-systemd-b1608daf27a38f223afa4dda1930d4999c183178.tar.gz |
Added support for listen_fds_with_names()
Diffstat (limited to 'systemd/test/test_daemon.py')
-rw-r--r-- | systemd/test/test_daemon.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/systemd/test/test_daemon.py b/systemd/test/test_daemon.py index 9f4db7d..ea680a1 100644 --- a/systemd/test/test_daemon.py +++ b/systemd/test/test_daemon.py @@ -11,7 +11,7 @@ from systemd.daemon import (booted, is_socket_unix, _is_socket_unix, is_socket_sockaddr, _is_socket_sockaddr, is_mq, _is_mq, - listen_fds, + listen_fds, listen_fds_with_names, notify) import pytest @@ -256,6 +256,46 @@ def test_listen_fds_default_unset(): assert listen_fds() == [3] assert listen_fds() == [] +def test_listen_fds_with_names_nothing(): + # make sure we have no fds to listen to, no names + os.unsetenv('LISTEN_FDS') + os.unsetenv('LISTEN_PID') + os.unsetenv('LISTEN_FDNAMES') + + assert listen_fds_with_names() == {} + assert listen_fds_with_names(True) == {} + assert listen_fds_with_names(False) == {} + +def test_listen_fds_with_names_no_names(): + # make sure we have no fds to listen to, no names + os.environ['LISTEN_FDS'] = '1' + os.environ['LISTEN_PID'] = str(os.getpid()) + os.unsetenv('LISTEN_FDNAMES') + + assert listen_fds_with_names(False) == {3: 'unknown'} + assert listen_fds_with_names(True) == {3: 'unknown'} + assert listen_fds_with_names() == {} + +def test_listen_fds_with_names_single(): + # make sure we have no fds to listen to, no names + os.environ['LISTEN_FDS'] = '1' + os.environ['LISTEN_PID'] = str(os.getpid()) + os.environ['LISTEN_FDNAMES'] = 'cmds' + + assert listen_fds_with_names(False) == {3: 'cmds'} + assert listen_fds_with_names() == {3: 'cmds'} + assert listen_fds_with_names(True) == {} + +def test_listen_fds_with_names_multiple(): + # make sure we have no fds to listen to, no names + os.environ['LISTEN_FDS'] = '3' + os.environ['LISTEN_PID'] = str(os.getpid()) + os.environ['LISTEN_FDNAMES'] = 'cmds:data:errs' + + assert listen_fds_with_names(False) == {3: 'cmds', 4: 'data', 5: 'errs'} + assert listen_fds_with_names(True) == {3: 'cmds', 4: 'data', 5: 'errs'} + assert listen_fds_with_names() == {} + def test_notify_no_socket(): assert notify('READY=1') is False with skip_enosys(): |