summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/sdk/case.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/sdk/case.py')
-rw-r--r--meta/lib/oeqa/sdk/case.py67
1 files changed, 64 insertions, 3 deletions
diff --git a/meta/lib/oeqa/sdk/case.py b/meta/lib/oeqa/sdk/case.py
index c45882689c..1fd3b3b569 100644
--- a/meta/lib/oeqa/sdk/case.py
+++ b/meta/lib/oeqa/sdk/case.py
@@ -6,8 +6,11 @@
6 6
7import os 7import os
8import subprocess 8import subprocess
9import shutil
10import unittest
9 11
10from oeqa.core.case import OETestCase 12from oeqa.core.case import OETestCase
13from oeqa.sdkext.context import OESDKExtTestContext
11 14
12class OESDKTestCase(OETestCase): 15class OESDKTestCase(OETestCase):
13 def _run(self, cmd): 16 def _run(self, cmd):
@@ -15,18 +18,76 @@ class OESDKTestCase(OETestCase):
15 (self.tc.sdk_env, cmd), shell=True, executable="/bin/bash", 18 (self.tc.sdk_env, cmd), shell=True, executable="/bin/bash",
16 stderr=subprocess.STDOUT, universal_newlines=True) 19 stderr=subprocess.STDOUT, universal_newlines=True)
17 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
18 def fetch(self, workdir, dl_dir, url, archive=None): 77 def fetch(self, workdir, dl_dir, url, archive=None):
19 if not archive: 78 if not archive:
20 from urllib.parse import urlparse 79 from urllib.parse import urlparse
21 archive = os.path.basename(urlparse(url).path) 80 archive = os.path.basename(urlparse(url).path)
22 81
23 if dl_dir: 82 if dl_dir:
24 tarball = os.path.join(dl_dir, archive) 83 archive_tarball = os.path.join(dl_dir, archive)
25 if os.path.exists(tarball): 84 if os.path.exists(archive_tarball):
26 return tarball 85 return archive_tarball
27 86
28 tarball = os.path.join(workdir, archive) 87 tarball = os.path.join(workdir, archive)
29 subprocess.check_output(["wget", "-O", tarball, url], stderr=subprocess.STDOUT) 88 subprocess.check_output(["wget", "-O", tarball, url], stderr=subprocess.STDOUT)
89 if dl_dir and not os.path.exists(archive_tarball):
90 shutil.copyfile(tarball, archive_tarball)
30 return tarball 91 return tarball
31 92
32 def check_elf(self, path, target_os=None, target_arch=None): 93 def check_elf(self, path, target_os=None, target_arch=None):