From: Babanpreet Singh <bbnpreetsingh@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>,
Michael Opdenacker <michael.opdenacker@rootcommit.com>,
Babanpreet Singh <bbnpreetsingh@gmail.com>
Subject: [PATCH v2 1/3] prserv/tests: run ScriptTests on a free port with one database
Date: Tue, 15 Sep 2026 16:06:31 +0000 [thread overview]
Message-ID: <20260915160633.7-2-bbnpreetsingh@gmail.com> (raw)
In-Reply-To: <20260915160633.7-1-bbnpreetsingh@gmail.com>
ScriptTests starts bitbake-prserv on the default port (8585) and gives
each test its own temporary directory for the database. Anything
already listening on 8585 on the test machine stops the daemon from
binding.
Pick a free port in setUpClass and keep one database directory for the
whole class, which is what the oe-selftest prservice test already does
for its port.
AI-Generated: Uses Claude (claude-fable-5-1)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
lib/prserv/tests.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/lib/prserv/tests.py b/lib/prserv/tests.py
index df0c00300..f3b2aae45 100644
--- a/lib/prserv/tests.py
+++ b/lib/prserv/tests.py
@@ -369,20 +369,28 @@ class PRUpstreamTests(PRTestSetup, unittest.TestCase):
class ScriptTests(unittest.TestCase):
- def setUp(self):
-
- self.temp_dir = tempfile.TemporaryDirectory(prefix='bb-prserv')
- self.addCleanup(self.temp_dir.cleanup)
- self.dbfile = os.path.join(self.temp_dir.name, "prtest.sqlite3")
+ @classmethod
+ def setUpClass(cls):
+ cls.temp_dir = tempfile.TemporaryDirectory(prefix='bb-prserv')
+ cls.dbfile = os.path.join(cls.temp_dir.name, "prtest.sqlite3")
+ # The server test_1 starts runs until test_2 stops it, so use a
+ # port nothing else on the machine is listening on
+ with socket.socket() as s:
+ s.bind(("0.0.0.0", 0))
+ cls.port = str(s.getsockname()[1])
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.temp_dir.cleanup()
def test_1_start_bitbake_prserv(self):
try:
- subprocess.check_call([BIN_DIR / "bitbake-prserv", "--start", "-f", self.dbfile])
+ subprocess.check_call([BIN_DIR / "bitbake-prserv", "--start", "-f", self.dbfile, "--port", self.port])
except subprocess.CalledProcessError as e:
self.fail("Failed to start bitbake-prserv: %s" % e.returncode)
def test_2_stop_bitbake_prserv(self):
try:
- subprocess.check_call([BIN_DIR / "bitbake-prserv", "--stop"])
+ subprocess.check_call([BIN_DIR / "bitbake-prserv", "--stop", "--port", self.port])
except subprocess.CalledProcessError as e:
self.fail("Failed to stop bitbake-prserv: %s" % e.returncode)
--
2.43.0
next prev parent reply other threads:[~2026-09-15 16:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 16:06 [PATCH v2 0/3] prserv: add --status, and make --start notice a dead server Babanpreet Singh
2026-09-15 16:06 ` Babanpreet Singh [this message]
2026-09-15 16:06 ` [PATCH v2 2/3] prserv: make --start fail when the server does not come up Babanpreet Singh
2026-09-15 16:06 ` [PATCH v2 3/3] prserv: add --status to list running servers Babanpreet Singh
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=20260915160633.7-2-bbnpreetsingh@gmail.com \
--to=bbnpreetsingh@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=michael.opdenacker@rootcommit.com \
--cc=richard.purdie@linuxfoundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.