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:16:55 +0000 |
commit | 2a652bcf66ff4d5cccb1eb9520f68d1547e8d4d4 (patch) | |
tree | 70e69f380c2e40d9ce6059f9f524f457d24b9354 | |
parent | 319532792435be73e96c8319e90336e1298ac2a1 (diff) | |
download | openembedded-core-contrib-2a652bcf66ff4d5cccb1eb9520f68d1547e8d4d4.tar.gz |
oeqa/sdk/case: add fundamental helper methods
-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): return subprocess.check_output(". %s > /dev/null; %s;" % \ (self.tc.sdk_env, cmd), shell=True, stderr=subprocess.STDOUT, universal_newlines=True) + + def fetch(self, workdir, dl_dir, url, archive=None): + if not archive: + from urllib.parse import urlparse + archive = os.path.basename(urlparse(url).path) + + if dl_dir: + tarball = os.path.join(dl_dir, archive) + if os.path.exists(tarball): + return tarball + + tarball = os.path.join(workdir, archive) + subprocess.check_output(["wget", "-O", tarball, url]) + return tarball + + def check_elf(self, path, target_os=None, target_arch=None): + import oe.qa, oe.elf + + elf = oe.qa.ELFFile(path) + elf.open() + + if not target_os or not target_arch: + output = self._run("echo $OECORE_TARGET_OS:$OECORE_TARGET_ARCH") + target_os, target_arch = output.strip().split(":") + + machine_data = oe.elf.machine_dict(None)[target_os][target_arch] + (machine, osabi, abiversion, endian, bits) = machine_data + + self.assertEqual(machine, elf.machine()) + self.assertEqual(bits, elf.abiSize()) + self.assertEqual(endian, elf.isLittleEndian()) + |