summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-16 15:23:08 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-16 16:27:11 +0200
commita2471e236906503a2079fe9806303ff31e832cbd (patch)
treee1ec42702cf50860ebfbc4d0c8f508d64173168d
parent7e32263d7977342d6b827ff4d950b90c87fed32f (diff)
downloadpython-systemd-a2471e236906503a2079fe9806303ff31e832cbd.tar.gz
tests: add the reproducer from #51
The example relies on implementation details, but I don't see why it wouldn't work everywhere. Let's pull it in, and if it breaks somewhere, we can remove it.
-rw-r--r--systemd/test/test_daemon.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/systemd/test/test_daemon.py b/systemd/test/test_daemon.py
index 1ddb55e..9f4db7d 100644
--- a/systemd/test/test_daemon.py
+++ b/systemd/test/test_daemon.py
@@ -302,3 +302,16 @@ def test_notify_with_socket(tmpdir):
assert notify('FDSTORE=1', fds=[1, 2])
assert notify('FDSTORE=1', pid=os.getpid())
assert notify('FDSTORE=1', pid=os.getpid(), fds=(1,))
+
+def test_daemon_notify_memleak():
+ # https://github.com/systemd/python-systemd/pull/51
+ fd = 1
+ fds = [fd]
+ ref_cnt = sys.getrefcount(fd)
+
+ try:
+ notify('', True, 0, fds)
+ except ConnectionRefusedError:
+ pass
+
+ assert sys.getrefcount(fd) <= ref_cnt, 'leak'