Run like this: alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-selftest -v bb.tests.setup test_setup (bb.tests.setup.BitbakeSetupTest.test_setup) ... ok ---------------------------------------------------------------------- Ran 1 test in 9.223s OK The test does a basic run-through of init, then status/update on an unchanged configuration, then status/update on a configuration changed via new commits to the test layer, then status/update on configuration changed via the top level json config file. Note that nothing whatsoever is fetched from the network; the test relies entirely on synthetic data contained inside itself, including minimal stubs for oe-setup-build and bitbake-config-build. This data is used to create temporary git repositories then clone them via local filesystem URIs. Later on this can be supplemented by an oe-selftest that tests bitbake-setup against real config files in the official configuration repository and real layers, templates and fragments. (Bitbake rev: e3aa3eb46bd3196fa5415fa36e3737636fd6a1c0) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2.0 KiB
Executable File
#!/usr/bin/env python3
Copyright (C) 2012 Richard Purdie
SPDX-License-Identifier: GPL-2.0-only
import os import sys, logging import warnings warnings.simplefilter("default") sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(file)), 'lib'))
import unittest try: import bb import hashserv import prserv import layerindexlib except RuntimeError as exc: sys.exit(str(exc))
tests = ["bb.tests.codeparser", "bb.tests.color", "bb.tests.cooker", "bb.tests.cow", "bb.tests.data", "bb.tests.event", "bb.tests.fetch", "bb.tests.parse", "bb.tests.runqueue", "bb.tests.setup", "bb.tests.siggen", "bb.tests.utils", "bb.tests.compression", "bb.tests.filter", "hashserv.tests", "prserv.tests", "layerindexlib.tests.layerindexobj", "layerindexlib.tests.restapi", "layerindexlib.tests.cooker"]
for t in tests: t = '.'.join(t.split('.')[:3]) import(t)
Set-up logging
class StdoutStreamHandler(logging.StreamHandler): """Special handler so that unittest is able to capture stdout""" def init(self): # Override init() because we don't want to set self.stream here logging.Handler.init(self)
@property
def stream(self):
# We want to dynamically write wherever sys.stdout is pointing to
return sys.stdout
handler = StdoutStreamHandler() bb.logger.addHandler(handler) bb.logger.setLevel(logging.DEBUG)
ENV_HELP = """
Environment variables:
BB_SKIP_NETTESTS set to 'yes' in order to skip tests using network
connection
BB_TMPDIR_NOCLEAN set to 'yes' to preserve test tmp directories
"""
class main(unittest.main): def _print_help(self, *args, **kwargs): super(main, self)._print_help(*args, **kwargs) print(ENV_HELP)
if name == 'main': main(defaultTest=tests, buffer=True)