diff options
| author | Ross Burton <ross.burton@intel.com> | 2018-12-07 21:24:42 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-08 17:17:01 +0000 |
| commit | 2a2a38aa2cf90ff7cad4ff768a5f8a4dad4d35b3 (patch) | |
| tree | 44fe86e55ca713e04c076bd2828a8b95fe6ebbc5 | |
| parent | ccf3c1ca496c39892bc696c141b11300290d2073 (diff) | |
| download | poky-2a2a38aa2cf90ff7cad4ff768a5f8a4dad4d35b3.tar.gz | |
oeqa/sdk/case: add fundamental helper methods
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/sdk/case.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/meta/lib/oeqa/sdk/case.py b/meta/lib/oeqa/sdk/case.py index 963aa8d358..ea15d6a107 100644 --- a/meta/lib/oeqa/sdk/case.py +++ b/meta/lib/oeqa/sdk/case.py | |||
| @@ -10,3 +10,35 @@ class OESDKTestCase(OETestCase): | |||
| 10 | return subprocess.check_output(". %s > /dev/null; %s;" % \ | 10 | return subprocess.check_output(". %s > /dev/null; %s;" % \ |
| 11 | (self.tc.sdk_env, cmd), shell=True, | 11 | (self.tc.sdk_env, cmd), shell=True, |
| 12 | stderr=subprocess.STDOUT, universal_newlines=True) | 12 | stderr=subprocess.STDOUT, universal_newlines=True) |
| 13 | |||
| 14 | def fetch(self, workdir, dl_dir, url, archive=None): | ||
| 15 | if not archive: | ||
| 16 | from urllib.parse import urlparse | ||
| 17 | archive = os.path.basename(urlparse(url).path) | ||
| 18 | |||
| 19 | if dl_dir: | ||
| 20 | tarball = os.path.join(dl_dir, archive) | ||
| 21 | if os.path.exists(tarball): | ||
| 22 | return tarball | ||
| 23 | |||
| 24 | tarball = os.path.join(workdir, archive) | ||
| 25 | subprocess.check_output(["wget", "-O", tarball, url]) | ||
| 26 | return tarball | ||
| 27 | |||
| 28 | def check_elf(self, path, target_os=None, target_arch=None): | ||
| 29 | import oe.qa, oe.elf | ||
| 30 | |||
| 31 | elf = oe.qa.ELFFile(path) | ||
| 32 | elf.open() | ||
| 33 | |||
| 34 | if not target_os or not target_arch: | ||
| 35 | output = self._run("echo $OECORE_TARGET_OS:$OECORE_TARGET_ARCH") | ||
| 36 | target_os, target_arch = output.strip().split(":") | ||
| 37 | |||
| 38 | machine_data = oe.elf.machine_dict(None)[target_os][target_arch] | ||
| 39 | (machine, osabi, abiversion, endian, bits) = machine_data | ||
| 40 | |||
| 41 | self.assertEqual(machine, elf.machine()) | ||
| 42 | self.assertEqual(bits, elf.abiSize()) | ||
| 43 | self.assertEqual(endian, elf.isLittleEndian()) | ||
| 44 | |||
