diff options
-rw-r--r-- | meta/classes-recipe/rootfs-postcommands.bbclass | 3 | ||||
-rw-r--r-- | meta/lib/oe/data.py | 9 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/rootfspostcommandstests.py | 19 |
3 files changed, 28 insertions, 3 deletions
diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass index 690fa976aae..b91498c32ec 100644 --- a/meta/classes-recipe/rootfs-postcommands.bbclass +++ b/meta/classes-recipe/rootfs-postcommands.bbclass @@ -386,7 +386,8 @@ python write_image_test_data() { os.remove(testdata_link) os.symlink(os.path.basename(testdata_name), testdata_link) } -write_image_test_data[vardepsexclude] += "TOPDIR" +write_image_test_data[vardeps] += "${@' '.join(oe.data.exportkeys(d))}" +write_image_test_data[vardepsexclude] += "TOPDIR DATETIME BUILDNAME ${BB_HASHCONFIG_IGNORE_VARS}" # Check for unsatisfied recommendations (RRECOMMENDS) python rootfs_log_check_recommends() { diff --git a/meta/lib/oe/data.py b/meta/lib/oe/data.py index 37121cfad2b..99892306381 100644 --- a/meta/lib/oe/data.py +++ b/meta/lib/oe/data.py @@ -23,8 +23,7 @@ def typed_value(key, d): except (TypeError, ValueError) as exc: bb.msg.fatal("Data", "%s: %s" % (key, str(exc))) -def export2json(d, json_file, expand=True, searchString="",replaceString=""): - data2export = {} +def exportkeys(d): keys2export = [] for key in d.keys(): @@ -41,6 +40,12 @@ def export2json(d, json_file, expand=True, searchString="",replaceString=""): keys2export.append(key) + return keys2export + +def export2json(d, json_file, expand=True, searchString="",replaceString=""): + data2export = {} + keys2export = exportkeys(d) + for key in keys2export: try: data2export[key] = d.getVar(key, expand).replace(searchString,replaceString) diff --git a/meta/lib/oeqa/selftest/cases/rootfspostcommandstests.py b/meta/lib/oeqa/selftest/cases/rootfspostcommandstests.py index 44e2c09a6f8..5de4ea378a3 100644 --- a/meta/lib/oeqa/selftest/cases/rootfspostcommandstests.py +++ b/meta/lib/oeqa/selftest/cases/rootfspostcommandstests.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: MIT +import json import os import oe import unittest @@ -95,3 +96,21 @@ class ShadowUtilsTidyFiles(OESelftestTestCase): unsorted.append(file) if (unsorted): raise Exception("The following files were not sorted by ID as expected: %s" % unsorted) + + +class TestDataTests(OESelftestTestCase): + def test_vardeps(self): + """ + Test that variables changes are reflected in testdata.json + """ + test_image = "core-image-minimal" + self.write_config('TEST_VARIABLE = "VALUE1"') + bitbake(test_image) + self.write_config('TEST_VARIABLE = "VALUE2"') + bitbake(test_image) + + vars = get_bb_vars(('DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'), test_image) + testdata_json = "%s/%s.testdata.json" % (vars['DEPLOY_DIR_IMAGE'], vars['IMAGE_LINK_NAME']) + with open(testdata_json, 'r') as tf: + testdata_vars = json.load(tf) + self.assertEqual(testdata_vars['TEST_VARIABLE'], 'VALUE2') |