diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-03-12 11:29:27 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-03-13 17:35:22 +0000 |
| commit | a4c484b8cb2ec0eb82b8b0855532cadedb2fac97 (patch) | |
| tree | e8e90bed5085d2c27f0c5ae690f565aa4165688d /meta/lib/oeqa/selftest/cases/sstatetests.py | |
| parent | 4eb546cf1c2780b7870ba4d6e1a51bd096987fe8 (diff) | |
| download | poky-a4c484b8cb2ec0eb82b8b0855532cadedb2fac97.tar.gz | |
oeqa/selftest/sstate: Merge sstate test class with tests themselves
Having this base class as a separate file is just confusing. Merge with
the rest of the test code.
(From OE-Core rev: 977522a3b063225e22e2fd04b8265a4595606db2)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/sstatetests.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/sstatetests.py | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index ae766f91bd..a6a688cc19 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py | |||
| @@ -9,13 +9,69 @@ import shutil | |||
| 9 | import glob | 9 | import glob |
| 10 | import subprocess | 10 | import subprocess |
| 11 | import tempfile | 11 | import tempfile |
| 12 | import datetime | ||
| 13 | import re | ||
| 12 | 14 | ||
| 13 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer | 15 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer, get_bb_vars |
| 14 | from oeqa.selftest.cases.sstate import SStateBase | 16 | from oeqa.selftest.case import OESelftestTestCase |
| 15 | import oe | ||
| 16 | 17 | ||
| 18 | import oe | ||
| 17 | import bb.siggen | 19 | import bb.siggen |
| 18 | 20 | ||
| 21 | class SStateBase(OESelftestTestCase): | ||
| 22 | |||
| 23 | def setUpLocal(self): | ||
| 24 | super(SStateBase, self).setUpLocal() | ||
| 25 | self.temp_sstate_location = None | ||
| 26 | needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', 'TCLIBC', 'TUNE_ARCH', | ||
| 27 | 'TOPDIR', 'TARGET_VENDOR', 'TARGET_OS'] | ||
| 28 | bb_vars = get_bb_vars(needed_vars) | ||
| 29 | self.sstate_path = bb_vars['SSTATE_DIR'] | ||
| 30 | self.hostdistro = bb_vars['NATIVELSBSTRING'] | ||
| 31 | self.tclibc = bb_vars['TCLIBC'] | ||
| 32 | self.tune_arch = bb_vars['TUNE_ARCH'] | ||
| 33 | self.topdir = bb_vars['TOPDIR'] | ||
| 34 | self.target_vendor = bb_vars['TARGET_VENDOR'] | ||
| 35 | self.target_os = bb_vars['TARGET_OS'] | ||
| 36 | self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro) | ||
| 37 | |||
| 38 | # Creates a special sstate configuration with the option to add sstate mirrors | ||
| 39 | def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]): | ||
| 40 | self.temp_sstate_location = temp_sstate_location | ||
| 41 | |||
| 42 | if self.temp_sstate_location: | ||
| 43 | temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S')) | ||
| 44 | config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path | ||
| 45 | self.append_config(config_temp_sstate) | ||
| 46 | self.track_for_cleanup(temp_sstate_path) | ||
| 47 | bb_vars = get_bb_vars(['SSTATE_DIR', 'NATIVELSBSTRING']) | ||
| 48 | self.sstate_path = bb_vars['SSTATE_DIR'] | ||
| 49 | self.hostdistro = bb_vars['NATIVELSBSTRING'] | ||
| 50 | self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro) | ||
| 51 | |||
| 52 | if add_local_mirrors: | ||
| 53 | config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""' | ||
| 54 | self.append_config(config_set_sstate_if_not_set) | ||
| 55 | for local_mirror in add_local_mirrors: | ||
| 56 | self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror') | ||
| 57 | config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror | ||
| 58 | self.append_config(config_sstate_mirror) | ||
| 59 | |||
| 60 | # Returns a list containing sstate files | ||
| 61 | def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True): | ||
| 62 | result = [] | ||
| 63 | for root, dirs, files in os.walk(self.sstate_path): | ||
| 64 | if distro_specific and re.search(r"%s/%s/[a-z0-9]{2}/[a-z0-9]{2}$" % (self.sstate_path, self.hostdistro), root): | ||
| 65 | for f in files: | ||
| 66 | if re.search(filename_regex, f): | ||
| 67 | result.append(f) | ||
| 68 | if distro_nonspecific and re.search(r"%s/[a-z0-9]{2}/[a-z0-9]{2}$" % self.sstate_path, root): | ||
| 69 | for f in files: | ||
| 70 | if re.search(filename_regex, f): | ||
| 71 | result.append(f) | ||
| 72 | return result | ||
| 73 | |||
| 74 | |||
| 19 | class SStateTests(SStateBase): | 75 | class SStateTests(SStateBase): |
| 20 | def test_autorev_sstate_works(self): | 76 | def test_autorev_sstate_works(self): |
| 21 | # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} | 77 | # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} |
