From: Peter Hoyes <[email protected]> The testdata.json file generated as part of the rootfs postprocess commands contains almost all Bitbake variables and is used by OEQA test cases to inspect the build environment. However it is not automatically regenerated, complicating the process of developing OEQA test cases.
Set nostamp on the new do_write_image_test_data task so that it always runs. Add a demonstrative OE selftest. Signed-off-by: Peter Hoyes <[email protected]> --- meta/classes-recipe/testimage.bbclass | 1 + meta/lib/oeqa/selftest/cases/testimage.py | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/testimage.py diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index b23340420f..67f7f3629e 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass @@ -118,6 +118,7 @@ python do_write_image_test_data() { os.remove(testdata_link) os.symlink(os.path.basename(testdata_name), testdata_link) } +do_write_image_test_data[nostamp] = "1" do_write_image_test_data[vardepsexclude] += "TOPDIR" addtask write_image_test_data after do_rootfs before do_image_complete diff --git a/meta/lib/oeqa/selftest/cases/testimage.py b/meta/lib/oeqa/selftest/cases/testimage.py new file mode 100644 index 0000000000..3ba9184821 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/testimage.py @@ -0,0 +1,26 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import json +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake, get_bb_vars + +class TestDataTests(OESelftestTestCase): + def test_regenerate(self): + """ + Test that variables changes are reflected in testdata.json + """ + test_image = "core-image-minimal" + self.write_config('IMAGE_CLASSES += "testimage"\nTEST_VARIABLE = "VALUE1"') + bitbake(test_image) + self.append_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') -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#182705): https://lists.openembedded.org/g/openembedded-core/message/182705 Mute This Topic: https://lists.openembedded.org/mt/99501790/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
