@@ -6,6 +6,8 @@
from bb.tests.fetch import FetcherTest
import json
+import hashlib
+import glob
class BitbakeSetupTest(FetcherTest):
def setUp(self):
@@ -360,3 +362,36 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0])
self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0])
self.check_setupdir_files(setuppath, test_file_content)
+
+ # do the same as the previous test, but now without updating the bitbake configuration (--update-bb-conf=no)
+ # and check that files have not been modified
+
+ def _conf_chksum(confdir: str) -> list:
+ sums = []
+ for f in glob.glob(f'{confdir}/*'):
+ if not os.path.islink(f):
+ with open(f, 'rb') as fd:
+ sum = os.path.basename(f) + '_' + hashlib.file_digest(fd, "sha256").hexdigest()
+ sums.append(sum)
+ return sums
+
+ prev_test_file_content = test_file_content
+ test_file_content = 'modified-in-branch-no-bb-conf-update\n'
+ branch = "another-branch-no-bb-conf-update"
+ self.git('checkout -b {}'.format(branch), cwd=self.testrepopath)
+ self.add_file_to_testrepo('test-file', test_file_content)
+ json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch, branch)
+ for c in ('gadget', 'gizmo',
+ 'gizmo-env-passthrough',
+ 'gizmo-no-fragment',
+ 'gadget-notemplate', 'gizmo-notemplate'):
+ setuppath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c))
+ os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+ # write something in local.conf and bblayers.conf
+ for f in ["local.conf", "bblayers.conf"]:
+ with open(f"{setuppath}/build/conf/{f}", "w") as fd:
+ fd.write("deadbeef")
+ sums_before = _conf_chksum(f"{setuppath}/build/conf")
+ out = self.runbbsetup("update --update-bb-conf='no'")
+ sums_after = _conf_chksum(f"{setuppath}/build/conf")
+ self.assertEqual(sums_before, sums_after)
We want to check that with --update-bb-conf set to 'no' our BitBake configuration remains unchanged. For this create a list of checksums of the files in conf/ and compare before/after bitbake-setup update --update-bb-conf=no. Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> --- lib/bb/tests/setup.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)