From: Tim Orling <ticotimo@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Tim Orling <tim.orling@konsulko.com>
Subject: [PATCH 3/3] oeqa/selftest/oelib: add tests for oe.distro_check
Date: Sat, 14 Nov 2026 12:08:10 -0800 [thread overview]
Message-ID: <20261114200810.31078-4-tim.orling@konsulko.com> (raw)
In-Reply-To: <20261114200810.31078-1-tim.orling@konsulko.com>
Nothing in OE-Core uses oe.distro_check any more (its user is the
Recipe Reporting System on the layer index), so nothing exercised it.
Test, without network access, that create_distro_packages_list()
skips a distro whose fetch fails and that Debian style Sources lists
are read from both .gz and .xz files.
Without the two previous changes the skip and .xz tests fail.
[YOCTO #16503]
AI-Generated: Claude Opus 5.5
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
.../oeqa/selftest/cases/oelib/distro_check.py | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 meta/lib/oeqa/selftest/cases/oelib/distro_check.py
diff --git a/meta/lib/oeqa/selftest/cases/oelib/distro_check.py b/meta/lib/oeqa/selftest/cases/oelib/distro_check.py
new file mode 100644
index 0000000000..f47d1dd4a4
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/oelib/distro_check.py
@@ -0,0 +1,59 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+import gzip
+import io
+import lzma
+import os
+import tempfile
+from unittest import mock
+from unittest.case import TestCase
+
+import bb
+# oe.distro_check uses bb as a builtin, which bb.build sets up
+import bb.build
+import oe.distro_check
+
+SOURCES = b"Package: foo\nVersion: 1.0\n\nPackage: bar\nVersion: 2.0\n"
+
+class TestDebianStyleSourcePackageList(TestCase):
+ def check(self, url, data):
+ with mock.patch.object(oe.distro_check, "create_socket", return_value=io.BytesIO(data)):
+ names = oe.distro_check.get_debian_style_source_package_list(url, "main", None)
+ self.assertEqual(names, {"foo:main", "bar:main"})
+
+ def test_gzip(self):
+ self.check("http://example.com/Sources.gz", gzip.compress(SOURCES))
+
+ def test_xz(self):
+ self.check("http://example.com/Sources.xz", lzma.compress(SOURCES))
+
+class TestCreateDistroPackagesList(TestCase):
+ def test_skip_failed_distro(self):
+ """
+ A distro whose package list can't be fetched is skipped, and the
+ other distros' lists are still written.
+ """
+ def fail(d):
+ raise OSError("HTTP Error 404: Not Found")
+
+ def ok(d):
+ return "1.0", {"foo:main"}
+
+ fetchers = {"get_latest_released_%s_source_package_list" % name: ok
+ for name in ("ubuntu", "fedora", "opensuse", "clear")}
+ fetchers["get_latest_released_debian_source_package_list"] = fail
+
+ with tempfile.TemporaryDirectory() as tmpdir, \
+ mock.patch.multiple(oe.distro_check, **fetchers), \
+ mock.patch.object(bb, "note"), \
+ mock.patch.object(bb, "warn") as warn:
+ oe.distro_check.create_distro_packages_list(tmpdir, None)
+ lists = sorted(os.listdir(os.path.join(tmpdir, "package_lists")))
+
+ self.assertEqual(lists, ["Clear-1.0", "Fedora-1.0", "Ubuntu-1.0", "openSUSE-1.0"])
+ warn.assert_called_once()
+ self.assertIn("Debian", warn.call_args[0][0])
--
2.56.1
prev parent reply other threads:[~2026-11-14 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 20:08 [PATCH 0/3] Fix distro_check when a distro list cannot be fetched Tim Orling
2026-11-14 20:08 ` [PATCH 1/3] lib/oe/distro_check: skip a distro whose package list can't " Tim Orling
2026-11-14 20:08 ` [PATCH 2/3] lib/oe/distro_check: fetch Debian updates from stable-updates Tim Orling
2026-11-14 20:08 ` Tim Orling [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261114200810.31078-4-tim.orling@konsulko.com \
--to=ticotimo@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=tim.orling@konsulko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox