summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2023-10-23 13:06:16 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-27 10:53:43 +0100
commit2187e823ad66eaaee6a4ed7d748f2c68028a45e7 (patch)
treea668f076ef4531d0c38b4a57bdb94e9de766a9c8 /meta/lib
parent7e0cce4f6b754e33a0652b516d622b6b40b3abd7 (diff)
downloadpoky-2187e823ad66eaaee6a4ed7d748f2c68028a45e7.tar.gz
selftest/sstatetests: add tests for 'bitbake -S printdiff'
'bitbake -S printdiff' is a useful diagnostic facility for finding out why sstate is not being reused, but until now it had no tests that would ensure it works. This commit adds three basic scenarios: 1. make a change in a really basic, common recipe that is at the very root of dependency trees (quilt-native), and ensure that change is correctly discovered when building an image. 2. make a change in gcc-source recipe, which is somewhat special (operates in work-shared), and ensure that gcc-runtime builds track that down as well. 3. make a change in base_do_configure() definition from base.bbclass, which is not recipe-specific, but affects many basic recipes, and ensure that is correctly reported as well. The test itself actually runs twice: - first against a fully populated build directory, where the printdiff code is guaranteed to find the correct previous stamp that can be compared with in a predictable manner. - then in an empty build directory where the printdiff code goes to look in the sstate cache, and so the existence of the previous signature can be tested, but not the difference with it (what the exact difference would be is unpredictable as the sstate cache is indeed shared between many builds). (From OE-Core rev: 7a7d76aa8a8d590ebc99156f9f4b9535cdf868c7) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/sstatetests.py113
1 files changed, 113 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py
index bdad9088d3..b96eacc9ad 100644
--- a/meta/lib/oeqa/selftest/cases/sstatetests.py
+++ b/meta/lib/oeqa/selftest/cases/sstatetests.py
@@ -773,3 +773,116 @@ addtask tmptask2 before do_tmptask1
773 latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:] 773 latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:]
774 bb.siggen.compare_sigfiles(latestfiles[-2], latestfiles[-1], recursecb) 774 bb.siggen.compare_sigfiles(latestfiles[-2], latestfiles[-1], recursecb)
775 self.assertEqual(recursecb_count,1) 775 self.assertEqual(recursecb_count,1)
776
777class SStatePrintdiff(SStateBase):
778 # FIXME: OEBasicHash setting is necessary for now as otherwise the following error can occur:
779 # ERROR: Can't find a task we're supposed to have written out? (hash: e79d70b9c2cc72030c1ce822525510699a1eeb1ddf5986271d3217422244366a)?
780 # The underlying issue should be investigated and addressed.
781 def run_test_printdiff_changerecipe(self, target, change_recipe, change_bbtask, change_content, expected_sametmp_output, expected_difftmp_output):
782 self.write_config("""
783TMPDIR = "${TOPDIR}/tmp-sstateprintdiff"
784BB_SIGNATURE_HANDLER = "OEBasicHash"
785""")
786 self.track_for_cleanup(self.topdir + "/tmp-sstateprintdiff")
787 bitbake(target)
788 bitbake("-S none {}".format(target))
789 bitbake(change_bbtask)
790 self.write_recipeinc(change_recipe, change_content)
791 result_sametmp = bitbake("-S printdiff {}".format(target))
792
793 self.write_config("""
794TMPDIR = "${TOPDIR}/tmp-sstateprintdiff-2"
795BB_SIGNATURE_HANDLER = "OEBasicHash"
796""")
797 self.track_for_cleanup(self.topdir + "/tmp-sstateprintdiff-2")
798 result_difftmp = bitbake("-S printdiff {}".format(target))
799
800 self.delete_recipeinc(change_recipe)
801 for item in expected_sametmp_output:
802 self.assertIn(item, result_sametmp.output)
803 for item in expected_difftmp_output:
804 self.assertIn(item, result_difftmp.output)
805
806 def run_test_printdiff_changeconfig(self, target, change_content, expected_sametmp_output, expected_difftmp_output):
807 self.write_config("""
808TMPDIR = "${TOPDIR}/tmp-sstateprintdiff"
809BB_SIGNATURE_HANDLER = "OEBasicHash"
810""")
811 self.track_for_cleanup(self.topdir + "/tmp-sstateprintdiff")
812 bitbake(target)
813 bitbake("-S none {}".format(target))
814 self.append_config(change_content)
815 result_sametmp = bitbake("-S printdiff {}".format(target))
816
817 self.write_config("""
818TMPDIR = "${TOPDIR}/tmp-sstateprintdiff-2"
819BB_SIGNATURE_HANDLER = "OEBasicHash"
820""")
821 self.append_config(change_content)
822 self.track_for_cleanup(self.topdir + "/tmp-sstateprintdiff-2")
823 result_difftmp = bitbake("-S printdiff {}".format(target))
824
825 for item in expected_sametmp_output:
826 self.assertIn(item, result_sametmp.output)
827 for item in expected_difftmp_output:
828 self.assertIn(item, result_difftmp.output)
829
830
831 # Check if printdiff walks the full dependency chain from the image target to where the change is in a specific recipe
832 def test_image_minimal_vs_quilt(self):
833 expected_output = ("Task quilt-native:do_install couldn't be used from the cache because:",
834"We need hash",
835"most recent matching task was")
836 expected_sametmp_output = expected_output + ("Variable do_install value changed",'+ echo "this changes the task signature"')
837 expected_difftmp_output = expected_output
838
839 self.run_test_printdiff_changerecipe("core-image-minimal", "quilt-native", "-c do_install quilt-native",
840"""
841do_install:append() {
842 echo "this changes the task signature"
843}
844""",
845expected_sametmp_output, expected_difftmp_output)
846
847 # Check if changes to gcc-source (which uses tmp/work-shared) are correctly discovered
848 def test_gcc_runtime_vs_gcc_source(self):
849 gcc_source_pn = 'gcc-source-%s' % get_bb_vars(['PV'], 'gcc')['PV']
850
851 expected_output = ("Task {}:do_preconfigure couldn't be used from the cache because:".format(gcc_source_pn),
852"We need hash",
853"most recent matching task was")
854 expected_sametmp_output = expected_output + ("Variable do_preconfigure value changed",'+ print("this changes the task signature")')
855 #FIXME: printdiff is supposed to find at least one preconfigure task signature in the sstate cache, but isn't able to
856 #expected_difftmp_output = expected_output
857 expected_difftmp_output = ()
858
859 self.run_test_printdiff_changerecipe("gcc-runtime", "gcc-source", "-c do_preconfigure {}".format(gcc_source_pn),
860"""
861python do_preconfigure:append() {
862 print("this changes the task signature")
863}
864""",
865expected_sametmp_output, expected_difftmp_output)
866
867 # Check if changing a really base task definiton is reported against multiple core recipes using it
868 def test_image_minimal_vs_base_do_configure(self):
869 expected_output = ("Task zstd-native:do_configure couldn't be used from the cache because:",
870"Task texinfo-dummy-native:do_configure couldn't be used from the cache because:",
871"Task ldconfig-native:do_configure couldn't be used from the cache because:",
872"Task gettext-minimal-native:do_configure couldn't be used from the cache because:",
873"Task tzcode-native:do_configure couldn't be used from the cache because:",
874"Task makedevs-native:do_configure couldn't be used from the cache because:",
875"Task pigz-native:do_configure couldn't be used from the cache because:",
876"Task update-rc.d-native:do_configure couldn't be used from the cache because:",
877"Task unzip-native:do_configure couldn't be used from the cache because:",
878"Task gnu-config-native:do_configure couldn't be used from the cache because:",
879"We need hash",
880"most recent matching task was")
881 expected_sametmp_output = expected_output + ("Variable base_do_configure value changed",'+ echo "this changes base_do_configure() definiton"')
882 expected_difftmp_output = expected_output
883
884 self.run_test_printdiff_changeconfig("core-image-minimal",
885"""
886INHERIT += "base-do-configure-modified"
887""",
888expected_sametmp_output, expected_difftmp_output)