From: Alexander Kanavin <alex.kanavin@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Alexander Kanavin <alex@linutronix.de>
Subject: [PATCH 5/5] bitbake-setup: add tests for update scenarios fixed in the previous commit
Date: Fri, 9 Jan 2026 14:20:00 +0100 [thread overview]
Message-ID: <20260109132000.2372791-5-alex.kanavin@gmail.com> (raw)
In-Reply-To: <20260109132000.2372791-1-alex.kanavin@gmail.com>
From: Alexander Kanavin <alex@linutronix.de>
This adds tests for the issues fixed in the previous commits:
- transitions in sources from remote to local, from local to local and from local to remote
- ensuring that local commits in sources are restricted
- ensuring that source backups do happen when that is expected.
Add a helper function that adds a test configuration with a local source in it.
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
lib/bb/tests/setup.py | 68 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py
index 438dc0cd8..834d09854 100644
--- a/lib/bb/tests/setup.py
+++ b/lib/bb/tests/setup.py
@@ -175,6 +175,16 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
""" % (self.testrepopath, branch, rev)
return self._add_json_config_to_registry_helper(name, sources)
+ def add_local_json_config_to_registry(self, name, path):
+ sources = """
+ "test-repo": {
+ "local": {
+ "path": "%s"
+ }
+ }
+""" % (path)
+ return self._add_json_config_to_registry_helper(name, sources)
+
def add_file_to_testrepo(self, name, content, script=False):
fullname = os.path.join(self.testrepopath, name)
os.makedirs(os.path.join(self.testrepopath, os.path.dirname(name)), exist_ok=True)
@@ -413,7 +423,6 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
sums_after = _conf_chksum(f"{setuppath}/build/conf")
self.assertEqual(sums_before, sums_after)
- # check source overrides, local sources provided with symlinks, and custom setup dir name
def _check_local_sources(custom_setup_dir):
custom_setup_path = os.path.join(self.tempdir, 'bitbake-builds', custom_setup_dir)
custom_layer_path = os.path.join(custom_setup_path, 'layers', 'test-repo')
@@ -421,6 +430,63 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
self.assertEqual(self.testrepopath, os.path.realpath(custom_layer_path))
self.config_is_unchanged(custom_setup_path)
+ # Change the configuration to refer to a local source, then to another local source, then back to a git remote
+ # Run status/update after each change and verify that nothing breaks
+ c = 'gadget'
+ setuppath = self.get_setup_path('test-config-1', c)
+ self.config_is_unchanged(setuppath)
+
+ json_1 = self.add_local_json_config_to_registry('test-config-1.conf.json', self.testrepopath)
+ os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+ out = self.runbbsetup("update --update-bb-conf='yes'")
+ _check_local_sources(setuppath)
+
+ prev_path = self.testrepopath
+ self.testrepopath = prev_path + "-2"
+ self.git("clone {} {}".format(prev_path, self.testrepopath), cwd=self.tempdir)
+ json_1 = self.add_local_json_config_to_registry('test-config-1.conf.json', self.testrepopath)
+ os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+ out = self.runbbsetup("update --update-bb-conf='yes'")
+ _check_local_sources(setuppath)
+
+ self.testrepopath = prev_path
+ json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch, branch)
+ os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+ out = self.runbbsetup("update --update-bb-conf='yes'")
+ self.check_setupdir_files(setuppath, test_file_content)
+
+ # Also check that there are no layer backups up to this point, then make a change that should
+ # result in a layer backup, and check that it does happen.
+ def _check_layer_backups(layer_path, expected_backups):
+ files = os.listdir(layer_path)
+ backups = len([f for f in files if 'backup' in f])
+ self.assertEqual(backups, expected_backups, msg = "Expected {} layer backups, got {}, directory listing: {}".format(expected_backups, backups, files))
+
+ layers_path = os.path.join(setuppath, 'layers')
+ layer_path = os.path.join(layers_path, 'test-repo')
+ _check_layer_backups(layers_path, 0)
+
+ ## edit a file without making a commit
+ with open(os.path.join(layer_path, 'local-modification'), 'w') as f:
+ f.write('locally-modified\n')
+ test_file_content = "modified-again\n"
+ self.add_file_to_testrepo('test-file', test_file_content)
+ os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+ out = self.runbbsetup("update --update-bb-conf='yes'")
+ _check_layer_backups(layers_path, 1)
+
+ ## edit a file and try to make a commit; this should be rejected
+ with open(os.path.join(layer_path, 'local-modification'), 'w') as f:
+ f.write('locally-modified-again\n')
+ self.git('add .', cwd=layer_path)
+ with self.assertRaisesRegex(bb.process.ExecutionError, "making commits is restricted"):
+ self.git('commit -m "Adding a local modification"', cwd=layer_path)
+ test_file_content = "modified-again-and-again\n"
+ self.add_file_to_testrepo('test-file', test_file_content)
+ out = self.runbbsetup("update --update-bb-conf='yes'")
+ _check_layer_backups(layers_path, 2)
+
+ # check source overrides, local sources provided with symlinks, and custom setup dir name
source_override_content = """
{
"sources": {
--
2.47.3
next prev parent reply other threads:[~2026-01-09 13:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 13:19 [PATCH 1/5] doc: document fixed revisions override in bitbake-setup manual Alexander Kanavin
2026-01-09 13:19 ` [PATCH 2/5] bitbake-setup: ensure paths with timestamps in them are unique Alexander Kanavin
2026-01-15 12:03 ` [bitbake-devel] " Quentin Schulz
2026-01-15 12:24 ` Alexander Kanavin
2026-01-09 13:19 ` [PATCH 3/5] bitbake-setup: allow empty commits in configuration history repo Alexander Kanavin
2026-01-09 13:19 ` [PATCH 4/5] bitbake-setup: correct several scenarios in layer updates Alexander Kanavin
2026-01-09 13:20 ` Alexander Kanavin [this message]
2026-01-15 11:50 ` [bitbake-devel] [PATCH 1/5] doc: document fixed revisions override in bitbake-setup manual Quentin Schulz
2026-01-15 11:58 ` Alexander Kanavin
2026-01-15 12:59 ` Antonin Godard
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=20260109132000.2372791-5-alex.kanavin@gmail.com \
--to=alex.kanavin@gmail.com \
--cc=alex@linutronix.de \
--cc=bitbake-devel@lists.openembedded.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox