mirror of
https://git.yoctoproject.org/poky
synced 2026-07-17 04:07:06 +00:00
1f42bb0cb0
Redirect stderr to stdout when running subcommands while doing the SDK tests. The tests will show stdout when CalledProcessError is raised, but any output to stderr was lost. (From OE-Core rev: cf6cab12ca7ff40ac484cdaf27ea91ed49b901b0) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 7cb4e9ab8c1596281060e94a216966060103956e) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
#
|
|
# Copyright (C) 2016 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
from oeqa.core.case import OETestCase
|
|
|
|
class OESDKTestCase(OETestCase):
|
|
def _run(self, cmd):
|
|
return subprocess.check_output(". %s > /dev/null; %s;" % \
|
|
(self.tc.sdk_env, cmd), shell=True, executable="/bin/bash",
|
|
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], stderr=subprocess.STDOUT)
|
|
return tarball
|
|
|
|
def check_elf(self, path, target_os=None, target_arch=None):
|
|
"""
|
|
Verify that the ELF binary $path matches the specified target
|
|
OS/architecture, or if not specified the currently configured MACHINE's
|
|
OS/architecture.
|
|
"""
|
|
import oe.qa, oe.elf
|
|
|
|
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
|
|
|
|
elf = oe.qa.ELFFile(path)
|
|
elf.open()
|
|
|
|
self.assertEqual(machine, elf.machine(),
|
|
"Binary was %s but expected %s" %
|
|
(oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine)))
|
|
self.assertEqual(bits, elf.abiSize())
|
|
self.assertEqual(endian, elf.isLittleEndian())
|