mirror of
https://git.yoctoproject.org/poky
synced 2026-04-30 03:32:12 +02:00
oeqa/selftest/sstate: Move common code to base class
Move the other common shares test functions to the base class to improve the code structure. (From OE-Core rev: de3e6f85c5537a3571ffbe2326b73f2c2526bce2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -71,6 +71,112 @@ class SStateBase(OESelftestTestCase):
|
||||
result.append(f)
|
||||
return result
|
||||
|
||||
# Test sstate files creation and their location
|
||||
def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
if self.temp_sstate_location:
|
||||
bitbake(['-cclean'] + targets)
|
||||
else:
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
file_tracker = []
|
||||
results = self.search_sstate('|'.join(map(str, targets)), distro_specific, distro_nonspecific)
|
||||
if distro_nonspecific:
|
||||
for r in results:
|
||||
if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo", "_fetch.tar.zst.siginfo", "_unpack.tar.zst.siginfo", "_patch.tar.zst.siginfo")):
|
||||
continue
|
||||
file_tracker.append(r)
|
||||
else:
|
||||
file_tracker = results
|
||||
|
||||
if should_pass:
|
||||
self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets)))
|
||||
else:
|
||||
self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker)))
|
||||
|
||||
# Test the sstate files deletion part of the do_cleansstate task
|
||||
def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
archives_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(archives_created, msg="Could not find sstate .tar.zst files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_created)))
|
||||
|
||||
siginfo_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created)))
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
archives_removed = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(not archives_removed, msg="do_cleansstate didn't remove .tar.zst sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_removed)))
|
||||
|
||||
# Test rebuilding of distro-specific sstate files
|
||||
def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
results = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=False, distro_nonspecific=True)
|
||||
filtered_results = []
|
||||
for r in results:
|
||||
if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo")):
|
||||
continue
|
||||
filtered_results.append(r)
|
||||
self.assertTrue(filtered_results == [], msg="Found distro non-specific sstate for: %s (%s)" % (', '.join(map(str, targets)), str(filtered_results)))
|
||||
file_tracker_1 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False)
|
||||
self.assertTrue(len(file_tracker_1) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets)))
|
||||
|
||||
self.track_for_cleanup(self.distro_specific_sstate + "_old")
|
||||
shutil.copytree(self.distro_specific_sstate, self.distro_specific_sstate + "_old")
|
||||
shutil.rmtree(self.distro_specific_sstate)
|
||||
|
||||
bitbake(['-cclean'] + targets)
|
||||
bitbake(targets)
|
||||
file_tracker_2 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False)
|
||||
self.assertTrue(len(file_tracker_2) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets)))
|
||||
|
||||
not_recreated = [x for x in file_tracker_1 if x not in file_tracker_2]
|
||||
self.assertTrue(not_recreated == [], msg="The following sstate files were not recreated: %s" % ', '.join(map(str, not_recreated)))
|
||||
|
||||
created_once = [x for x in file_tracker_2 if x not in file_tracker_1]
|
||||
self.assertTrue(created_once == [], msg="The following sstate files were created only in the second run: %s" % ', '.join(map(str, created_once)))
|
||||
|
||||
def sstate_common_samesigs(self, configA, configB, allarch=False):
|
||||
|
||||
self.write_config(configA)
|
||||
self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash")
|
||||
bitbake("world meta-toolchain -S none")
|
||||
self.write_config(configB)
|
||||
self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2")
|
||||
bitbake("world meta-toolchain -S none")
|
||||
|
||||
def get_files(d, result):
|
||||
for root, dirs, files in os.walk(d):
|
||||
for name in files:
|
||||
if "meta-environment" in root or "cross-canadian" in root:
|
||||
continue
|
||||
if "do_build" not in name:
|
||||
# 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79
|
||||
(_, task, _, shash) = name.rsplit(".", 3)
|
||||
result[os.path.join(os.path.basename(root), task)] = shash
|
||||
|
||||
files1 = {}
|
||||
files2 = {}
|
||||
subdirs = sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux"))
|
||||
if allarch:
|
||||
subdirs.extend(sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/all-*-linux")))
|
||||
|
||||
for subdir in subdirs:
|
||||
nativesdkdir = os.path.basename(subdir)
|
||||
get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir, files1)
|
||||
get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir, files2)
|
||||
|
||||
self.maxDiff = None
|
||||
self.assertEqual(files1, files2)
|
||||
|
||||
class SStateTests(SStateBase):
|
||||
def test_autorev_sstate_works(self):
|
||||
@@ -111,32 +217,6 @@ class SStateTests(SStateBase):
|
||||
result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir)
|
||||
bitbake("dbus-wait-test -c unpack")
|
||||
|
||||
|
||||
# Test sstate files creation and their location
|
||||
def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
if self.temp_sstate_location:
|
||||
bitbake(['-cclean'] + targets)
|
||||
else:
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
file_tracker = []
|
||||
results = self.search_sstate('|'.join(map(str, targets)), distro_specific, distro_nonspecific)
|
||||
if distro_nonspecific:
|
||||
for r in results:
|
||||
if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo", "_fetch.tar.zst.siginfo", "_unpack.tar.zst.siginfo", "_patch.tar.zst.siginfo")):
|
||||
continue
|
||||
file_tracker.append(r)
|
||||
else:
|
||||
file_tracker = results
|
||||
|
||||
if should_pass:
|
||||
self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets)))
|
||||
else:
|
||||
self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker)))
|
||||
|
||||
def test_sstate_creation_distro_specific_pass(self):
|
||||
self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True)
|
||||
|
||||
@@ -149,23 +229,6 @@ class SStateTests(SStateBase):
|
||||
def test_sstate_creation_distro_nonspecific_fail(self):
|
||||
self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False)
|
||||
|
||||
# Test the sstate files deletion part of the do_cleansstate task
|
||||
def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
archives_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(archives_created, msg="Could not find sstate .tar.zst files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_created)))
|
||||
|
||||
siginfo_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created)))
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
archives_removed = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific)
|
||||
self.assertTrue(not archives_removed, msg="do_cleansstate didn't remove .tar.zst sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_removed)))
|
||||
|
||||
def test_cleansstate_task_distro_specific_nonspecific(self):
|
||||
targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native']
|
||||
targets.append('linux-libc-headers')
|
||||
@@ -180,38 +243,6 @@ class SStateTests(SStateBase):
|
||||
self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True)
|
||||
|
||||
|
||||
# Test rebuilding of distro-specific sstate files
|
||||
def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True):
|
||||
self.config_sstate(temp_sstate_location, [self.sstate_path])
|
||||
|
||||
bitbake(['-ccleansstate'] + targets)
|
||||
|
||||
bitbake(targets)
|
||||
results = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=False, distro_nonspecific=True)
|
||||
filtered_results = []
|
||||
for r in results:
|
||||
if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo")):
|
||||
continue
|
||||
filtered_results.append(r)
|
||||
self.assertTrue(filtered_results == [], msg="Found distro non-specific sstate for: %s (%s)" % (', '.join(map(str, targets)), str(filtered_results)))
|
||||
file_tracker_1 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False)
|
||||
self.assertTrue(len(file_tracker_1) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets)))
|
||||
|
||||
self.track_for_cleanup(self.distro_specific_sstate + "_old")
|
||||
shutil.copytree(self.distro_specific_sstate, self.distro_specific_sstate + "_old")
|
||||
shutil.rmtree(self.distro_specific_sstate)
|
||||
|
||||
bitbake(['-cclean'] + targets)
|
||||
bitbake(targets)
|
||||
file_tracker_2 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False)
|
||||
self.assertTrue(len(file_tracker_2) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets)))
|
||||
|
||||
not_recreated = [x for x in file_tracker_1 if x not in file_tracker_2]
|
||||
self.assertTrue(not_recreated == [], msg="The following sstate files were not recreated: %s" % ', '.join(map(str, not_recreated)))
|
||||
|
||||
created_once = [x for x in file_tracker_2 if x not in file_tracker_1]
|
||||
self.assertTrue(created_once == [], msg="The following sstate files were created only in the second run: %s" % ', '.join(map(str, created_once)))
|
||||
|
||||
def test_rebuild_distro_specific_sstate_cross_native_targets(self):
|
||||
self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch, 'binutils-native'], temp_sstate_location=True)
|
||||
|
||||
@@ -433,38 +464,6 @@ BB_SIGNATURE_HANDLER = "OEBasicHash"
|
||||
"""
|
||||
self.sstate_common_samesigs(configA, configB)
|
||||
|
||||
def sstate_common_samesigs(self, configA, configB, allarch=False):
|
||||
|
||||
self.write_config(configA)
|
||||
self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash")
|
||||
bitbake("world meta-toolchain -S none")
|
||||
self.write_config(configB)
|
||||
self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2")
|
||||
bitbake("world meta-toolchain -S none")
|
||||
|
||||
def get_files(d, result):
|
||||
for root, dirs, files in os.walk(d):
|
||||
for name in files:
|
||||
if "meta-environment" in root or "cross-canadian" in root:
|
||||
continue
|
||||
if "do_build" not in name:
|
||||
# 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79
|
||||
(_, task, _, shash) = name.rsplit(".", 3)
|
||||
result[os.path.join(os.path.basename(root), task)] = shash
|
||||
|
||||
files1 = {}
|
||||
files2 = {}
|
||||
subdirs = sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux"))
|
||||
if allarch:
|
||||
subdirs.extend(sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/all-*-linux")))
|
||||
|
||||
for subdir in subdirs:
|
||||
nativesdkdir = os.path.basename(subdir)
|
||||
get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir, files1)
|
||||
get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir, files2)
|
||||
|
||||
self.maxDiff = None
|
||||
self.assertEqual(files1, files2)
|
||||
|
||||
def test_sstate_sametune_samesigs(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user