summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-05-10 09:43:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-12 22:01:55 +0100
commiteeacb5d906626e1f85fa53113632a07b77bc03af (patch)
tree7f985c22f12f9fdb133210c6c4c2d818f8992266 /meta/lib
parentd20341f93a13fc2f006b0c53eaaf39be153b2686 (diff)
downloadpoky-eeacb5d906626e1f85fa53113632a07b77bc03af.tar.gz
oeqa/sdk: add helpers to check for and install packages
The existing tests simply look at the manifest to determine if a test should be ran or not based on dependencies. Whilst this works for Traditional SDKs, it fails for Extensible SDKs if they've been built in minimal mode, where the manifest will be empty. However, minimal eSDKs might well have available sstate to install the missing dependencies. Add a pair of helper functions to ensure that a package is available, or skip the test. This handles nativesdk- vs -native (SDK vs eSDK) and will try to sdk-install missing dependencies into an eSDK if they're not already installed. (From OE-Core rev: d0e8b83d05957b1f22d08582e364afa4b522801e) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/sdk/case.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/lib/oeqa/sdk/case.py b/meta/lib/oeqa/sdk/case.py
index 46a3789f57..1fd3b3b569 100644
--- a/meta/lib/oeqa/sdk/case.py
+++ b/meta/lib/oeqa/sdk/case.py
@@ -7,8 +7,10 @@
7import os 7import os
8import subprocess 8import subprocess
9import shutil 9import shutil
10import unittest
10 11
11from oeqa.core.case import OETestCase 12from oeqa.core.case import OETestCase
13from oeqa.sdkext.context import OESDKExtTestContext
12 14
13class OESDKTestCase(OETestCase): 15class OESDKTestCase(OETestCase):
14 def _run(self, cmd): 16 def _run(self, cmd):
@@ -16,6 +18,62 @@ class OESDKTestCase(OETestCase):
16 (self.tc.sdk_env, cmd), shell=True, executable="/bin/bash", 18 (self.tc.sdk_env, cmd), shell=True, executable="/bin/bash",
17 stderr=subprocess.STDOUT, universal_newlines=True) 19 stderr=subprocess.STDOUT, universal_newlines=True)
18 20
21 def ensure_host_package(self, *packages, recipe=None):
22 """
23 Check that the host variation of one of the packages listed is available
24 in the SDK (nativesdk-foo for SDK, foo-native for eSDK). The package is
25 a list for the case where debian-renaming may have occured, and the
26 manifest could contain 'foo' or 'libfoo'.
27
28 If testing an eSDK and the package is not found, then try to install the
29 specified recipe to install it from sstate.
30 """
31
32 # In a SDK the manifest is correct. In an eSDK the manifest may be
33 # correct (type=full) or not include packages that exist in sstate but
34 # not installed yet (minimal) so we should try to install the recipe.
35 for package in packages:
36 if isinstance(self.tc, OESDKExtTestContext):
37 package = package + "-native"
38 else:
39 package = "nativesdk-" + package
40
41 if self.tc.hasHostPackage(package):
42 break
43 else:
44 if isinstance(self.tc, OESDKExtTestContext):
45 recipe = (recipe or packages[0]) + "-native"
46 print("Trying to install %s..." % recipe)
47 self._run('devtool sdk-install %s' % recipe)
48 else:
49 raise unittest.SkipTest("Test %s needs one of %s" % (self.id(), ", ".join(packages)))
50
51 def ensure_target_package(self, *packages, multilib=False, recipe=None):
52 """
53 Check that at least one of the packages listed is available in the SDK,
54 adding the multilib prefix if required. The target package is a list for
55 the case where debian-renaming may have occured, and the manifest could
56 contain 'foo' or 'libfoo'.
57
58 If testing an eSDK and the package is not found, then try to install the
59 specified recipe to install it from sstate.
60 """
61
62 # In a SDK the manifest is correct. In an eSDK the manifest may be
63 # correct (type=full) or not include packages that exist in sstate but
64 # not installed yet (minimal) so we should try to install the recipe.
65 for package in packages:
66 if self.tc.hasTargetPackage(package, multilib=multilib):
67 break
68 else:
69 if isinstance(self.tc, OESDKExtTestContext):
70 recipe = recipe or packages[0]
71 print("Trying to install %s..." % recipe)
72 self._run('devtool sdk-install %s' % recipe)
73 else:
74 raise unittest.SkipTest("Test %s needs one of %s" % (self.id(), ", ".join(packages)))
75
76
19 def fetch(self, workdir, dl_dir, url, archive=None): 77 def fetch(self, workdir, dl_dir, url, archive=None):
20 if not archive: 78 if not archive:
21 from urllib.parse import urlparse 79 from urllib.parse import urlparse