summaryrefslogtreecommitdiff
path: root/systemd/test
Commit message (Collapse)AuthorAgeFilesLines
* Adding timezone information to datetimes from systemd-journalSamuel BF2022-08-131-0/+12
|
* journal: allow JournalHandler constructor to be called with args in a ↵Tamaki Nishino2020-11-121-0/+14
| | | | | | | | | | | | | | | positional param This change enables to add extra fields to JournalHandler in a configuration file loaded by `logging.config.fileConfig`, which only allows positional parameters: class=systemd.journal.JournalHandler args={'level': INFO, 'SYSLOG_IDENTIFIER': 'my-cool-app'} [zj: originally the patch added a new positional parameter to __init__(), but that is not backwards compatible. So I added a new classmethod to allow the positional parameters to be passed.]
* test: make sure $NOTIFY_SOCKET is unset in testZbigniew Jędrzejewski-Szmek2020-11-121-0/+2
| | | | | | When running the tests in Fedora's mock, the test would fail because NOTIFY_SOCKET is set to /run/systemd/nspawn/notify, and we get a permission error.
* tests: add tests for all id128 funcs, including get_machine_app_specific()Zbigniew Jędrzejewski-Szmek2019-06-161-0/+46
|
* Added support for listen_fds_with_names()Marcel Waldvogel2019-06-161-1/+41
|
* tests: add the reproducer from #51Zbigniew Jędrzejewski-Szmek2019-06-161-0/+13
| | | | | | 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.
* journal: do not convert extra args to string in JournalHandlerZbigniew Jędrzejewski-Szmek2017-03-191-2/+0
| | | | | | send() already does conversions in a type-specific way, and doing it in journal handler would defeat those conversions. In particular, UUIDs would be converted to early and have dashes.
* test_journal: add tests for MESSAGE_ID passingZbigniew Jędrzejewski-Szmek2017-03-191-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MESSAGE_ID passing was broken before previous commit: TypeError: send() got multiple values for keyword argument 'MESSAGE_ID' With the previous commit it's broken differently: ______________________________ test_journalhandler_message_id_on_handler _______________________________ def test_journalhandler_message_id_on_handler(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() handler = journal.JournalHandler(logging.INFO, sender_function=sender.send, MESSAGE_ID=TEST_MID) handler.emit(record) assert len(sender.buf) == 1 > assert 'MESSAGE_ID=' + TEST_MID.hex in sender.buf[0] E assert ('MESSAGE_ID=' + '8441372f8dca4ca98694a6091fd8519f') in ['MESSAGE=test', 'MESSAGE_ID=8441372f-8dca-4ca9-8694-a6091fd8519f', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...] E + where '8441372f8dca4ca98694a6091fd8519f' = UUID('8441372f-8dca-4ca9-8694-a6091fd8519f').hex systemd/test/test_journal.py:116: AssertionError ______________________________ test_journalhandler_message_id_on_message _______________________________ def test_journalhandler_message_id_on_message(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) record.__dict__['MESSAGE_ID'] = TEST_MID2 sender = MockSender() handler = journal.JournalHandler(logging.INFO, sender_function=sender.send, MESSAGE_ID=TEST_MID) handler.emit(record) assert len(sender.buf) == 1 > assert 'MESSAGE_ID=' + TEST_MID2.hex in sender.buf[0] E assert ('MESSAGE_ID=' + '8441370000000000000000001fd85000') in ['MESSAGE=test', 'MESSAGE_ID=84413700-0000-0000-0000-00001fd85000', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...] E + where '8441370000000000000000001fd85000' = UUID('84413700-0000-0000-0000-00001fd85000').hex systemd/test/test_journal.py:135: AssertionError ============================ 2 failed, 53 passed, 6 skipped in 0.16 seconds ============================
* journal: rename SENDER_FUNCTION to sender_functionZbigniew Jędrzejewski-Szmek2017-03-191-1/+1
| | | | | | | Let's not try to make it look like a journal field. It should be a normal parameter. Followup for dce0a855c3281e7051b1cbe0f73386d1c90ef320.
* daemon: properly skip sd_is_socket_sockaddr calls if not availableZbigniew Jędrzejewski-Szmek2017-03-191-15/+29
| | | | | As with other functions, the wrapper is always present, but returns OSError: [Errno 38] Function not implemented.
* Fix styling to match PEP8 in most places (#45)Wesley Bowman2017-03-141-1/+1
| | | | Backwards compatibility for mapPriority is retained.
* Adjust import order, spacing, operators as recommended by pylintZbigniew Jędrzejewski-Szmek2017-03-122-13/+13
|
* tests: move login tests from doctest to separate fileZbigniew Jędrzejewski-Szmek2017-03-121-0/+48
| | | | | | | | | This way we can skip ENOENT (which happens in containers). While at it, let's extend the tests a bit, so that we at least call all functions and check the type of the return value. Also, drop '.nspawn' from the machine name, nspawn doesn't use that suffix any more.
* Merge pull request #31 from keszybz/is_socket_sockaddrZbigniew Jędrzejewski-Szmek2017-03-112-13/+59
|\ | | | | daemon: add basic support for sd_is_socket_sockaddr
| * Fix handling of addresses without port and add testsZbigniew Jędrzejewski-Szmek2016-12-151-9/+10
| |
| * daemon: add wrapper for sd_is_socket_sockaddr and testsZbigniew Jędrzejewski-Szmek2016-12-151-5/+39
| | | | | | | | Specifying the address without does not work.
| * tests: skip journal.stream tests on ENOENT errorZbigniew Jędrzejewski-Szmek2016-12-151-8/+19
| | | | | | | | | | | | | | | | When running in a chroot, doctests that called journal.stream would fail with ENOENT. Move the tests to test_journal, where we can skip tests properly (without uglyfying the documentation). Fixes #32.
* | replace dict.iteritems() with dict.items() to support py3 (#39)Jeongsoo, Park2017-03-111-0/+36
| | | | | | py3 doesn't have dict.iteritems() anymore.
* | test_daemon: xfail test_notify_with_socket if bind() fails (#42)Mike Gilbert2017-03-111-1/+4
|/ | | | | This bind() call may fail if TMPDIR is too long. Bug: https://bugs.gentoo.org/610368
* tests: add workaround for pre-232 system returning EINVAL on some flagsZbigniew Jędrzejewski-Szmek2016-09-221-5/+15
|
* tests: skip fdstore tests if not implementedZbigniew Jędrzejewski-Szmek2016-09-221-3/+15
| | | | Should fix #12.
* journal: convert seek_realtime argument to microsecondsZbigniew Jędrzejewski-Szmek2016-09-211-2/+16
| | | | | | | | | | | | | This somewhat breaks backwards compatibility, but not for the previously documented arguments: floats are now interpreted differently, but ints and datetime.datetime objects are interpreted the same as before. But the documentation clearly stated that only ints and datetime.datetime objects were allowed. This makes seek_realtime match seek_monotonic and other functions which take time and follows the principle of least surprise. Fixes #21.
* tests: use a context manager, skip new functions if missingZbigniew Jędrzejewski-Szmek2016-09-211-21/+16
|
* reader: add SD_JOURNAL_OS_ROOT and rework flag passingZbigniew Jędrzejewski-Szmek2016-09-211-10/+25
| | | | | | | | | | | | | | | | | Let's pass any flags through to the journal functions without checking validity. Those functions do their own checking, so there's no need to second-guess. The semantics for _Reader(flags=0) are a bit changed: before, this would be transformed into sd_journal_open(SD_J_LOCAL_ONLY). Now, this results in sd_journal_open(0). Previous behaviour should be achieved by not specifying the flags at all. This change is necessary, because previously it was not possible to pass flags=0 to sd_journal_open(0), i.e. it was not possible to "merge" journals through the Python interface. Similarly, Reader(flags=0) now means to open all journals, and Reader(flags=None) is the same as Reader(flags=LOCAL_ONLY).
* journal: allow sd_journal_open_directory_fd to be usedZbigniew Jędrzejewski-Szmek2016-09-211-0/+16
|
* tests: check enumerate_fields, has_runtime_fiels, has_persistent_filesZbigniew Jędrzejewski-Szmek2016-09-201-0/+47
|
* Spelling fixesVille Skyttä2016-05-211-2/+2
|
* test_daemon: Define a default value for SO_PASSCREDMike Gilbert2016-01-201-1/+3
| | | | The socket module seems to be missing this in python2.7.
* tests: mirror is-systemd-running test from systemdv231Zbigniew Jędrzejewski-Szmek2015-10-281-1/+1
|
* Python2 does not have ConnectionErrorZbigniew Jędrzejewski-Szmek2015-10-271-5/+10
|
* tests: add tests for notify()Zbigniew Jędrzejewski-Szmek2015-10-261-1/+36
|
* tests: work around bug in sd_is_mqZbigniew Jędrzejewski-Szmek2015-10-251-3/+20
| | | | The fix was committed in v226-362-g0260d1d542.
* tests: add simplistic tests for Reader matchesZbigniew Jędrzejewski-Szmek2015-09-161-1/+33
| | | | | | | It would be nice to run those tests against fake journal files with the right content to actually test the matches. But those tests are still useful because they test that the interface works as expected.
* tests: add tests for Reader initializationZbigniew Jędrzejewski-Szmek2015-09-171-0/+39
|
* tests: start adding tests for JournalHandlerZbigniew Jędrzejewski-Szmek2015-09-171-0/+34
|
* tests: add more tests for socket functionsZbigniew Jędrzejewski-Szmek2015-09-061-1/+85
|
* tests: daemon.bootedZbigniew Jędrzejewski-Szmek2015-09-051-1/+9
|
* tests: daemon.listen_fdsZbigniew Jędrzejewski-Szmek2015-09-051-1/+26
|
* tests: add first testZbigniew Jędrzejewski-Szmek2015-08-071-0/+64
This is based on the code in https://github.com/systemd/python-systemd/pull/4 by Jacek Konieczny <j.konieczny@eggsoft.pl>.