summaryrefslogtreecommitdiff
path: root/systemd/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-09-18 21:58:21 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-09-21 15:32:58 -0400
commitdadcd3d723c7781ee9a3ab54341030cad10904bd (patch)
treee5ab9b986b7abb589916885df1acaed9c61a58d8 /systemd/test
parent42f627b30236e92f0b7dd76db8069580ce8a9199 (diff)
downloadpython-systemd-dadcd3d723c7781ee9a3ab54341030cad10904bd.tar.gz
journal: allow sd_journal_open_directory_fd to be used
Diffstat (limited to 'systemd/test')
-rw-r--r--systemd/test/test_journal.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/systemd/test/test_journal.py b/systemd/test/test_journal.py
index 152fccf..4b23a70 100644
--- a/systemd/test/test_journal.py
+++ b/systemd/test/test_journal.py
@@ -1,6 +1,7 @@
import logging
import uuid
import errno
+import os
from systemd import journal, id128
import pytest
@@ -52,6 +53,21 @@ def test_reader_init_path(tmpdir):
with pytest.raises(ValueError):
journal.Reader(journal.LOCAL_ONLY, path=tmpdir.strpath)
+def test_reader_init_path_invalid_fd():
+ with pytest.raises(OSError):
+ journal.Reader(0, path=-1)
+
+def test_reader_init_path_nondirectory_fd():
+ with pytest.raises(OSError):
+ journal.Reader(0, path=0)
+
+def test_reader_init_path_fd(tmpdir):
+ fd = os.open(tmpdir.strpath, os.O_RDONLY)
+ j = journal.Reader(path=fd)
+ with pytest.raises(ValueError):
+ journal.Reader(journal.LOCAL_ONLY, path=fd)
+ assert list(j) == []
+
def test_reader_as_cm(tmpdir):
j = journal.Reader(path=tmpdir.strpath)
with j: