diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/case.py')
| -rw-r--r-- | meta/lib/oeqa/sdk/case.py | 58 |
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 @@ | |||
| 7 | import os | 7 | import os |
| 8 | import subprocess | 8 | import subprocess |
| 9 | import shutil | 9 | import shutil |
| 10 | import unittest | ||
| 10 | 11 | ||
| 11 | from oeqa.core.case import OETestCase | 12 | from oeqa.core.case import OETestCase |
| 13 | from oeqa.sdkext.context import OESDKExtTestContext | ||
| 12 | 14 | ||
| 13 | class OESDKTestCase(OETestCase): | 15 | class 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 |
