diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-14 20:05:37 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 04:26:31 +0300 |
commit | eb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch) | |
tree | de291a73dc37168da6370e2cf16c347d1eba9df8 /poky/meta/lib/oeqa/sdk | |
parent | 9c3cf826d853102535ead04cebc2d6023eff3032 (diff) | |
download | openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz |
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers
content to the top level.
Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'poky/meta/lib/oeqa/sdk')
-rw-r--r-- | poky/meta/lib/oeqa/sdk/__init__.py | 0 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/case.py | 12 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/buildcpio.py | 33 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/buildgalculator.py | 35 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/buildlzip.py | 36 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/gcc.py | 43 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/perl.py | 28 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/cases/python.py | 32 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/context.py | 134 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/files/testsdkmakefile | 5 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/utils/__init__.py | 0 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py | 45 |
12 files changed, 403 insertions, 0 deletions
diff --git a/poky/meta/lib/oeqa/sdk/__init__.py b/poky/meta/lib/oeqa/sdk/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/__init__.py diff --git a/poky/meta/lib/oeqa/sdk/case.py b/poky/meta/lib/oeqa/sdk/case.py new file mode 100644 index 0000000000..963aa8d358 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/case.py @@ -0,0 +1,12 @@ +# Copyright (C) 2016 Intel Corporation +# Released under the MIT license (see COPYING.MIT) + +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, + stderr=subprocess.STDOUT, universal_newlines=True) diff --git a/poky/meta/lib/oeqa/sdk/cases/buildcpio.py b/poky/meta/lib/oeqa/sdk/cases/buildcpio.py new file mode 100644 index 0000000000..333dc7c226 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/buildcpio.py @@ -0,0 +1,33 @@ +import unittest +from oeqa.sdk.case import OESDKTestCase +from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject + +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") + + def test_cpio(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() diff --git a/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py b/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py new file mode 100644 index 0000000000..780afccc74 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/buildgalculator.py @@ -0,0 +1,35 @@ +import unittest + +from oeqa.sdk.case import OESDKTestCase +from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject + +class GalculatorTest(OESDKTestCase): + td_vars = ['DATETIME'] + + @classmethod + def setUpClass(self): + if not (self.tc.hasTargetPackage("gtk\+3") or\ + self.tc.hasTargetPackage("libgtk-3.0")): + raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3") + + 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() diff --git a/poky/meta/lib/oeqa/sdk/cases/buildlzip.py b/poky/meta/lib/oeqa/sdk/cases/buildlzip.py new file mode 100644 index 0000000000..3a89ce8627 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/buildlzip.py @@ -0,0 +1,36 @@ +import unittest +from oeqa.sdk.case import OESDKTestCase +from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject + + +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.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or + self.tc.hasTargetPackage("gcc")): + raise unittest.SkipTest("SDK doesn't contain a cross-canadian toolchain") + + 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() diff --git a/poky/meta/lib/oeqa/sdk/cases/gcc.py b/poky/meta/lib/oeqa/sdk/cases/gcc.py new file mode 100644 index 0000000000..d11f4b63fb --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/gcc.py @@ -0,0 +1,43 @@ +import os +import shutil +import unittest + +from oeqa.core.utils.path import remove_safe +from oeqa.sdk.case import OESDKTestCase + +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.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or + self.tc.hasTargetPackage("gcc")): + 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) diff --git a/poky/meta/lib/oeqa/sdk/cases/perl.py b/poky/meta/lib/oeqa/sdk/cases/perl.py new file mode 100644 index 0000000000..8085678116 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/perl.py @@ -0,0 +1,28 @@ +import os +import shutil +import unittest + +from oeqa.core.utils.path import remove_safe +from oeqa.sdk.case import OESDKTestCase + +class PerlTest(OESDKTestCase): + @classmethod + def setUpClass(self): + if not (self.tc.hasHostPackage("nativesdk-perl") or + self.tc.hasHostPackage("perl-native")): + raise unittest.SkipTest("No perl package in the SDK") + + for f in ['test.pl']: + shutil.copyfile(os.path.join(self.tc.files_dir, f), + os.path.join(self.tc.sdk_dir, f)) + self.testfile = os.path.join(self.tc.sdk_dir, "test.pl") + + def test_perl_exists(self): + self._run('which perl') + + def test_perl_works(self): + self._run('perl %s' % self.testfile) + + @classmethod + def tearDownClass(self): + remove_safe(self.testfile) diff --git a/poky/meta/lib/oeqa/sdk/cases/python.py b/poky/meta/lib/oeqa/sdk/cases/python.py new file mode 100644 index 0000000000..72dfcc72bd --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/cases/python.py @@ -0,0 +1,32 @@ +import os +import shutil +import unittest + +from oeqa.core.utils.path import remove_safe +from oeqa.sdk.case import OESDKTestCase + +class PythonTest(OESDKTestCase): + @classmethod + def setUpClass(self): + if not (self.tc.hasHostPackage("nativesdk-python") or + self.tc.hasHostPackage("python-native")): + raise unittest.SkipTest("No python package in the SDK") + + for f in ['test.py']: + shutil.copyfile(os.path.join(self.tc.files_dir, f), + os.path.join(self.tc.sdk_dir, f)) + + def test_python_exists(self): + self._run('which python') + + def test_python_stdout(self): + output = self._run('python %s/test.py' % self.tc.sdk_dir) + self.assertEqual(output.strip(), "the value of a is 0.01", msg="Incorrect output: %s" % output) + + def test_python_testfile(self): + self._run('ls /tmp/testfile.python') + + @classmethod + def tearDownClass(self): + remove_safe("%s/test.py" % self.tc.sdk_dir) + remove_safe("/tmp/testfile.python") diff --git a/poky/meta/lib/oeqa/sdk/context.py b/poky/meta/lib/oeqa/sdk/context.py new file mode 100644 index 0000000000..b3d7c75183 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/context.py @@ -0,0 +1,134 @@ +# Copyright (C) 2016 Intel Corporation +# Released under the MIT license (see COPYING.MIT) + +import os +import sys +import glob +import re + +from oeqa.core.context import OETestContextExecutor +from oeqa.core.threaded import OETestContextThreaded + +class OESDKTestContext(OETestContextThreaded): + 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): + for host_pkg in manifest.keys(): + if re.search(pkg, host_pkg): + return True + return False + + def hasHostPackage(self, pkg): + return self._hasPackage(self.host_pkg_manifest, pkg) + + def hasTargetPackage(self, pkg): + return self._hasPackage(self.target_pkg_manifest, pkg) + +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') + + @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) + + @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 "\ + "enviroments 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 diff --git a/poky/meta/lib/oeqa/sdk/files/testsdkmakefile b/poky/meta/lib/oeqa/sdk/files/testsdkmakefile new file mode 100644 index 0000000000..fb05f822f3 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/files/testsdkmakefile @@ -0,0 +1,5 @@ +test: test.o + $(CC) -o test test.o -lm +test.o: test.c + $(CC) -c test.c + diff --git a/poky/meta/lib/oeqa/sdk/utils/__init__.py b/poky/meta/lib/oeqa/sdk/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/utils/__init__.py diff --git a/poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py b/poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py new file mode 100644 index 0000000000..4e251142d7 --- /dev/null +++ b/poky/meta/lib/oeqa/sdk/utils/sdkbuildproject.py @@ -0,0 +1,45 @@ +# Copyright (C) 2016 Intel Corporation +# Released under the MIT license (see COPYING.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%s -C %s' % (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) + return subprocess.call(". %s; " % self.sdkenv + cmd, shell=True) |