diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
commit | 1c7d6584a7811b7785ae5c1e378f14b5ba0971cf (patch) | |
tree | cd70a267a5ef105ba32f200aa088e281fbd85747 /external/poky/meta/lib/oeqa/sdk/cases | |
parent | 4204309872da5cb401cbb2729d9e2d4869a87f42 (diff) |
basesystem-jjsandbox/ToshikazuOhiwa/master-jj
recipes
Diffstat (limited to 'external/poky/meta/lib/oeqa/sdk/cases')
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/assimp.py | 65 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/buildcpio.py | 52 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py | 41 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py | 56 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/buildlzip.py | 65 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/gcc.py | 7 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/perl.py | 19 | ||||
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/python.py | 36 |
8 files changed, 196 insertions, 145 deletions
diff --git a/external/poky/meta/lib/oeqa/sdk/cases/assimp.py b/external/poky/meta/lib/oeqa/sdk/cases/assimp.py index 26c1df08..f26b17f2 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/assimp.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/assimp.py @@ -1,5 +1,11 @@ -import os, subprocess, unittest -import bb +# +# 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 @@ -10,54 +16,25 @@ class BuildAssimp(OESDKTestCase): Test case to build a project using cmake. """ - td_vars = ['DATETIME', 'TARGET_OS', 'TARGET_ARCH'] - - @classmethod - def setUpClass(self): + def setUp(self): if not (self.tc.hasHostPackage("nativesdk-cmake") or self.tc.hasHostPackage("cmake-native")): raise unittest.SkipTest("Needs cmake") - 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 test_assimp(self): - import tempfile - import oe.qa, oe.elf - with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir: - dl_dir = self.td.get('DL_DIR', None) - tarball = self.fetch(testdir, dl_dir, "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz") - subprocess.check_output(["tar", "xf", tarball, "-C", testdir]) - - sourcedir = os.path.join(testdir, "assimp-4.1.0") - builddir = os.path.join(testdir, "build") - installdir = os.path.join(testdir, "install") - bb.utils.mkdirhier(builddir) + tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz") - self._run("cd %s && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON %s " % (builddir, sourcedir)) - self._run("cmake --build %s -- -j" % builddir) - self._run("cmake --build %s --target install -- DESTDIR=%s" % (builddir, installdir)) + dirs = {} + dirs["source"] = os.path.join(testdir, "assimp-4.1.0") + dirs["build"] = os.path.join(testdir, "build") + dirs["install"] = os.path.join(testdir, "install") - elf = oe.qa.ELFFile(os.path.join(installdir, "usr", "local", "lib", "libassimp.so.4.1.0")) - elf.open() - - 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 + subprocess.check_output(["tar", "xf", tarball, "-C", testdir]) + self.assertTrue(os.path.isdir(dirs["source"])) + os.makedirs(dirs["build"]) - self.assertEqual(machine, elf.machine()) - self.assertEqual(bits, elf.abiSize()) - self.assertEqual(endian, elf.isLittleEndian()) + self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=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.4.1.0")) diff --git a/external/poky/meta/lib/oeqa/sdk/cases/buildcpio.py b/external/poky/meta/lib/oeqa/sdk/cases/buildcpio.py index 333dc7c2..902e93f6 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/buildcpio.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/buildcpio.py @@ -1,33 +1,35 @@ +# +# SPDX-License-Identifier: MIT +# + +import os +import tempfile +import subprocess import unittest + from oeqa.sdk.case import OESDKTestCase -from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() class BuildCpioTest(OESDKTestCase): - td_vars = ['DATETIME'] - - @classmethod - def setUpClass(self): - dl_dir = self.td.get('DL_DIR', None) - - self.project = SDKBuildProject(self.tc.sdk_dir + "/cpio/", self.tc.sdk_env, - "https://ftp.gnu.org/gnu/cpio/cpio-2.12.tar.gz", - self.tc.sdk_dir, self.td['DATETIME'], dl_dir=dl_dir) - self.project.download_archive() - - machine = self.td.get("MACHINE") - if not self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine): - raise unittest.SkipTest("SDK doesn't contain a cross-canadian toolchain") - + """ + Check that autotools will cross-compile correctly. + """ def test_cpio(self): - self.assertEqual(self.project.run_configure(), 0, - msg="Running configure failed") + 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.13.tar.gz") + + dirs = {} + dirs["source"] = os.path.join(testdir, "cpio-2.13") + dirs["build"] = os.path.join(testdir, "build") + dirs["install"] = os.path.join(testdir, "install") - self.assertEqual(self.project.run_make(), 0, - msg="Running make failed") + subprocess.check_output(["tar", "xf", tarball, "-C", testdir]) + self.assertTrue(os.path.isdir(dirs["source"])) + os.makedirs(dirs["build"]) - self.assertEqual(self.project.run_install(), 0, - msg="Running make install failed") + self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs)) + self._run("cd {build} && make -j".format(**dirs)) + self._run("cd {build} && make install DESTDIR={install}".format(**dirs)) - @classmethod - def tearDownClass(self): - self.project.clean() + self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio")) diff --git a/external/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py b/external/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py new file mode 100644 index 00000000..4211955f --- /dev/null +++ b/external/poky/meta/lib/oeqa/sdk/cases/buildepoxy.py @@ -0,0 +1,41 @@ +# +# 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): + if not (self.tc.hasHostPackage("nativesdk-meson")): + raise unittest.SkipTest("GalculatorTest 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]) + self.assertTrue(os.path.isdir(dirs["source"])) + os.makedirs(dirs["build"]) + + log = self._run("meson -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")) diff --git a/external/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py b/external/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py index 050d1b3b..bbaa5c55 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py @@ -1,13 +1,21 @@ +# +# SPDX-License-Identifier: MIT +# + +import os +import subprocess +import tempfile import unittest from oeqa.sdk.case import OESDKTestCase -from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() class GalculatorTest(OESDKTestCase): - td_vars = ['DATETIME'] - - @classmethod - def setUpClass(self): + """ + Test that autotools and GTK+ 3 compiles correctly. + """ + def setUp(self): 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") @@ -15,23 +23,21 @@ class GalculatorTest(OESDKTestCase): raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext") def test_galculator(self): - dl_dir = self.td.get('DL_DIR', None) - project = None - try: - project = SDKBuildProject(self.tc.sdk_dir + "/galculator/", - self.tc.sdk_env, - "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2", - self.tc.sdk_dir, self.td['DATETIME'], dl_dir=dl_dir) - - project.download_archive() - - # regenerate configure to get support for --with-libtool-sysroot - legacy_preconf=("autoreconf -i -f -I ${OECORE_TARGET_SYSROOT}/usr/share/aclocal -I m4;") - - self.assertEqual(project.run_configure(extra_cmds=legacy_preconf), - 0, msg="Running configure failed") - - self.assertEqual(project.run_make(), 0, - msg="Running make failed") - finally: - project.clean() + 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]) + self.assertTrue(os.path.isdir(dirs["source"])) + os.makedirs(dirs["build"]) + + self._run("cd {source} && 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")) diff --git a/external/poky/meta/lib/oeqa/sdk/cases/buildlzip.py b/external/poky/meta/lib/oeqa/sdk/cases/buildlzip.py index b28cc3a5..515acd28 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/buildlzip.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/buildlzip.py @@ -1,36 +1,37 @@ -import unittest -from oeqa.sdk.case import OESDKTestCase -from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject +# +# 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): - td_vars = ['DATETIME'] - - @classmethod - def setUpClass(self): - dl_dir = self.td.get('DL_DIR', None) - - self.project = SDKBuildProject(self.tc.sdk_dir + "/lzip/", self.tc.sdk_env, - "http://downloads.yoctoproject.org/mirror/sources/lzip-1.19.tar.gz", - self.tc.sdk_dir, self.td['DATETIME'], dl_dir=dl_dir) - self.project.download_archive() - - 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("SDK doesn't contain a cross-canadian toolchain") - + """ + Test that "plain" compilation works, using just $CC $CFLAGS etc. + """ def test_lzip(self): - self.assertEqual(self.project.run_configure(), 0, - msg="Running configure failed") - - self.assertEqual(self.project.run_make(), 0, - msg="Running make failed") - - self.assertEqual(self.project.run_install(), 0, - msg="Running make install failed") - - @classmethod - def tearDownClass(self): - self.project.clean() + 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]) + 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")) diff --git a/external/poky/meta/lib/oeqa/sdk/cases/gcc.py b/external/poky/meta/lib/oeqa/sdk/cases/gcc.py index b32b01fc..eb08eadd 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/gcc.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/gcc.py @@ -1,3 +1,7 @@ +# +# SPDX-License-Identifier: MIT +# + import os import shutil import unittest @@ -5,6 +9,9 @@ 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'] diff --git a/external/poky/meta/lib/oeqa/sdk/cases/perl.py b/external/poky/meta/lib/oeqa/sdk/cases/perl.py index ff50b468..14d76d82 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/perl.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/perl.py @@ -1,17 +1,20 @@ +# +# 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): - @classmethod - def setUpClass(self): + 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): - try: - cmd = "perl -e '$_=\"Uryyb, jbeyq\"; tr/a-zA-Z/n-za-mN-ZA-M/;print'" - output = self._run(cmd) - self.assertEqual(output, "Hello, world") - except subprocess.CalledProcessError as e: - self.fail("Unexpected exit %d (output %s)" % (e.returncode, e.output)) + cmd = "perl -e '$_=\"Uryyb, jbeyq\"; tr/a-zA-Z/n-za-mN-ZA-M/;print'" + output = self._run(cmd) + self.assertEqual(output, "Hello, world") diff --git a/external/poky/meta/lib/oeqa/sdk/cases/python.py b/external/poky/meta/lib/oeqa/sdk/cases/python.py index bd5f1f67..a334abce 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/python.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/python.py @@ -1,17 +1,31 @@ +# +# SPDX-License-Identifier: MIT +# + import subprocess, unittest from oeqa.sdk.case import OESDKTestCase -class PythonTest(OESDKTestCase): - @classmethod - def setUpClass(self): - if not (self.tc.hasHostPackage("nativesdk-python3") or - self.tc.hasHostPackage("python3-native")): +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class Python2Test(OESDKTestCase): + def setUp(self): + if not (self.tc.hasHostPackage("nativesdk-python-core") or + self.tc.hasHostPackage("python-core-native")): raise unittest.SkipTest("No python package in the SDK") + def test_python2(self): + cmd = "python -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" + output = self._run(cmd) + self.assertEqual(output, "Hello, world\n") + +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): - try: - cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" - output = self._run(cmd) - self.assertEqual(output, "Hello, world\n") - except subprocess.CalledProcessError as e: - self.fail("Unexpected exit %d (output %s)" % (e.returncode, e.output)) + cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" + output = self._run(cmd) + self.assertEqual(output, "Hello, world\n") |