diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-09-05 14:13:38 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-09-05 14:18:23 +0200 |
commit | 2e115f3c4f6f96a2fae0ef011def64ab8b0a11ca (patch) | |
tree | db3758cf10367eb276d60f05991f27e8c9ce7536 /systemd | |
parent | c76c5f0ef76e2de00eb93ee6e35e9d044fe35c28 (diff) | |
download | python-systemd-2e115f3c4f6f96a2fae0ef011def64ab8b0a11ca.tar.gz |
tests: daemon.listen_fds
Diffstat (limited to 'systemd')
-rw-r--r-- | systemd/test/test_daemon.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/systemd/test/test_daemon.py b/systemd/test/test_daemon.py index 230581d..96c5717 100644 --- a/systemd/test/test_daemon.py +++ b/systemd/test/test_daemon.py @@ -1,7 +1,7 @@ import sys import os import posix -from systemd.daemon import _is_fifo, is_fifo +from systemd.daemon import _is_fifo, is_fifo, listen_fds import pytest @@ -62,3 +62,28 @@ def test_is_fifo_bad_fd(tmpdir): with pytest.raises(OSError): assert not is_fifo(-1, path) + +def test_listen_fds_no_fds(): + # make sure we have no fds to listen to + os.unsetenv('LISTEN_FDS') + os.unsetenv('LISTEN_PID') + + assert listen_fds() == [] + assert listen_fds(True) == [] + assert listen_fds(False) == [] + +def test_listen_fds(): + os.environ['LISTEN_FDS'] = '3' + os.environ['LISTEN_PID'] = str(os.getpid()) + + assert listen_fds(False) == [3, 4, 5] + assert listen_fds(True) == [3, 4, 5] + assert listen_fds() == [] + +def test_listen_fds_default_unset(): + os.environ['LISTEN_FDS'] = '1' + os.environ['LISTEN_PID'] = str(os.getpid()) + + assert listen_fds(False) == [3] + assert listen_fds() == [3] + assert listen_fds() == [] |