summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/license.py15
-rw-r--r--meta/lib/oe/spdx30_tasks.py35
-rw-r--r--meta/lib/oe/utils.py43
-rw-r--r--meta/lib/oeqa/buildtools-docs/cases/README (renamed from meta/lib/oeqa/sdk/buildtools-docs-cases/README)0
-rw-r--r--meta/lib/oeqa/buildtools-docs/cases/build.py (renamed from meta/lib/oeqa/sdk/buildtools-docs-cases/build.py)0
-rw-r--r--meta/lib/oeqa/buildtools/cases/README (renamed from meta/lib/oeqa/sdk/buildtools-cases/README)0
-rw-r--r--meta/lib/oeqa/buildtools/cases/build.py (renamed from meta/lib/oeqa/sdk/buildtools-cases/build.py)0
-rw-r--r--meta/lib/oeqa/buildtools/cases/gcc.py (renamed from meta/lib/oeqa/sdk/buildtools-cases/gcc.py)0
-rw-r--r--meta/lib/oeqa/buildtools/cases/https.py (renamed from meta/lib/oeqa/sdk/buildtools-cases/https.py)0
-rw-r--r--meta/lib/oeqa/buildtools/cases/sanity.py (renamed from meta/lib/oeqa/sdk/buildtools-cases/sanity.py)0
-rw-r--r--meta/lib/oeqa/core/context.py7
-rw-r--r--meta/lib/oeqa/core/target/__init__.py1
-rw-r--r--meta/lib/oeqa/runtime/case.py2
-rw-r--r--meta/lib/oeqa/sdk/testsdk.py24
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py33
16 files changed, 82 insertions, 80 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 6f882c3812..6e55fa1e7f 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -462,3 +462,18 @@ def skip_incompatible_package_licenses(d, pkgs):
462 skipped_pkgs[pkg] = incompatible_lic 462 skipped_pkgs[pkg] = incompatible_lic
463 463
464 return skipped_pkgs 464 return skipped_pkgs
465
466def tidy_licenses(value):
467 """
468 Flat, split and sort licenses.
469 """
470 from oe.license import flattened_licenses
471
472 def _choose(a, b):
473 str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
474 return ["(%s | %s)" % (str_a, str_b)]
475
476 if not isinstance(value, str):
477 value = " & ".join(value)
478
479 return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index beeafc2bb7..c352dab152 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -552,7 +552,7 @@ def create_spdx(d):
552 ) 552 )
553 build_objset.new_relationship( 553 build_objset.new_relationship(
554 source_files, 554 source_files,
555 oe.spdx30.RelationshipType.hasConcludedLicense, 555 oe.spdx30.RelationshipType.hasDeclaredLicense,
556 [oe.sbom30.get_element_link_id(recipe_spdx_license)], 556 [oe.sbom30.get_element_link_id(recipe_spdx_license)],
557 ) 557 )
558 558
@@ -724,24 +724,23 @@ def create_spdx(d):
724 impact_statement=description, 724 impact_statement=description,
725 ) 725 )
726 726
727 if detail in ( 727 vex_just_type = d.getVarFlag(
728 "ignored", 728 "CVE_CHECK_VEX_JUSTIFICATION", detail
729 "cpe-incorrect", 729 )
730 "disputed", 730 if vex_just_type:
731 "upstream-wontfix", 731 if (
732 ): 732 vex_just_type
733 # VEX doesn't have justifications for this 733 not in oe.spdx30.security_VexJustificationType.NAMED_INDIVIDUALS
734 pass 734 ):
735 elif detail in ( 735 bb.fatal(
736 "not-applicable-config", 736 f"Unknown vex justification '{vex_just_type}', detail '{detail}', for ignored {cve}"
737 "not-applicable-platform",
738 ):
739 for v in spdx_vex:
740 v.security_justificationType = (
741 oe.spdx30.security_VexJustificationType.vulnerableCodeNotPresent
742 ) 737 )
743 else: 738
744 bb.fatal(f"Unknown detail '{detail}' for ignored {cve}") 739 for v in spdx_vex:
740 v.security_justificationType = oe.spdx30.security_VexJustificationType.NAMED_INDIVIDUALS[
741 vex_just_type
742 ]
743
745 elif status == "Unknown": 744 elif status == "Unknown":
746 bb.note(f"Skipping {cve} with status 'Unknown'") 745 bb.note(f"Skipping {cve} with status 'Unknown'")
747 else: 746 else:
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index a11db5f3cd..779c5e593f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -415,60 +415,29 @@ def format_pkg_list(pkg_dict, ret_format=None, pkgdata_dir=None):
415 return output_str 415 return output_str
416 416
417 417
418# Helper function to get the host compiler version 418# Helper function to get the host gcc version
419# Do not assume the compiler is gcc 419def get_host_gcc_version(d, taskcontextonly=False):
420def get_host_compiler_version(d, taskcontextonly=False):
421 import re, subprocess 420 import re, subprocess
422 421
423 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1': 422 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
424 return 423 return
425 424
426 compiler = d.getVar("BUILD_CC")
427 # Get rid of ccache since it is not present when parsing.
428 if compiler.startswith('ccache '):
429 compiler = compiler[7:]
430 try: 425 try:
431 env = os.environ.copy() 426 env = os.environ.copy()
432 # datastore PATH does not contain session PATH as set by environment-setup-... 427 # datastore PATH does not contain session PATH as set by environment-setup-...
433 # this breaks the install-buildtools use-case 428 # this breaks the install-buildtools use-case
434 # env["PATH"] = d.getVar("PATH") 429 # env["PATH"] = d.getVar("PATH")
435 output = subprocess.check_output("%s --version" % compiler, \ 430 output = subprocess.check_output("gcc --version", \
436 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8") 431 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
437 except subprocess.CalledProcessError as e: 432 except subprocess.CalledProcessError as e:
438 bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8"))) 433 bb.fatal("Error running gcc --version: %s" % (e.output.decode("utf-8")))
439 434
440 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0]) 435 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
441 if not match: 436 if not match:
442 bb.fatal("Can't get compiler version from %s --version output" % compiler) 437 bb.fatal("Can't get compiler version from gcc --version output")
443 438
444 version = match.group(1) 439 version = match.group(1)
445 return compiler, version 440 return version
446
447
448def host_gcc_version(d, taskcontextonly=False):
449 import re, subprocess
450
451 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
452 return
453
454 compiler = d.getVar("BUILD_CC")
455 # Get rid of ccache since it is not present when parsing.
456 if compiler.startswith('ccache '):
457 compiler = compiler[7:]
458 try:
459 env = os.environ.copy()
460 env["PATH"] = d.getVar("PATH")
461 output = subprocess.check_output("%s --version" % compiler, \
462 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
463 except subprocess.CalledProcessError as e:
464 bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
465
466 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
467 if not match:
468 bb.fatal("Can't get compiler version from %s --version output" % compiler)
469
470 version = match.group(1)
471 return "-%s" % version if version in ("4.8", "4.9") else ""
472 441
473@bb.parse.vardepsexclude("DEFAULTTUNE_MULTILIB_ORIGINAL", "OVERRIDES") 442@bb.parse.vardepsexclude("DEFAULTTUNE_MULTILIB_ORIGINAL", "OVERRIDES")
474def get_multilib_datastore(variant, d): 443def get_multilib_datastore(variant, d):
diff --git a/meta/lib/oeqa/sdk/buildtools-docs-cases/README b/meta/lib/oeqa/buildtools-docs/cases/README
index f8edbc7dad..f8edbc7dad 100644
--- a/meta/lib/oeqa/sdk/buildtools-docs-cases/README
+++ b/meta/lib/oeqa/buildtools-docs/cases/README
diff --git a/meta/lib/oeqa/sdk/buildtools-docs-cases/build.py b/meta/lib/oeqa/buildtools-docs/cases/build.py
index 6e3ee94292..6e3ee94292 100644
--- a/meta/lib/oeqa/sdk/buildtools-docs-cases/build.py
+++ b/meta/lib/oeqa/buildtools-docs/cases/build.py
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/README b/meta/lib/oeqa/buildtools/cases/README
index d4f20faa9f..d4f20faa9f 100644
--- a/meta/lib/oeqa/sdk/buildtools-cases/README
+++ b/meta/lib/oeqa/buildtools/cases/README
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/build.py b/meta/lib/oeqa/buildtools/cases/build.py
index c85c32496b..c85c32496b 100644
--- a/meta/lib/oeqa/sdk/buildtools-cases/build.py
+++ b/meta/lib/oeqa/buildtools/cases/build.py
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/gcc.py b/meta/lib/oeqa/buildtools/cases/gcc.py
index a62c4d0bc4..a62c4d0bc4 100644
--- a/meta/lib/oeqa/sdk/buildtools-cases/gcc.py
+++ b/meta/lib/oeqa/buildtools/cases/gcc.py
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/https.py b/meta/lib/oeqa/buildtools/cases/https.py
index 4525e3d758..4525e3d758 100644
--- a/meta/lib/oeqa/sdk/buildtools-cases/https.py
+++ b/meta/lib/oeqa/buildtools/cases/https.py
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/sanity.py b/meta/lib/oeqa/buildtools/cases/sanity.py
index a55d456656..a55d456656 100644
--- a/meta/lib/oeqa/sdk/buildtools-cases/sanity.py
+++ b/meta/lib/oeqa/buildtools/cases/sanity.py
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index 9313271f58..46de9135c1 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -179,9 +179,16 @@ class OETestContextExecutor(object):
179 else: 179 else:
180 self.tc_kwargs['init']['td'] = {} 180 self.tc_kwargs['init']['td'] = {}
181 181
182 # Run image specific TEST_SUITE like testimage.bbclass by default
183 test_suites = self.tc_kwargs['init']['td'].get("TEST_SUITES")
184 if test_suites:
185 test_suites = test_suites.split()
186
182 if args.run_tests: 187 if args.run_tests:
183 self.tc_kwargs['load']['modules'] = args.run_tests 188 self.tc_kwargs['load']['modules'] = args.run_tests
184 self.tc_kwargs['load']['modules_required'] = args.run_tests 189 self.tc_kwargs['load']['modules_required'] = args.run_tests
190 elif test_suites:
191 self.tc_kwargs['load']['modules'] = test_suites
185 else: 192 else:
186 self.tc_kwargs['load']['modules'] = [] 193 self.tc_kwargs['load']['modules'] = []
187 194
diff --git a/meta/lib/oeqa/core/target/__init__.py b/meta/lib/oeqa/core/target/__init__.py
index 1382aa9b52..177f648fe3 100644
--- a/meta/lib/oeqa/core/target/__init__.py
+++ b/meta/lib/oeqa/core/target/__init__.py
@@ -10,6 +10,7 @@ class OETarget(object):
10 10
11 def __init__(self, logger, *args, **kwargs): 11 def __init__(self, logger, *args, **kwargs):
12 self.logger = logger 12 self.logger = logger
13 self.runner = None
13 14
14 @abstractmethod 15 @abstractmethod
15 def start(self): 16 def start(self):
diff --git a/meta/lib/oeqa/runtime/case.py b/meta/lib/oeqa/runtime/case.py
index 9515ca2f3d..2a47771a3d 100644
--- a/meta/lib/oeqa/runtime/case.py
+++ b/meta/lib/oeqa/runtime/case.py
@@ -23,6 +23,8 @@ class OERuntimeTestCase(OETestCase):
23 uninstall_package(self) 23 uninstall_package(self)
24 24
25def run_network_serialdebug(runner): 25def run_network_serialdebug(runner):
26 if not runner:
27 return
26 status, output = runner.run_serial("ip addr") 28 status, output = runner.run_serial("ip addr")
27 print("ip addr on target: %s %s" % (output, status)) 29 print("ip addr on target: %s %s" % (output, status))
28 status, output = runner.run_serial("ping -c 1 %s" % self.target.server_ip) 30 status, output = runner.run_serial("ping -c 1 %s" % self.target.server_ip)
diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py
index 52b702b6a2..cffcf9f49a 100644
--- a/meta/lib/oeqa/sdk/testsdk.py
+++ b/meta/lib/oeqa/sdk/testsdk.py
@@ -31,6 +31,28 @@ class TestSDK(TestSDKBase):
31 context_class = OESDKTestContext 31 context_class = OESDKTestContext
32 test_type = 'sdk' 32 test_type = 'sdk'
33 33
34 def sdk_dir_names(self, d):
35 """Return list from TESTSDK_CASE_DIRS."""
36 testdirs = d.getVar("TESTSDK_CASE_DIRS")
37 if testdirs:
38 return testdirs.split()
39
40 bb.fatal("TESTSDK_CASE_DIRS unset, can't find SDK test directories.")
41
42 def get_sdk_paths(self, d):
43 """
44 Return a list of paths where SDK test cases reside.
45
46 SDK tests are expected in <LAYER_DIR>/lib/oeqa/<dirname>/cases
47 """
48 paths = []
49 for layer in d.getVar("BBLAYERS").split():
50 for dirname in self.sdk_dir_names(d):
51 case_path = os.path.join(layer, "lib", "oeqa", dirname, "cases")
52 if os.path.isdir(case_path):
53 paths.append(case_path)
54 return paths
55
34 def get_tcname(self, d): 56 def get_tcname(self, d):
35 """ 57 """
36 Get the name of the SDK file 58 Get the name of the SDK file
@@ -115,7 +137,7 @@ class TestSDK(TestSDKBase):
115 137
116 try: 138 try:
117 modules = (d.getVar("TESTSDK_SUITES") or "").split() 139 modules = (d.getVar("TESTSDK_SUITES") or "").split()
118 tc.loadTests(self.context_executor_class.default_cases, modules) 140 tc.loadTests(self.get_sdk_paths(d), modules)
119 except Exception as e: 141 except Exception as e:
120 import traceback 142 import traceback
121 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) 143 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 74a7727cc0..05f228f03e 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -154,7 +154,7 @@ class DevtoolTestCase(OESelftestTestCase):
154 value = invalue 154 value = invalue
155 invar = None 155 invar = None
156 elif '=' in line: 156 elif '=' in line:
157 splitline = line.split('=', 1) 157 splitline = re.split(r"[?+:]*=[+]?", line, 1)
158 var = splitline[0].rstrip() 158 var = splitline[0].rstrip()
159 value = splitline[1].strip().strip('"') 159 value = splitline[1].strip().strip('"')
160 if value.endswith('\\'): 160 if value.endswith('\\'):
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 2a91f6c7ae..0bd724c8ee 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -757,13 +757,12 @@ class RecipetoolCreateTests(RecipetoolBase):
757 757
758 def test_recipetool_create_go(self): 758 def test_recipetool_create_go(self):
759 # Basic test to check go recipe generation 759 # Basic test to check go recipe generation
760 self.maxDiff = None
761
760 temprecipe = os.path.join(self.tempdir, 'recipe') 762 temprecipe = os.path.join(self.tempdir, 'recipe')
761 os.makedirs(temprecipe) 763 os.makedirs(temprecipe)
762 764
763 recipefile = os.path.join(temprecipe, 'recipetool-go-test_git.bb') 765 recipefile = os.path.join(temprecipe, 'recipetool-go-test_git.bb')
764 deps_require_file = os.path.join(temprecipe, 'recipetool-go-test', 'recipetool-go-test-modules.inc')
765 lics_require_file = os.path.join(temprecipe, 'recipetool-go-test', 'recipetool-go-test-licenses.inc')
766 modules_txt_file = os.path.join(temprecipe, 'recipetool-go-test', 'modules.txt')
767 766
768 srcuri = 'https://git.yoctoproject.org/recipetool-go-test.git' 767 srcuri = 'https://git.yoctoproject.org/recipetool-go-test.git'
769 srcrev = "c3e213c01b6c1406b430df03ef0d1ae77de5d2f7" 768 srcrev = "c3e213c01b6c1406b430df03ef0d1ae77de5d2f7"
@@ -771,13 +770,11 @@ class RecipetoolCreateTests(RecipetoolBase):
771 770
772 result = runCmd('recipetool create -o %s %s -S %s -B %s' % (temprecipe, srcuri, srcrev, srcbranch)) 771 result = runCmd('recipetool create -o %s %s -S %s -B %s' % (temprecipe, srcuri, srcrev, srcbranch))
773 772
774 self.maxDiff = None 773 inherits = ['go-mod', 'go-mod-update-modules']
775 inherits = ['go-vendor']
776 774
777 checkvars = {} 775 checkvars = {}
778 checkvars['GO_IMPORT'] = "git.yoctoproject.org/recipetool-go-test" 776 checkvars['GO_IMPORT'] = "git.yoctoproject.org/recipetool-go-test"
779 checkvars['SRC_URI'] = {'git://${GO_IMPORT};destsuffix=git/src/${GO_IMPORT};nobranch=1;name=${BPN};protocol=https', 777 checkvars['SRC_URI'] = {'git://${GO_IMPORT};protocol=https;nobranch=1;destsuffix=${GO_SRCURI_DESTSUFFIX}'}
780 'file://modules.txt'}
781 checkvars['LIC_FILES_CHKSUM'] = { 778 checkvars['LIC_FILES_CHKSUM'] = {
782 'file://src/${GO_IMPORT}/LICENSE;md5=4e3933dd47afbf115e484d11385fb3bd', 779 'file://src/${GO_IMPORT}/LICENSE;md5=4e3933dd47afbf115e484d11385fb3bd',
783 'file://src/${GO_IMPORT}/is/LICENSE;md5=62beaee5a116dd1e80161667b1df39ab' 780 'file://src/${GO_IMPORT}/is/LICENSE;md5=62beaee5a116dd1e80161667b1df39ab'
@@ -786,26 +783,16 @@ class RecipetoolCreateTests(RecipetoolBase):
786 self._test_recipe_contents(recipefile, checkvars, inherits) 783 self._test_recipe_contents(recipefile, checkvars, inherits)
787 self.assertNotIn('Traceback', result.output) 784 self.assertNotIn('Traceback', result.output)
788 785
786 lics_require_file = os.path.join(temprecipe, 'recipetool-go-test-licenses.inc')
787 self.assertFileExists(lics_require_file)
789 checkvars = {} 788 checkvars = {}
790 checkvars['VENDORED_LIC_FILES_CHKSUM'] = set( 789 checkvars['LIC_FILES_CHKSUM'] = {'file://pkg/mod/github.com/godbus/dbus/v5@v5.1.0/LICENSE;md5=09042bd5c6c96a2b9e45ddf1bc517eed;spdx=BSD-2-Clause'}
791 ['file://src/${GO_IMPORT}/vendor/github.com/godbus/dbus/v5/LICENSE;md5=09042bd5c6c96a2b9e45ddf1bc517eed',
792 'file://src/${GO_IMPORT}/vendor/github.com/matryer/is/LICENSE;md5=62beaee5a116dd1e80161667b1df39ab'])
793 self.assertTrue(os.path.isfile(lics_require_file))
794 self._test_recipe_contents(lics_require_file, checkvars, []) 790 self._test_recipe_contents(lics_require_file, checkvars, [])
795 791
796 # make sure that dependencies don't mention local directory ./matryer/is 792 deps_require_file = os.path.join(temprecipe, 'recipetool-go-test-go-mods.inc')
797 dependencies = \ 793 self.assertFileExists(deps_require_file)
798 [ ('github.com/godbus/dbus','v5.1.0', 'github.com/godbus/dbus/v5', '/v5', ''),
799 ]
800
801 src_uri = set()
802 for d in dependencies:
803 src_uri.add(self._go_urifiy(*d))
804
805 checkvars = {} 794 checkvars = {}
806 checkvars['GO_DEPENDENCIES_SRC_URI'] = src_uri 795 checkvars['SRC_URI'] = {'gomod://github.com/godbus/dbus/v5;version=v5.1.0;sha256sum=03dfa8e71089a6f477310d15c4d3a036d82d028532881b50fee254358e782ad9'}
807
808 self.assertTrue(os.path.isfile(deps_require_file))
809 self._test_recipe_contents(deps_require_file, checkvars, []) 796 self._test_recipe_contents(deps_require_file, checkvars, [])
810 797
811class RecipetoolTests(RecipetoolBase): 798class RecipetoolTests(RecipetoolBase):