support/testing/infra/basetest.py: add BRHostPkgTest class

Runtime test cases are currently mostly used to test target packages,
and the BRTest class is perfect for that as we can easily feed a
Buildroot configuration, boot it under Qemu and run commands inside
the emulator.

A few tests use the more basic BRConfigTest when they have special
needs that don't match with BRTest.

However, as we are going to add a number of tests to verify the proper
functionality of some host only packages, which have no visible
menuconfig option, it makes sense to add another BRHostPkgTest class
that allows to easily trigger the build of "make host-<foo>
host-<bar>", and then run some commands on the host machine. Such
tests could be done by using BRConfigTest, but that would require a
bit of duplicated boilerplate, which BRHostPkgTest allows to remove.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Thomas Petazzoni
2025-10-18 21:43:00 +02:00
committed by Julien Olivain
parent 01dc13adfb
commit 9468f1c099

View File

@@ -60,6 +60,28 @@ class BRConfigTest(unittest.TestCase):
self.b.delete()
class BRHostPkgTest(BRConfigTest):
"""Test up to the build stage of a host package. Define hostpkgs in
the class to the list of host packages that should be built."""
config = \
BASIC_TOOLCHAIN_CONFIG + \
MINIMAL_CONFIG
hostpkgs = None
def __init__(self, names):
super(BRHostPkgTest, self).__init__(names)
def setUp(self):
super(BRHostPkgTest, self).setUp()
if not self.b.is_finished():
self.show_msg("Building")
self.b.build(make_extra_opts=self.hostpkgs)
self.show_msg("Building done")
def tearDown(self):
super(BRHostPkgTest, self).tearDown()
class BRTest(BRConfigTest):
"""Test up to the build stage and instantiate an emulator."""
def __init__(self, names):