2c41fb6225
Running tests with top-level parallel builds can speed up running some tests, expecially those that have a lot of packages like the systemd init tests. Trigger TLPB when the configuration enables per-package directories. We're using the jlevel argument, which normally is used for BR2_JLEVEL as the value for calling make -j<N> at the top-level. In fact, BR2_JLEVEL is "unused" when using TLPB, because the top-level make acts as the job server that distributes tokens to sub-makes (except for the few build systems like waf or scons that don't support this), so it's really the top-level make -j<N> that determines the level of parallelism, and BR2_JLEVEL doesn't really have an effect. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> [Thomas: extend explanation a bit] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
100 lines
3.0 KiB
Python
100 lines
3.0 KiB
Python
import unittest
|
|
import os
|
|
import datetime
|
|
|
|
from infra.builder import Builder
|
|
from infra.emulator import Emulator
|
|
|
|
BASIC_TOOLCHAIN_CONFIG = \
|
|
"""
|
|
BR2_arm=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
|
|
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
|
|
BR2_TOOLCHAIN_EXTERNAL_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/armv5-eabi/tarballs/armv5-eabi--uclibc--bleeding-edge-2018.11-1.tar.bz2"
|
|
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
|
|
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
|
|
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
|
|
BR2_TOOLCHAIN_HAS_THREADS_DEBUG=y
|
|
BR2_TOOLCHAIN_EXTERNAL_CXX=y
|
|
"""
|
|
|
|
MINIMAL_CONFIG = \
|
|
"""
|
|
BR2_INIT_NONE=y
|
|
BR2_SYSTEM_BIN_SH_NONE=y
|
|
# BR2_PACKAGE_BUSYBOX is not set
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
"""
|
|
|
|
|
|
class BRConfigTest(unittest.TestCase):
|
|
"""Test up to the configure stage."""
|
|
config = None
|
|
br2_external = list()
|
|
downloaddir = None
|
|
outputdir = None
|
|
logtofile = True
|
|
keepbuilds = False
|
|
jlevel = 0
|
|
timeout_multiplier = 1
|
|
|
|
def __init__(self, names):
|
|
super(BRConfigTest, self).__init__(names)
|
|
self.testname = self.__class__.__name__
|
|
self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
|
|
self.config += '\nBR2_DL_DIR="{}"\n'.format(self.downloaddir)
|
|
self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
|
|
|
|
def show_msg(self, msg):
|
|
print("{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
|
|
self.testname, msg))
|
|
|
|
def setUp(self):
|
|
self.show_msg("Starting")
|
|
self.b = Builder(self.config, self.builddir, self.logtofile, self.jlevel)
|
|
|
|
if not self.keepbuilds:
|
|
self.b.delete()
|
|
|
|
if not self.b.is_finished():
|
|
self.b.configure(make_extra_opts=["BR2_EXTERNAL={}".format(":".join(self.br2_external))])
|
|
|
|
def tearDown(self):
|
|
self.show_msg("Cleaning up")
|
|
if self.b and not self.keepbuilds:
|
|
self.b.delete()
|
|
|
|
|
|
class BRTest(BRConfigTest):
|
|
"""Test up to the build stage and instantiate an emulator."""
|
|
def __init__(self, names):
|
|
super(BRTest, self).__init__(names)
|
|
self.emulator = None
|
|
|
|
def setUp(self):
|
|
super(BRTest, self).setUp()
|
|
if not self.b.is_finished():
|
|
self.show_msg("Building")
|
|
self.b.build()
|
|
self.show_msg("Building done")
|
|
|
|
self.emulator = Emulator(self.builddir, self.downloaddir,
|
|
self.logtofile, self.timeout_multiplier)
|
|
|
|
def tearDown(self):
|
|
if self.emulator:
|
|
self.emulator.stop()
|
|
super(BRTest, self).tearDown()
|
|
|
|
# Run the given 'cmd' with a 'timeout' on the target and
|
|
# assert that the command succeeded; on error, print the
|
|
# faulty command and its output
|
|
def assertRunOk(self, cmd, timeout=-1):
|
|
out, exit_code = self.emulator.run(cmd, timeout)
|
|
self.assertEqual(
|
|
exit_code,
|
|
0,
|
|
"\nFailed to run: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out))
|
|
)
|