summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-12 11:29:27 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-13 17:35:22 +0000
commita4c484b8cb2ec0eb82b8b0855532cadedb2fac97 (patch)
treee8e90bed5085d2c27f0c5ae690f565aa4165688d
parent4eb546cf1c2780b7870ba4d6e1a51bd096987fe8 (diff)
downloadpoky-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>
-rw-r--r--meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/sstate.py66
-rw-r--r--meta/lib/oeqa/selftest/cases/sstatetests.py62
3 files changed, 60 insertions, 70 deletions
diff --git a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py
index 5f1c8df2d4..2c9584d329 100644
--- a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py
+++ b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py
@@ -9,7 +9,7 @@ import shutil
9 9
10import oeqa.utils.ftools as ftools 10import oeqa.utils.ftools as ftools
11from oeqa.utils.commands import runCmd, bitbake, get_bb_var 11from oeqa.utils.commands import runCmd, bitbake, get_bb_var
12from oeqa.selftest.cases.sstate import SStateBase 12from oeqa.selftest.cases.sstatetests import SStateBase
13 13
14 14
15class RebuildFromSState(SStateBase): 15class RebuildFromSState(SStateBase):
diff --git a/meta/lib/oeqa/selftest/cases/sstate.py b/meta/lib/oeqa/selftest/cases/sstate.py
deleted file mode 100644
index e73bb94884..0000000000
--- a/meta/lib/oeqa/selftest/cases/sstate.py
+++ /dev/null
@@ -1,66 +0,0 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7import datetime
8import os
9import re
10
11from oeqa.selftest.case import OESelftestTestCase
12from oeqa.utils.commands import get_bb_vars
13
14
15class SStateBase(OESelftestTestCase):
16
17 def setUpLocal(self):
18 super(SStateBase, self).setUpLocal()
19 self.temp_sstate_location = None
20 needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', 'TCLIBC', 'TUNE_ARCH',
21 'TOPDIR', 'TARGET_VENDOR', 'TARGET_OS']
22 bb_vars = get_bb_vars(needed_vars)
23 self.sstate_path = bb_vars['SSTATE_DIR']
24 self.hostdistro = bb_vars['NATIVELSBSTRING']
25 self.tclibc = bb_vars['TCLIBC']
26 self.tune_arch = bb_vars['TUNE_ARCH']
27 self.topdir = bb_vars['TOPDIR']
28 self.target_vendor = bb_vars['TARGET_VENDOR']
29 self.target_os = bb_vars['TARGET_OS']
30 self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro)
31
32 # Creates a special sstate configuration with the option to add sstate mirrors
33 def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]):
34 self.temp_sstate_location = temp_sstate_location
35
36 if self.temp_sstate_location:
37 temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
38 config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path
39 self.append_config(config_temp_sstate)
40 self.track_for_cleanup(temp_sstate_path)
41 bb_vars = get_bb_vars(['SSTATE_DIR', 'NATIVELSBSTRING'])
42 self.sstate_path = bb_vars['SSTATE_DIR']
43 self.hostdistro = bb_vars['NATIVELSBSTRING']
44 self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro)
45
46 if add_local_mirrors:
47 config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""'
48 self.append_config(config_set_sstate_if_not_set)
49 for local_mirror in add_local_mirrors:
50 self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror')
51 config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror
52 self.append_config(config_sstate_mirror)
53
54 # Returns a list containing sstate files
55 def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True):
56 result = []
57 for root, dirs, files in os.walk(self.sstate_path):
58 if distro_specific and re.search(r"%s/%s/[a-z0-9]{2}/[a-z0-9]{2}$" % (self.sstate_path, self.hostdistro), root):
59 for f in files:
60 if re.search(filename_regex, f):
61 result.append(f)
62 if distro_nonspecific and re.search(r"%s/[a-z0-9]{2}/[a-z0-9]{2}$" % self.sstate_path, root):
63 for f in files:
64 if re.search(filename_regex, f):
65 result.append(f)
66 return result
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
9import glob 9import glob
10import subprocess 10import subprocess
11import tempfile 11import tempfile
12import datetime
13import re
12 14
13from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer 15from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer, get_bb_vars
14from oeqa.selftest.cases.sstate import SStateBase 16from oeqa.selftest.case import OESelftestTestCase
15import oe
16 17
18import oe
17import bb.siggen 19import bb.siggen
18 20
21class 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
19class SStateTests(SStateBase): 75class 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}