Initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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):
|
||||
if not (self.tc.hasHostPackage("nativesdk-cmake") or
|
||||
self.tc.hasHostPackage("cmake-native")):
|
||||
raise unittest.SkipTest("Needs cmake")
|
||||
if not (self.tc.hasTargetPackage("zlib", multilib=True) or \
|
||||
self.tc.hasTargetPackage("libz1", multilib=True)):
|
||||
raise unittest.SkipTest("Assimp test needs zlib in the SDK")
|
||||
|
||||
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/v4.1.0.tar.gz")
|
||||
|
||||
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")
|
||||
|
||||
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} && 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"))
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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 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.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")
|
||||
|
||||
subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
|
||||
self.assertTrue(os.path.isdir(dirs["source"]))
|
||||
os.makedirs(dirs["build"])
|
||||
|
||||
self._run("sed -i -e '/char.*program_name/d' {source}/src/global.c".format(**dirs))
|
||||
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))
|
||||
|
||||
self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))
|
||||
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# 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):
|
||||
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"))
|
||||
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# 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):
|
||||
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"))
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# 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 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"))
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# 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):
|
||||
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)
|
||||
@@ -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")
|
||||
@@ -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")
|
||||
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# 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)
|
||||
Reference in New Issue
Block a user