From bfb15f2c940e58deec468ba4c7bfa72d77e5fa2547483310af4a8209d7f48f4d Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 13 May 2024 18:04:54 +0000 Subject: [PATCH] - Add fix_test_reader_this_machine.patch to make test_reader_this_machine pass in the limited build environment. - Do not pull in whole systemd, when just libsystemd0 is enough (bsc#1215538). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-systemd?expand=0&rev=29 --- OBS_missing_etc_machine_id.patch | 25 +++++++++++++++------- fix_test_reader_this_machine.patch | 34 ++++++++++++++++++++++++++++++ python-systemd.changes | 8 +++++++ python-systemd.spec | 9 +++++--- 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 fix_test_reader_this_machine.patch diff --git a/OBS_missing_etc_machine_id.patch b/OBS_missing_etc_machine_id.patch index 63246cb..134e4fb 100644 --- a/OBS_missing_etc_machine_id.patch +++ b/OBS_missing_etc_machine_id.patch @@ -6,14 +6,12 @@ Subject: [PATCH] tests: check for errnos that sd_id128_get_machine actually Fixes #118. --- - systemd/test/test_id128.py | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) + systemd/test/test_id128.py | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) -diff --git a/systemd/test/test_id128.py b/systemd/test/test_id128.py -index 146ec73..f5fc65f 100644 --- a/systemd/test/test_id128.py +++ b/systemd/test/test_id128.py -@@ -6,11 +6,11 @@ +@@ -6,11 +6,11 @@ import pytest from systemd import id128 @contextlib.contextmanager @@ -27,13 +25,24 @@ index 146ec73..f5fc65f 100644 pytest.skip() raise -@@ -29,7 +29,8 @@ def test_get_machine_app_specific(): +@@ -21,7 +21,10 @@ def test_randomize(): + assert u1 != u2 + + def test_get_machine(): +- u1 = id128.get_machine() ++ # yikes, python2 doesn't know ENOMEDIUM ++ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123): ++ u1 = id128.get_machine() ++ + u2 = id128.get_machine() + assert u1 == u2 + +@@ -29,7 +32,7 @@ def test_get_machine_app_specific(): a1 = uuid.uuid1() a2 = uuid.uuid1() - with skip_oserror(errno.ENOSYS): -+ # yikes, python2 doesn't know ENOMEDIUM -+ with skip_oserror(errno.ENOENT, 123): ++ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123): u1 = id128.get_machine_app_specific(a1) u2 = id128.get_machine_app_specific(a2) diff --git a/fix_test_reader_this_machine.patch b/fix_test_reader_this_machine.patch new file mode 100644 index 0000000..13a56be --- /dev/null +++ b/fix_test_reader_this_machine.patch @@ -0,0 +1,34 @@ +--- + systemd/test/test_journal.py | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +--- a/systemd/test/test_journal.py ++++ b/systemd/test/test_journal.py +@@ -43,11 +43,11 @@ class MockSender: + self.buf.append(args) + + @contextlib.contextmanager +-def skip_oserror(code): ++def skip_oserror(*errnos): + try: + yield + except (OSError, IOError) as e: +- if e.errno == code: ++ if e.errno in errnos: + pytest.skip() + raise + +@@ -233,9 +233,10 @@ def test_reader_this_boot(tmpdir): + def test_reader_this_machine(tmpdir): + j = journal.Reader(path=tmpdir.strpath) + with j: +- j.this_machine() +- j.this_machine(TEST_MID) +- j.this_machine(TEST_MID.hex) ++ with skip_oserror(errno.ENOENT, errno.ENOSYS, 123): ++ j.this_machine() ++ j.this_machine(TEST_MID) ++ j.this_machine(TEST_MID.hex) + + def test_reader_query_unique(tmpdir): + j = journal.Reader(path=tmpdir.strpath) diff --git a/python-systemd.changes b/python-systemd.changes index 94cd404..39a592b 100644 --- a/python-systemd.changes +++ b/python-systemd.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon May 13 18:03:23 UTC 2024 - Matej Cepl + +- Add fix_test_reader_this_machine.patch to make + test_reader_this_machine pass in the limited build environment. +- Do not pull in whole systemd, when just libsystemd0 is enough + (bsc#1215538). + ------------------------------------------------------------------- Sun Jun 11 14:08:18 UTC 2023 - ecsos diff --git a/python-systemd.spec b/python-systemd.spec index 937bb2b..13453c2 100644 --- a/python-systemd.spec +++ b/python-systemd.spec @@ -1,7 +1,7 @@ # # spec file for package python-systemd # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -30,6 +30,9 @@ Patch1: iso-c-90.patch # PATCH-FIX-OPENSUSE OBS_missing_etc_machine_id.patch gh#systemd/python-systemd#118 mcepl@suse.com # build environment doesn't have /etc/machine-id Patch2: OBS_missing_etc_machine_id.patch +# PATCH-FIX-UPSTREAM fix_test_reader_this_machine.patch mcepl@suse.com +# make test_reader_this_machine test pass in the limited build environment +Patch3: fix_test_reader_this_machine.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} @@ -39,7 +42,7 @@ BuildRequires: gcc-c++ BuildRequires: pkgconfig BuildRequires: python-rpm-macros BuildRequires: pkgconfig(libsystemd) -Requires: systemd +Requires: libsystemd0 Suggests: %{name}-doc # /SECTION BuildRequires: %{python_module pytest} @@ -64,7 +67,7 @@ Python module for native access to the systemd facilities. Functionality is sepe %check # Not sure about the first exclusion, -export PYTEST_ADDOPTS="-k 'not (test_reader_this_machine or test_get_machine)'" +# export PYTEST_ADDOPTS="-k 'not (test_reader_this_machine or test_get_machine)'" %python_expand make PYTHON=python%{$python_version} check %files %{python_files}