Complete Yocto mirror with license table for TQMa6UL (2038-compliance)
- 264 license table entries with exact download URLs (224/264 resolved) - Complete sources/ directory with all BitBake recipes - Build configuration: tqma6ul-multi-mba6ulx, spaetzle (musl) - Full traceability for Softwarefreigabeantrag - GCC 13.4.0, Linux 6.6.102, U-Boot 2023.04, musl 1.2.4 - License distribution: GPL-2.0 (24), MIT (23), GPL-2.0+ (18), BSD-3 (16)
This commit is contained in:
0
sources/poky/meta/lib/oeqa/sdk/__init__.py
Normal file
0
sources/poky/meta/lib/oeqa/sdk/__init__.py
Normal file
2
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/README
Normal file
2
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/README
Normal file
@@ -0,0 +1,2 @@
|
||||
These test cases are used by buildtools-tarball, and are not used by the testsdk
|
||||
class.
|
||||
32
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/build.py
Normal file
32
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/build.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os, tempfile
|
||||
import time
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class BuildTests(OESDKTestCase):
|
||||
"""
|
||||
Verify that bitbake can build virtual/libc inside the buildtools.
|
||||
"""
|
||||
def test_libc(self):
|
||||
with tempfile.TemporaryDirectory(prefix='bitbake-build-', dir=self.tc.sdk_dir) as testdir:
|
||||
corebase = self.td['COREBASE']
|
||||
|
||||
self._run('. %s/oe-init-build-env %s' % (corebase, testdir))
|
||||
with open(os.path.join(testdir, 'conf', 'local.conf'), 'ta') as conf:
|
||||
conf.write('\n')
|
||||
conf.write('DL_DIR = "%s"\n' % self.td['DL_DIR'])
|
||||
|
||||
try:
|
||||
self._run('. %s/oe-init-build-env %s && bitbake virtual/libc' % (corebase, testdir))
|
||||
finally:
|
||||
delay = 10
|
||||
while delay and (os.path.exists(testdir + "/bitbake.lock") or os.path.exists(testdir + "/cache/hashserv.db-wal")):
|
||||
time.sleep(1)
|
||||
delay = delay - 1
|
||||
31
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/gcc.py
Normal file
31
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/gcc.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os.path
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
class GccTests(OESDKTestCase):
|
||||
def test_verify_specs(self):
|
||||
"""
|
||||
Verify that the compiler has been relocated successfully and isn't
|
||||
looking in the hard-coded prefix.
|
||||
"""
|
||||
# Canonicalise the SDK root
|
||||
sdk_base = os.path.realpath(self.tc.sdk_dir)
|
||||
# Canonicalise the location of GCC
|
||||
gcc_path = os.path.realpath(self._run("command -v gcc").strip())
|
||||
# Skip the test if the GCC didn't come from the buildtools, as it only
|
||||
# comes with buildtools-extended-tarball.
|
||||
if os.path.commonprefix((sdk_base, gcc_path)) != sdk_base:
|
||||
self.skipTest("Buildtools does not provide GCC")
|
||||
|
||||
# This is the prefix that GCC is build with, and should be replaced at
|
||||
# installation time.
|
||||
sdkpath = self.td.get("SDKPATH")
|
||||
self.assertTrue(sdkpath)
|
||||
|
||||
for line in self._run('gcc -dumpspecs').splitlines():
|
||||
self.assertNotIn(sdkpath, line)
|
||||
22
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/https.py
Normal file
22
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/https.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class HTTPTests(OESDKTestCase):
|
||||
"""
|
||||
Verify that HTTPS certificates are working correctly, as this depends on
|
||||
environment variables being set correctly.
|
||||
"""
|
||||
|
||||
def test_wget(self):
|
||||
self._run('env -i wget --debug --output-document /dev/null https://yoctoproject.org/connectivity.html')
|
||||
|
||||
def test_python(self):
|
||||
# urlopen() returns a file-like object on success and throws an exception otherwise
|
||||
self._run('python3 -c \'import urllib.request; urllib.request.urlopen("https://yoctoproject.org/connectivity.html")\'')
|
||||
24
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/sanity.py
Normal file
24
sources/poky/meta/lib/oeqa/sdk/buildtools-cases/sanity.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import shutil
|
||||
import os.path
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
class SanityTests(OESDKTestCase):
|
||||
def test_tools(self):
|
||||
"""
|
||||
Test that wget and tar come from the buildtools, not the host. This
|
||||
verifies that the buildtools have installed correctly. We can't check
|
||||
for gcc as that is only installed by buildtools-extended.
|
||||
"""
|
||||
for command in ("tar", "wget"):
|
||||
# Canonicalise the SDK root
|
||||
sdk_base = os.path.realpath(self.tc.sdk_dir)
|
||||
# Canonicalise the location of this command
|
||||
tool_path = os.path.realpath(self._run("command -v %s" % command).strip())
|
||||
# Assert that the tool was found inside the SDK root
|
||||
self.assertEqual(os.path.commonprefix((sdk_base, tool_path)), sdk_base)
|
||||
@@ -0,0 +1,2 @@
|
||||
These test cases are used by build-docs-tarball, and are not used by the testsdk
|
||||
class.
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import tempfile
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class BuildTests(OESDKTestCase):
|
||||
"""
|
||||
Verify that our docs can build using our docs tools tarball.
|
||||
"""
|
||||
def test_docs_build(self):
|
||||
with tempfile.TemporaryDirectory(prefix='docs-tarball-build-', dir=self.tc.sdk_dir) as testdir:
|
||||
self._run('git clone git://git.yoctoproject.org/yocto-docs %s' % testdir)
|
||||
self._run('cd %s/documentation && make html' % testdir)
|
||||
57
sources/poky/meta/lib/oeqa/sdk/case.py
Normal file
57
sources/poky/meta/lib/oeqa/sdk/case.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Copyright (C) 2016 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
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:
|
||||
archive_tarball = os.path.join(dl_dir, archive)
|
||||
if os.path.exists(archive_tarball):
|
||||
return archive_tarball
|
||||
|
||||
tarball = os.path.join(workdir, archive)
|
||||
subprocess.check_output(["wget", "-O", tarball, url], stderr=subprocess.STDOUT)
|
||||
if dl_dir and not os.path.exists(archive_tarball):
|
||||
shutil.copyfile(tarball, archive_tarball)
|
||||
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())
|
||||
49
sources/poky/meta/lib/oeqa/sdk/cases/assimp.py
Normal file
49
sources/poky/meta/lib/oeqa/sdk/cases/assimp.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class BuildAssimp(OESDKTestCase):
|
||||
"""
|
||||
Test case to build a project using cmake.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("CMakeTest class: SDK doesn't contain a supported C library")
|
||||
|
||||
if not (self.tc.hasHostPackage("nativesdk-cmake") or
|
||||
self.tc.hasHostPackage("cmake-native")):
|
||||
raise unittest.SkipTest("Needs cmake")
|
||||
|
||||
def test_assimp(self):
|
||||
with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
|
||||
tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v5.4.1.tar.gz")
|
||||
|
||||
dirs = {}
|
||||
dirs["source"] = os.path.join(testdir, "assimp-5.4.1")
|
||||
dirs["build"] = os.path.join(testdir, "build")
|
||||
dirs["install"] = os.path.join(testdir, "install")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
# Apply the zlib patch https://github.com/madler/zlib/commit/a566e156b3fa07b566ddbf6801b517a9dba04fa3
|
||||
# this sed wont be needed once assimp moves its zlib copy to v1.3.1+
|
||||
self._run("sed -i '/# ifdef _FILE_OFFSET_BITS/I,+2 d' {source}/contrib/zlib/gzguts.h".format(**dirs))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
self._run("cd {build} && cmake -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASSIMP_BUILD_ZLIB=ON {source}".format(**dirs))
|
||||
self._run("cmake --build {build} -- -j".format(**dirs))
|
||||
self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs))
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.5.4.1"))
|
||||
42
sources/poky/meta/lib/oeqa/sdk/cases/buildcpio.py
Normal file
42
sources/poky/meta/lib/oeqa/sdk/cases/buildcpio.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class BuildCpioTest(OESDKTestCase):
|
||||
"""
|
||||
Check that autotools will cross-compile correctly.
|
||||
"""
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("AutotoolsTest class: SDK doesn't contain a supported C library")
|
||||
|
||||
def test_cpio(self):
|
||||
with tempfile.TemporaryDirectory(prefix="cpio-", dir=self.tc.sdk_dir) as testdir:
|
||||
tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.15.tar.gz")
|
||||
|
||||
dirs = {}
|
||||
dirs["source"] = os.path.join(testdir, "cpio-2.15")
|
||||
dirs["build"] = os.path.join(testdir, "build")
|
||||
dirs["install"] = os.path.join(testdir, "install")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
|
||||
self._run("cd {build} && make -j".format(**dirs))
|
||||
self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
|
||||
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))
|
||||
48
sources/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py
Normal file
48
sources/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class EpoxyTest(OESDKTestCase):
|
||||
"""
|
||||
Test that Meson builds correctly.
|
||||
"""
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("MesonTest class: SDK doesn't contain a supported C library")
|
||||
|
||||
if not (self.tc.hasHostPackage("nativesdk-meson") or
|
||||
self.tc.hasHostPackage("meson-native")):
|
||||
raise unittest.SkipTest("EpoxyTest class: SDK doesn't contain Meson")
|
||||
|
||||
def test_epoxy(self):
|
||||
with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir:
|
||||
tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz")
|
||||
|
||||
dirs = {}
|
||||
dirs["source"] = os.path.join(testdir, "libepoxy-1.5.3")
|
||||
dirs["build"] = os.path.join(testdir, "build")
|
||||
dirs["install"] = os.path.join(testdir, "install")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
|
||||
# Check that Meson thinks we're doing a cross build and not a native
|
||||
self.assertIn("Build type: cross build", log)
|
||||
self._run("ninja -C {build} -v".format(**dirs))
|
||||
self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs))
|
||||
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))
|
||||
50
sources/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py
Normal file
50
sources/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class GalculatorTest(OESDKTestCase):
|
||||
"""
|
||||
Test that autotools and GTK+ 3 compiles correctly.
|
||||
"""
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("GTK3Test class: SDK doesn't contain a supported C library")
|
||||
|
||||
if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \
|
||||
self.tc.hasTargetPackage("libgtk-3.0", multilib=True)):
|
||||
raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3")
|
||||
if not (self.tc.hasHostPackage("nativesdk-gettext-dev") or
|
||||
self.tc.hasHostPackage("gettext-native")):
|
||||
raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext")
|
||||
|
||||
def test_galculator(self):
|
||||
with tempfile.TemporaryDirectory(prefix="galculator", dir=self.tc.sdk_dir) as testdir:
|
||||
tarball = self.fetch(testdir, self.td["DL_DIR"], "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2")
|
||||
|
||||
dirs = {}
|
||||
dirs["source"] = os.path.join(testdir, "galculator-2.1.4")
|
||||
dirs["build"] = os.path.join(testdir, "build")
|
||||
dirs["install"] = os.path.join(testdir, "install")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
self._run("cd {source} && sed -i -e '/s_preferences.*prefs;/d' src/main.c && autoreconf -i -f -I $OECORE_TARGET_SYSROOT/usr/share/aclocal -I m4".format(**dirs))
|
||||
self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
|
||||
self._run("cd {build} && make -j".format(**dirs))
|
||||
self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
|
||||
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "galculator"))
|
||||
44
sources/poky/meta/lib/oeqa/sdk/cases/buildlzip.py
Normal file
44
sources/poky/meta/lib/oeqa/sdk/cases/buildlzip.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os, tempfile, subprocess, unittest
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class BuildLzipTest(OESDKTestCase):
|
||||
"""
|
||||
Test that "plain" compilation works, using just $CC $CFLAGS etc.
|
||||
"""
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("MakefileTest class: SDK doesn't contain a supported C library")
|
||||
|
||||
def test_lzip(self):
|
||||
with tempfile.TemporaryDirectory(prefix="lzip", dir=self.tc.sdk_dir) as testdir:
|
||||
tarball = self.fetch(testdir, self.td["DL_DIR"], "http://downloads.yoctoproject.org/mirror/sources/lzip-1.19.tar.gz")
|
||||
|
||||
dirs = {}
|
||||
dirs["source"] = os.path.join(testdir, "lzip-1.19")
|
||||
dirs["build"] = os.path.join(testdir, "build")
|
||||
dirs["install"] = os.path.join(testdir, "install")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
cmd = """cd {build} && \
|
||||
{source}/configure --srcdir {source} \
|
||||
CXX="$CXX" \
|
||||
CPPFLAGS="$CPPFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
"""
|
||||
self._run(cmd.format(**dirs))
|
||||
self._run("cd {build} && make -j".format(**dirs))
|
||||
self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "lzip"))
|
||||
56
sources/poky/meta/lib/oeqa/sdk/cases/gcc.py
Normal file
56
sources/poky/meta/lib/oeqa/sdk/cases/gcc.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class GccCompileTest(OESDKTestCase):
|
||||
td_vars = ['MACHINE']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir,
|
||||
'testsdkmakefile' : self.tc.sdk_files_dir}
|
||||
for f in files:
|
||||
shutil.copyfile(os.path.join(files[f], f),
|
||||
os.path.join(self.tc.sdk_dir, f))
|
||||
|
||||
def setUp(self):
|
||||
libc = self.td.get("TCLIBC")
|
||||
if libc in [ 'newlib' ]:
|
||||
raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a supported C library")
|
||||
|
||||
machine = self.td.get("MACHINE")
|
||||
if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
|
||||
self.tc.hasHostPackage("^gcc-", regex=True)):
|
||||
raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain")
|
||||
|
||||
def test_gcc_compile(self):
|
||||
self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_gpp_compile(self):
|
||||
self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_gpp2_compile(self):
|
||||
self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_make(self):
|
||||
self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
files = [os.path.join(self.tc.sdk_dir, f) \
|
||||
for f in ['test.c', 'test.cpp', 'test.o', 'test',
|
||||
'testsdkmakefile']]
|
||||
for f in files:
|
||||
remove_safe(f)
|
||||
79
sources/poky/meta/lib/oeqa/sdk/cases/maturin.py
Normal file
79
sources/poky/meta/lib/oeqa/sdk/cases/maturin.py
Normal file
@@ -0,0 +1,79 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
|
||||
errors_have_output()
|
||||
|
||||
|
||||
class MaturinTest(OESDKTestCase):
|
||||
def setUp(self):
|
||||
if not (
|
||||
self.tc.hasHostPackage("nativesdk-python3-maturin")
|
||||
or self.tc.hasHostPackage("python3-maturin-native")
|
||||
):
|
||||
raise unittest.SkipTest("No python3-maturin package in the SDK")
|
||||
|
||||
def test_maturin_list_python(self):
|
||||
py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'")
|
||||
py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'")
|
||||
python_version = "%s.%s" % (py_major.strip(), py_minor.strip())
|
||||
cmd = "maturin list-python"
|
||||
output = self._run(cmd)
|
||||
self.assertRegex(output, r"^🐍 1 python interpreter found:\n")
|
||||
self.assertRegex(
|
||||
output,
|
||||
r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version),
|
||||
)
|
||||
|
||||
|
||||
class MaturinDevelopTest(OESDKTestCase):
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
targetdir = os.path.join(self.tc.sdk_dir, "guessing-game")
|
||||
try:
|
||||
shutil.rmtree(targetdir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
shutil.copytree(
|
||||
os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
machine = self.td.get("MACHINE")
|
||||
if not (
|
||||
self.tc.hasHostPackage("nativesdk-python3-maturin")
|
||||
or self.tc.hasHostPackage("python3-maturin-native")
|
||||
):
|
||||
raise unittest.SkipTest("No python3-maturin package in the SDK")
|
||||
if not (
|
||||
self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine)
|
||||
):
|
||||
raise unittest.SkipTest(
|
||||
"Testing 'maturin develop' requires Rust cross-canadian in the SDK"
|
||||
)
|
||||
|
||||
def test_maturin_develop(self):
|
||||
"""
|
||||
This test case requires:
|
||||
(1) that a .venv can been created.
|
||||
(2) a functional 'rustc' and 'cargo'
|
||||
"""
|
||||
self._run("cd %s/guessing-game; python3 -m venv .venv" % self.tc.sdk_dir)
|
||||
cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir
|
||||
output = self._run(cmd)
|
||||
self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8")
|
||||
self.assertRegex(output, r"🐍 Not using a specific python interpreter")
|
||||
self.assertRegex(output, r"📡 Using build options features from pyproject.toml")
|
||||
self.assertRegex(output, r"Compiling guessing-game v0.1.0")
|
||||
self.assertRegex(output, r"📦 Built wheel for abi3 Python ≥ 3.8")
|
||||
self.assertRegex(output, r"🛠 Installed guessing-game-0.1.0")
|
||||
22
sources/poky/meta/lib/oeqa/sdk/cases/perl.py
Normal file
22
sources/poky/meta/lib/oeqa/sdk/cases/perl.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import unittest
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class PerlTest(OESDKTestCase):
|
||||
def setUp(self):
|
||||
if not (self.tc.hasHostPackage("nativesdk-perl") or
|
||||
self.tc.hasHostPackage("perl-native")):
|
||||
raise unittest.SkipTest("No perl package in the SDK")
|
||||
|
||||
def test_perl(self):
|
||||
cmd = "perl -e '$_=\"Uryyb, jbeyq\"; tr/a-zA-Z/n-za-mN-ZA-M/;print'"
|
||||
output = self._run(cmd)
|
||||
self.assertEqual(output, "Hello, world")
|
||||
22
sources/poky/meta/lib/oeqa/sdk/cases/python.py
Normal file
22
sources/poky/meta/lib/oeqa/sdk/cases/python.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import subprocess, unittest
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class Python3Test(OESDKTestCase):
|
||||
def setUp(self):
|
||||
if not (self.tc.hasHostPackage("nativesdk-python3-core") or
|
||||
self.tc.hasHostPackage("python3-core-native")):
|
||||
raise unittest.SkipTest("No python3 package in the SDK")
|
||||
|
||||
def test_python3(self):
|
||||
cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\""
|
||||
output = self._run(cmd)
|
||||
self.assertEqual(output, "Hello, world\n")
|
||||
57
sources/poky/meta/lib/oeqa/sdk/cases/rust.py
Normal file
57
sources/poky/meta/lib/oeqa/sdk/cases/rust.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
from oeqa.utils.subprocesstweak import errors_have_output
|
||||
errors_have_output()
|
||||
|
||||
class RustCompileTest(OESDKTestCase):
|
||||
td_vars = ['MACHINE']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
targetdir = os.path.join(self.tc.sdk_dir, "hello")
|
||||
try:
|
||||
shutil.rmtree(targetdir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir)
|
||||
|
||||
def setUp(self):
|
||||
machine = self.td.get("MACHINE")
|
||||
if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine):
|
||||
raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain")
|
||||
|
||||
def test_cargo_build(self):
|
||||
self._run('cd %s/hello; cargo build' % self.tc.sdk_dir)
|
||||
|
||||
class RustHostCompileTest(OESDKTestCase):
|
||||
td_vars = ['MACHINE', 'SDK_SYS']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
targetdir = os.path.join(self.tc.sdk_dir, "hello")
|
||||
try:
|
||||
shutil.rmtree(targetdir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir)
|
||||
|
||||
def setUp(self):
|
||||
machine = self.td.get("MACHINE")
|
||||
if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine):
|
||||
raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain")
|
||||
|
||||
def test_cargo_build(self):
|
||||
sdksys = self.td.get("SDK_SYS")
|
||||
self._run('cd %s/hello; cargo build --target %s-gnu' % (self.tc.sdk_dir, sdksys))
|
||||
self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys))
|
||||
155
sources/poky/meta/lib/oeqa/sdk/context.py
Normal file
155
sources/poky/meta/lib/oeqa/sdk/context.py
Normal file
@@ -0,0 +1,155 @@
|
||||
#
|
||||
# Copyright (C) 2016 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import re
|
||||
|
||||
from oeqa.core.context import OETestContext, OETestContextExecutor
|
||||
|
||||
class OESDKTestContext(OETestContext):
|
||||
sdk_files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files")
|
||||
|
||||
def __init__(self, td=None, logger=None, sdk_dir=None, sdk_env=None,
|
||||
target_pkg_manifest=None, host_pkg_manifest=None):
|
||||
super(OESDKTestContext, self).__init__(td, logger)
|
||||
|
||||
self.sdk_dir = sdk_dir
|
||||
self.sdk_env = sdk_env
|
||||
self.target_pkg_manifest = target_pkg_manifest
|
||||
self.host_pkg_manifest = host_pkg_manifest
|
||||
|
||||
def _hasPackage(self, manifest, pkg, regex=False):
|
||||
if regex:
|
||||
# do regex match
|
||||
pat = re.compile(pkg)
|
||||
for p in manifest.keys():
|
||||
if pat.search(p):
|
||||
return True
|
||||
else:
|
||||
# do exact match
|
||||
if pkg in manifest.keys():
|
||||
return True
|
||||
return False
|
||||
|
||||
def hasHostPackage(self, pkg, regex=False):
|
||||
return self._hasPackage(self.host_pkg_manifest, pkg, regex=regex)
|
||||
|
||||
def hasTargetPackage(self, pkg, multilib=False, regex=False):
|
||||
if multilib:
|
||||
stripped_sdk_env = os.path.basename(self.sdk_env)
|
||||
if stripped_sdk_env.startswith('environment-setup-'):
|
||||
# match multilib according to sdk_env
|
||||
mls = self.td.get('MULTILIB_VARIANTS', '').split()
|
||||
for ml in mls:
|
||||
if ('ml'+ml) in stripped_sdk_env:
|
||||
pkg = ml + '-' + pkg
|
||||
return self._hasPackage(self.target_pkg_manifest, pkg, regex=regex)
|
||||
|
||||
class OESDKTestContextExecutor(OETestContextExecutor):
|
||||
_context_class = OESDKTestContext
|
||||
|
||||
name = 'sdk'
|
||||
help = 'sdk test component'
|
||||
description = 'executes sdk tests'
|
||||
|
||||
default_cases = [os.path.join(os.path.abspath(os.path.dirname(__file__)),
|
||||
'cases')]
|
||||
default_test_data = None
|
||||
|
||||
def register_commands(self, logger, subparsers):
|
||||
super(OESDKTestContextExecutor, self).register_commands(logger, subparsers)
|
||||
|
||||
sdk_group = self.parser.add_argument_group('sdk options')
|
||||
sdk_group.add_argument('--sdk-env', action='store',
|
||||
help='sdk environment')
|
||||
sdk_group.add_argument('--target-manifest', action='store',
|
||||
help='sdk target manifest')
|
||||
sdk_group.add_argument('--host-manifest', action='store',
|
||||
help='sdk host manifest')
|
||||
|
||||
sdk_dgroup = self.parser.add_argument_group('sdk display options')
|
||||
sdk_dgroup.add_argument('--list-sdk-env', action='store_true',
|
||||
default=False, help='sdk list available environment')
|
||||
|
||||
# XXX this option is required but argparse_oe has a bug handling
|
||||
# required options, seems that don't keep track of already parsed
|
||||
# options
|
||||
sdk_rgroup = self.parser.add_argument_group('sdk required options')
|
||||
sdk_rgroup.add_argument('--sdk-dir', required=False, action='store',
|
||||
help='sdk installed directory')
|
||||
|
||||
self.parser.add_argument('-j', '--num-processes', dest='processes', action='store',
|
||||
type=int, help="number of processes to execute in parallel with")
|
||||
|
||||
@staticmethod
|
||||
def _load_manifest(manifest):
|
||||
pkg_manifest = {}
|
||||
if manifest:
|
||||
with open(manifest) as f:
|
||||
for line in f:
|
||||
(pkg, arch, version) = line.strip().split()
|
||||
pkg_manifest[pkg] = (version, arch)
|
||||
|
||||
return pkg_manifest
|
||||
|
||||
def _process_args(self, logger, args):
|
||||
super(OESDKTestContextExecutor, self)._process_args(logger, args)
|
||||
|
||||
self.tc_kwargs['init']['sdk_dir'] = args.sdk_dir
|
||||
self.tc_kwargs['init']['sdk_env'] = self.sdk_env
|
||||
self.tc_kwargs['init']['target_pkg_manifest'] = \
|
||||
OESDKTestContextExecutor._load_manifest(args.target_manifest)
|
||||
self.tc_kwargs['init']['host_pkg_manifest'] = \
|
||||
OESDKTestContextExecutor._load_manifest(args.host_manifest)
|
||||
self.tc_kwargs['run']['processes'] = args.processes
|
||||
|
||||
@staticmethod
|
||||
def _get_sdk_environs(sdk_dir):
|
||||
sdk_env = {}
|
||||
|
||||
environ_pattern = sdk_dir + '/environment-setup-*'
|
||||
full_sdk_env = glob.glob(sdk_dir + '/environment-setup-*')
|
||||
for env in full_sdk_env:
|
||||
m = re.search('environment-setup-(.*)', env)
|
||||
if m:
|
||||
sdk_env[m.group(1)] = env
|
||||
|
||||
return sdk_env
|
||||
|
||||
def _display_sdk_envs(self, log, args, sdk_envs):
|
||||
log("Available SDK environments at directory %s:" \
|
||||
% args.sdk_dir)
|
||||
log("")
|
||||
for env in sdk_envs:
|
||||
log(env)
|
||||
|
||||
def run(self, logger, args):
|
||||
import argparse_oe
|
||||
|
||||
if not args.sdk_dir:
|
||||
raise argparse_oe.ArgumentUsageError("No SDK directory "\
|
||||
"specified please do, --sdk-dir SDK_DIR", self.name)
|
||||
|
||||
sdk_envs = OESDKTestContextExecutor._get_sdk_environs(args.sdk_dir)
|
||||
if not sdk_envs:
|
||||
raise argparse_oe.ArgumentUsageError("No available SDK "\
|
||||
"environments found at %s" % args.sdk_dir, self.name)
|
||||
|
||||
if args.list_sdk_env:
|
||||
self._display_sdk_envs(logger.info, args, sdk_envs)
|
||||
sys.exit(0)
|
||||
|
||||
if not args.sdk_env in sdk_envs:
|
||||
self._display_sdk_envs(logger.error, args, sdk_envs)
|
||||
raise argparse_oe.ArgumentUsageError("No valid SDK "\
|
||||
"environment (%s) specified" % args.sdk_env, self.name)
|
||||
|
||||
self.sdk_env = sdk_envs[args.sdk_env]
|
||||
return super(OESDKTestContextExecutor, self).run(logger, args)
|
||||
|
||||
_executor_class = OESDKTestContextExecutor
|
||||
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "hello"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
3
sources/poky/meta/lib/oeqa/sdk/files/rust/hello/build.rs
Normal file
3
sources/poky/meta/lib/oeqa/sdk/files/rust/hello/build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
/* This is the simplest build script just to invoke host compiler
|
||||
in the build process. */
|
||||
fn main() {}
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, OpenEmbedded world!");
|
||||
}
|
||||
5
sources/poky/meta/lib/oeqa/sdk/files/testsdkmakefile
Normal file
5
sources/poky/meta/lib/oeqa/sdk/files/testsdkmakefile
Normal file
@@ -0,0 +1,5 @@
|
||||
test: test.o
|
||||
$(CC) -o test test.o -lm
|
||||
test.o: test.c
|
||||
$(CC) -c test.c
|
||||
|
||||
45
sources/poky/meta/lib/oeqa/sdk/testmetaidesupport.py
Normal file
45
sources/poky/meta/lib/oeqa/sdk/testmetaidesupport.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
class TestSDK(object):
|
||||
def run(self, d):
|
||||
import json
|
||||
import logging
|
||||
from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
|
||||
from oeqa.utils import make_logger_bitbake_compatible
|
||||
|
||||
pn = d.getVar("PN")
|
||||
|
||||
logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
|
||||
|
||||
sdk_dir = d.expand("${WORKDIR}/testsdk/")
|
||||
bb.utils.remove(sdk_dir, True)
|
||||
bb.utils.mkdirhier(sdk_dir)
|
||||
|
||||
sdk_envs = OESDKTestContextExecutor._get_sdk_environs(d.getVar("DEPLOY_DIR_IMAGE"))
|
||||
tdname = d.expand("${DEPLOY_DIR_IMAGE}/${PN}.testdata.json")
|
||||
test_data = json.load(open(tdname, "r"))
|
||||
|
||||
host_pkg_manifest = {"cmake-native":"", "gcc-cross":"", "gettext-native":"", "meson-native":"", "perl-native":"", "python3-core-native":"", }
|
||||
target_pkg_manifest = {"gtk+3":""}
|
||||
|
||||
for s in sdk_envs:
|
||||
bb.plain("meta-ide-support based SDK testing environment: %s" % s)
|
||||
|
||||
sdk_env = sdk_envs[s]
|
||||
|
||||
tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
|
||||
sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
|
||||
host_pkg_manifest=host_pkg_manifest)
|
||||
|
||||
tc.loadTests(OESDKTestContextExecutor.default_cases)
|
||||
|
||||
results = tc.runTests()
|
||||
if results:
|
||||
results.logSummary(pn)
|
||||
|
||||
if (not results) or (not results.wasSuccessful()):
|
||||
bb.fatal('%s - FAILED' % (pn,), forcelog=True)
|
||||
141
sources/poky/meta/lib/oeqa/sdk/testsdk.py
Normal file
141
sources/poky/meta/lib/oeqa/sdk/testsdk.py
Normal file
@@ -0,0 +1,141 @@
|
||||
#
|
||||
# Copyright 2018 by Garmin Ltd. or its subsidiaries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
|
||||
|
||||
class TestSDKBase(object):
|
||||
@staticmethod
|
||||
def get_sdk_configuration(d, test_type):
|
||||
import platform
|
||||
import oe.lsb
|
||||
from oeqa.utils.metadata import get_layers
|
||||
configuration = {'TEST_TYPE': test_type,
|
||||
'MACHINE': d.getVar("MACHINE"),
|
||||
'SDKMACHINE': d.getVar("SDKMACHINE"),
|
||||
'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"),
|
||||
'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
|
||||
'STARTTIME': d.getVar("DATETIME"),
|
||||
'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'),
|
||||
'LAYERS': get_layers(d.getVar("BBLAYERS"))}
|
||||
return configuration
|
||||
|
||||
@staticmethod
|
||||
def get_sdk_result_id(configuration):
|
||||
return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME'])
|
||||
|
||||
class TestSDK(TestSDKBase):
|
||||
context_executor_class = OESDKTestContextExecutor
|
||||
context_class = OESDKTestContext
|
||||
test_type = 'sdk'
|
||||
|
||||
def get_tcname(self, d):
|
||||
"""
|
||||
Get the name of the SDK file
|
||||
"""
|
||||
return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
|
||||
|
||||
def extract_sdk(self, tcname, sdk_dir, d):
|
||||
"""
|
||||
Extract the SDK to the specified location
|
||||
"""
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))
|
||||
|
||||
def setup_context(self, d):
|
||||
"""
|
||||
Return a dictionary of additional arguments that should be passed to
|
||||
the context_class on construction
|
||||
"""
|
||||
return dict()
|
||||
|
||||
def run(self, d):
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
import logging
|
||||
|
||||
from bb.utils import export_proxies
|
||||
from oeqa.utils import make_logger_bitbake_compatible
|
||||
from oeqa.utils import get_json_result_dir
|
||||
|
||||
pn = d.getVar("PN")
|
||||
logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
|
||||
|
||||
# sdk use network for download projects for build
|
||||
export_proxies(d)
|
||||
|
||||
# We need the original PATH for testing the eSDK, not with our manipulations
|
||||
os.environ['PATH'] = d.getVar("BB_ORIGENV", False).getVar("PATH")
|
||||
|
||||
tcname = self.get_tcname(d)
|
||||
|
||||
if not os.path.exists(tcname):
|
||||
bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname)
|
||||
|
||||
tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json")
|
||||
test_data = json.load(open(tdname, "r"))
|
||||
|
||||
target_pkg_manifest = self.context_executor_class._load_manifest(
|
||||
d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"))
|
||||
host_pkg_manifest = self.context_executor_class._load_manifest(
|
||||
d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"))
|
||||
|
||||
processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS")
|
||||
if processes:
|
||||
try:
|
||||
import testtools, subunit
|
||||
except ImportError:
|
||||
bb.warn("Failed to import testtools or subunit, the testcases will run serially")
|
||||
processes = None
|
||||
|
||||
sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
|
||||
bb.utils.remove(sdk_dir, True)
|
||||
bb.utils.mkdirhier(sdk_dir)
|
||||
|
||||
context_args = self.setup_context(d)
|
||||
|
||||
self.extract_sdk(tcname, sdk_dir, d)
|
||||
|
||||
fail = False
|
||||
sdk_envs = self.context_executor_class._get_sdk_environs(sdk_dir)
|
||||
for s in sdk_envs:
|
||||
sdk_env = sdk_envs[s]
|
||||
bb.plain("SDK testing environment: %s" % s)
|
||||
tc = self.context_class(td=test_data, logger=logger, sdk_dir=sdk_dir,
|
||||
sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
|
||||
host_pkg_manifest=host_pkg_manifest, **context_args)
|
||||
|
||||
try:
|
||||
tc.loadTests(self.context_executor_class.default_cases)
|
||||
except Exception as e:
|
||||
import traceback
|
||||
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
|
||||
|
||||
if processes:
|
||||
result = tc.runTests(processes=int(processes))
|
||||
else:
|
||||
result = tc.runTests()
|
||||
|
||||
component = "%s %s" % (pn, self.context_executor_class.name)
|
||||
context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
|
||||
configuration = self.get_sdk_configuration(d, self.test_type)
|
||||
result.logDetails(get_json_result_dir(d),
|
||||
configuration,
|
||||
self.get_sdk_result_id(configuration))
|
||||
result.logSummary(component, context_msg)
|
||||
|
||||
if not result.wasSuccessful():
|
||||
fail = True
|
||||
|
||||
if fail:
|
||||
bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
|
||||
|
||||
|
||||
0
sources/poky/meta/lib/oeqa/sdk/utils/__init__.py
Normal file
0
sources/poky/meta/lib/oeqa/sdk/utils/__init__.py
Normal file
53
sources/poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py
Normal file
53
sources/poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Copyright (C) 2016 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from oeqa.utils.buildproject import BuildProject
|
||||
|
||||
class SDKBuildProject(BuildProject):
|
||||
def __init__(self, testpath, sdkenv, uri, testlogdir, builddatetime,
|
||||
foldername=None, dl_dir=None):
|
||||
self.sdkenv = sdkenv
|
||||
self.testdir = testpath
|
||||
self.targetdir = testpath
|
||||
os.makedirs(testpath, exist_ok=True)
|
||||
self.datetime = builddatetime
|
||||
self.testlogdir = testlogdir
|
||||
os.makedirs(self.testlogdir, exist_ok=True)
|
||||
self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime)
|
||||
BuildProject.__init__(self, uri, foldername, tmpdir=testpath, dl_dir=dl_dir)
|
||||
|
||||
def download_archive(self):
|
||||
self._download_archive()
|
||||
|
||||
cmd = 'tar xf %s -C %s' % (os.path.join(self.targetdir, self.archive), self.targetdir)
|
||||
subprocess.check_output(cmd, shell=True)
|
||||
|
||||
#Change targetdir to project folder
|
||||
self.targetdir = os.path.join(self.targetdir, self.fname)
|
||||
|
||||
def run_configure(self, configure_args='', extra_cmds=''):
|
||||
return super(SDKBuildProject, self).run_configure(configure_args=(configure_args or '$CONFIGURE_FLAGS'), extra_cmds=extra_cmds)
|
||||
|
||||
def run_install(self, install_args=''):
|
||||
return super(SDKBuildProject, self).run_install(install_args=(install_args or "DESTDIR=%s/../install" % self.targetdir))
|
||||
|
||||
def log(self, msg):
|
||||
if self.logfile:
|
||||
with open(self.logfile, "a") as f:
|
||||
f.write("%s\n" % msg)
|
||||
|
||||
def _run(self, cmd):
|
||||
self.log("Running . %s; " % self.sdkenv + cmd)
|
||||
try:
|
||||
output = subprocess.check_output(". %s; " % self.sdkenv + cmd, shell=True,
|
||||
executable='/bin/bash', stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
print(exc.output.decode('utf-8'))
|
||||
return exc.returncode
|
||||
return 0
|
||||
Reference in New Issue
Block a user