From a59cd1502ff14c5d8ccb04385bf4a3ad338d998d Mon Sep 17 00:00:00 2001 From: Yang Xu Date: Sat, 5 Aug 2023 13:50:41 +0100 Subject: [PATCH] oeqa/selftest/ssate: Add test for find_siginfo Previously some dependencies couldn't be followed through their siginfo files. This has been fixed, add a test to ensure this doesn't regress. Signed-off-by: Yang Xu --- .../recipes-test/binutils/binutils_%.bbappend | 2 + meta/lib/oeqa/selftest/cases/sstatetests.py | 83 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 meta-selftest/recipes-test/binutils/binutils_%.bbappend diff --git a/meta-selftest/recipes-test/binutils/binutils_%.bbappend b/meta-selftest/recipes-test/binutils/binutils_%.bbappend new file mode 100644 index 00000000000..205720982cb --- /dev/null +++ b/meta-selftest/recipes-test/binutils/binutils_%.bbappend @@ -0,0 +1,2 @@ +# This bbappend is used to alter the recipe using the test_recipe.inc file created by tests. +include test_recipe.inc diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index febafdb2f7a..3fa3038218c 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -691,3 +691,86 @@ TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" self.maxDiff = None self.assertCountEqual(files1, files2) +class SStateFindSiginfo(SStateBase): + def test_sstate_compare_sigfiles_and_find_siginfo(self): + """ + Test the functionality of the find_siginfo: basic function and callback in compare_sigfiles + """ + self.write_config(""" +TMPDIR = \"${TOPDIR}/tmp-sstates-findsiginfo\" +TCLIBCAPPEND = \"\" +MACHINE = \"qemux86-64\" +require conf/multilib.conf +MULTILIBS = "multilib:lib32" +DEFAULTTUNE:virtclass-multilib-lib32 = "x86" +BB_SIGNATURE_HANDLER = "OEBasicHash" +""") + self.track_for_cleanup(self.topdir + "/tmp-sstates-findsiginfo") + + pns = ["binutils", "binutils-native", "lib32-binutils"] + target_configs = [ +""" +TMPVAL1 = "tmpval1" +TMPVAL2 = "tmpval2" +do_tmptask1() { + echo ${TMPVAL1} +} +do_tmptask2() { + echo ${TMPVAL2} +} +addtask do_tmptask1 +addtask tmptask2 before do_tmptask1 +""", +""" +TMPVAL3 = "tmpval3" +TMPVAL4 = "tmpval4" +do_tmptask1() { + echo ${TMPVAL3} +} +do_tmptask2() { + echo ${TMPVAL4} +} +addtask do_tmptask1 +addtask tmptask2 before do_tmptask1 +""" + ] + + for target_config in target_configs: + self.write_recipeinc("binutils", target_config) + for pn in pns: + bitbake("%s -c do_tmptask1 -S none" % pn) + self.delete_recipeinc("binutils") + + with bb.tinfoil.Tinfoil() as tinfoil: + tinfoil.prepare(config_only=True) + + def find_siginfo(pn, taskname, sigs=None): + result = None + tinfoil.set_event_mask(["bb.event.FindSigInfoResult", + "bb.command.CommandCompleted"]) + ret = tinfoil.run_command("findSigInfo", pn, taskname, sigs) + if ret: + while True: + event = tinfoil.wait_event(1) + if event: + if isinstance(event, bb.command.CommandCompleted): + break + elif isinstance(event, bb.event.FindSigInfoResult): + result = event.result + return result + + def recursecb(key, hash1, hash2): + nonlocal recursecb_count + recursecb_count += 1 + hashes = [hash1, hash2] + hashfiles = find_siginfo(key, None, hashes) + self.assertCountEqual(hashes, hashfiles) + bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) + + for pn in pns: + recursecb_count = 0 + filedates = find_siginfo(pn, "do_tmptask1") + self.assertGreaterEqual(len(filedates), 2) + latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:] + bb.siggen.compare_sigfiles(latestfiles[-2], latestfiles[-1], recursecb) + self.assertEqual(recursecb_count,1) -- 2.47.3