All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Enable installation of packages in DUT
@ 2016-06-01 10:46 mariano.lopez
  2016-06-01 10:46 ` [PATCH 1/5] oetest.py: Add install/uninstall functionality for DUTs mariano.lopez
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

This series enable the functionality to install packages in the DUT
during runtime testing. Such packages must had been build previously
by bitbake and the packages are specified using a JSON file. This
functionality works with testimage and with testexport.

This address the concer of adding a task to extract the packages,
instead the extraction was added to the testimage and testexport
tasks. 

This also includes the use of an SDK package for systems with
missing dependencies in the testing system.

This address several bugs:
  - 7850
  - 8694
  - 8481


The following changes since commit 3c42280b8a5cac184311a59589849fec4e215a14:

  sanity: Drop setting C locale (2016-06-01 15:05:47 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib mariano/bug7850v3
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=mariano/bug7850v3

Mariano Lopez (5):
  oetest.py: Add install/uninstall functionality for DUTs
  testimage.bbclass: Make dependency of cpio when using RPMs
  testexport-tarball.bb: Add recipe
  testexport.bbclass: Add support for testexport-tarball
  testexport.bbclass: Create tarballs for easy release

 meta/classes/testexport.bbclass              | 77 ++++++++++++++++++++++++++--
 meta/classes/testimage.bbclass               | 20 ++++++++
 meta/lib/oeqa/oetest.py                      | 74 ++++++++++++++++++++++++++
 meta/lib/oeqa/runexported.py                 | 35 ++++++++++++-
 meta/recipes-core/meta/testexport-tarball.bb | 56 ++++++++++++++++++++
 5 files changed, 256 insertions(+), 6 deletions(-)
 create mode 100644 meta/recipes-core/meta/testexport-tarball.bb

-- 
2.6.6



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] oetest.py: Add install/uninstall functionality for DUTs
  2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
@ 2016-06-01 10:46 ` mariano.lopez
  2016-06-01 10:46 ` [PATCH 2/5] testimage.bbclass: Make dependency of cpio when using RPMs mariano.lopez
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

Add the functionality to install/unistall packages in the
DUTs without the use of the package manager. This is possible
with the extraction introduced in the previous commits.

testimage and testexport bbclasses has been modified in order
to support this new feature.

[YOCTO #8694]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/classes/testexport.bbclass | 34 ++++++++++++++++---
 meta/classes/testimage.bbclass  | 18 ++++++++++
 meta/lib/oeqa/oetest.py         | 74 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+), 5 deletions(-)

diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index e06c668..f613149d 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -16,6 +16,9 @@
 
 TEST_LOG_DIR ?= "${WORKDIR}/testexport"
 TEST_EXPORT_DIR ?= "${TMPDIR}/testexport/${PN}"
+TEST_EXPORT_PACKAGED_DIR ?= "packages/packaged"
+TEST_EXPORT_EXTRACTED_DIR ?= "packages/extracted"
+
 TEST_TARGET ?= "simpleremote"
 TEST_TARGET_IP ?= ""
 TEST_SERVER_IP ?= ""
@@ -28,9 +31,9 @@ python do_testexport() {
 }
 
 addtask testexport
-do_testimage[nostamp] = "1"
-do_testimage[depends] += "${TEST_EXPORT_DEPENDS}"
-do_testimage[lockfiles] += "${TEST_EXPORT_LOCK}"
+do_testexport[nostamp] = "1"
+do_testexport[depends] += "${TEST_EXPORT_DEPENDS} ${TESTIMAGEDEPENDS}"
+do_testexport[lockfiles] += "${TEST_EXPORT_LOCK}"
 
 def exportTests(d,tc):
     import json
@@ -96,6 +99,10 @@ def exportTests(d,tc):
                         shutil.copytree(foldername, target_folder)
         if not isfolder:
             shutil.copy2(mod.filename, os.path.join(exportpath, "oeqa/runtime"))
+            json_file = "%s.json" % mod.filename.rsplit(".", 1)[0]
+            if os.path.isfile(json_file):
+                shutil.copy2(json_file, os.path.join(exportpath, "oeqa/runtime"))
+
     # copy __init__.py files
     oeqadir = pkgutil.get_loader("oeqa").filename
     shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa"))
@@ -113,6 +120,20 @@ def exportTests(d,tc):
         for f in files:
             shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
 
+    # Copy packages needed for runtime testing
+    export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
+    test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True)
+    for root, subdirs, files in os.walk(test_pkg_dir):
+        for subdir in subdirs:
+            tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir)
+            new_dir = os.path.join(export_pkg_dir, tmp_dir)
+            bb.utils.mkdirhier(new_dir)
+
+        for f in files:
+            src_f = os.path.join(root, f)
+            dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
+            shutil.copy2(src_f, dst_f)
+
     bb.plain("Exported tests to: %s" % exportpath)
 
 def testexport_main(d):
@@ -120,9 +141,11 @@ def testexport_main(d):
     from oeqa.targetcontrol import get_target_controller
     from oeqa.utils.dump import get_host_dumper
 
+    test_create_extract_dirs(d)
+    export_dir = d.getVar("TEST_EXPORT_DIR", True)
     bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
-    bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True)
-    bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True))
+    bb.utils.remove(export_dir, recurse=True)
+    bb.utils.mkdirhier(export_dir)
 
     # the robot dance
     target = get_target_controller(d)
@@ -139,6 +162,7 @@ def testexport_main(d):
         import traceback
         bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
 
+    tc.extract_packages()
     exportTests(d,tc)
 
 testexport_main[vardepsexclude] =+ "BB_ORIGENV"
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index a2e13df..a70d3a8 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -30,6 +30,10 @@
 TEST_LOG_DIR ?= "${WORKDIR}/testimage"
 
 TEST_EXPORT_DIR ?= "${TMPDIR}/testimage/${PN}"
+TEST_INSTALL_TMP_DIR ?= "${WORKDIR}/testimage/install_tmp"
+TEST_NEEDED_PACKAGES_DIR ?= "${WORKDIR}/testimage/packages"
+TEST_EXTRACTED_DIR ?= "${TEST_NEEDED_PACKAGES_DIR}/extracted"
+TEST_PACKAGED_DIR ?= "${TEST_NEEDED_PACKAGES_DIR}/packaged"
 
 RPMTESTSUITE = "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'smart rpm', '', d)}"
 MINTESTSUITE = "ping"
@@ -100,6 +104,7 @@ testimage_dump_host () {
 python do_testimage() {
     testimage_main(d)
 }
+
 addtask testimage
 do_testimage[nostamp] = "1"
 do_testimage[depends] += "${TESTIMAGEDEPENDS}"
@@ -117,6 +122,7 @@ def testimage_main(d):
 
     pn = d.getVar("PN", True)
     bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
+    test_create_extract_dirs(d)
 
     # we need the host dumper in test context
     host_dumper = get_host_dumper(d)
@@ -136,6 +142,7 @@ def testimage_main(d):
         import traceback
         bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
 
+    tc.extract_packages()
     target.deploy()
     try:
         target.start()
@@ -155,6 +162,17 @@ def testimage_main(d):
         signal.signal(signal.SIGTERM, tc.origsigtermhandler)
         target.stop()
 
+def test_create_extract_dirs(d):
+    install_path = d.getVar("TEST_INSTALL_TMP_DIR", True)
+    package_path = d.getVar("TEST_PACKAGED_DIR", True)
+    extracted_path = d.getVar("TEST_EXTRACTED_DIR", True)
+    bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
+    bb.utils.remove(package_path, recurse=True)
+    bb.utils.mkdirhier(install_path)
+    bb.utils.mkdirhier(package_path)
+    bb.utils.mkdirhier(extracted_path)
+
+
 testimage_main[vardepsexclude] =+ "BB_ORIGENV"
 
 inherit testsdk
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index a50f9d8..dfac09b 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -80,6 +80,9 @@ class oeRuntimeTest(oeTest):
         super(oeRuntimeTest, self).__init__(methodName)
 
     def setUp(self):
+        # Install packages in the DUT
+        self.tc.install_uninstall_packages(self.id())
+
         # Check if test needs to run
         if self.tc.sigterm:
             self.fail("Got SIGTERM")
@@ -93,6 +96,9 @@ class oeRuntimeTest(oeTest):
         pass
 
     def tearDown(self):
+        # Unistall packages in the DUT
+        self.tc.install_uninstall_packages(self.id(), False)
+
         res = getResults()
         # If a test fails or there is an exception dump
         # for QemuTarget only
@@ -281,6 +287,19 @@ class TestContext(object):
 
         return modules
 
+    def getModulefromID(self, test_id):
+        """
+        Returns the test module based on a test id.
+        """
+
+        module_name = ".".join(test_id.split(".")[:3])
+        modules = self.getTestModules()
+        for module in modules:
+            if module.fullname == module_name:
+                return module
+
+        return None
+
     def getTests(self, test):
         '''Return all individual tests executed when running the suite.'''
         # Unfortunately unittest does not have an API for this, so we have
@@ -514,6 +533,43 @@ class RuntimeTestContext(TestContext):
         shutil.copy2(file_path, dst_dir)
         shutil.rmtree(pkg_path)
 
+    def install_uninstall_packages(self, test_id, pkg_dir, install):
+        """
+        Check if the test requires a package and Install/Unistall it in the DUT
+        """
+
+        test = test_id.split(".")[4]
+        module = self.getModulefromID(test_id)
+        json = self._getJsonFile(module)
+        if json:
+            needed_packages = self._getNeededPackages(json, test)
+            if needed_packages:
+                self._install_uninstall_packages(needed_packages, pkg_dir, install)
+
+    def _install_uninstall_packages(self, needed_packages, pkg_dir, install=True):
+        """
+        Install/Unistall packages in the DUT without using a package manager
+        """
+
+        if isinstance(needed_packages, dict):
+            packages = [needed_packages]
+        elif isinstance(needed_packages, list):
+            packages = needed_packages
+
+        for package in packages:
+            pkg = package["pkg"]
+            rm = package.get("rm", False)
+            extract = package.get("extract", True)
+            src_dir = os.path.join(pkg_dir, pkg)
+
+            # Install package
+            if install and extract:
+                self.target.connection.copy_dir_to(src_dir, "/")
+
+            # Unistall package
+            elif not install and rm:
+                self.target.connection.delete_dir_structure(src_dir, "/")
+
 class ImageTestContext(RuntimeTestContext):
     def __init__(self, d, target, host_dumper):
         super(ImageTestContext, self).__init__(d, target)
@@ -529,11 +585,29 @@ class ImageTestContext(RuntimeTestContext):
         self.sigterm = True
         self.target.stop()
 
+    def install_uninstall_packages(self, test_id, install=True):
+        """
+        Check if the test requires a package and Install/Unistall it in the DUT
+        """
+
+        pkg_dir = self.d.getVar("TEST_EXTRACTED_DIR", True)
+        super(ImageTestContext, self).install_uninstall_packages(test_id, pkg_dir, install)
+
 class ExportTestContext(RuntimeTestContext):
     def __init__(self, d, target, exported=False):
         super(ExportTestContext, self).__init__(d, target, exported)
         self.sigterm = None
 
+    def install_uninstall_packages(self, test_id, install=True):
+        """
+        Check if the test requires a package and Install/Unistall it in the DUT
+        """
+
+        export_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+        extracted_dir = self.d.getVar("TEST_EXPORT_EXTRACTED_DIR", True)
+        pkg_dir = os.path.join(export_dir, extracted_dir)
+        super(ExportTestContext, self).install_uninstall_packages(test_id, pkg_dir, install)
+
 class SDKTestContext(TestContext):
     def __init__(self, d, sdktestdir, sdkenv, tcname, *args):
         super(SDKTestContext, self).__init__(d)
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] testimage.bbclass: Make dependency of cpio when using RPMs
  2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
  2016-06-01 10:46 ` [PATCH 1/5] oetest.py: Add install/uninstall functionality for DUTs mariano.lopez
@ 2016-06-01 10:46 ` mariano.lopez
  2016-06-01 10:46 ` [PATCH 3/5] testexport-tarball.bb: Add recipe mariano.lopez
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

Exctraction of RPMs needs cpio, not all distros include cpio by
default, so we need to build it.

[YOCTO #8694]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/classes/testexport.bbclass | 1 +
 meta/classes/testimage.bbclass  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index f613149d..a3c6a35 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -24,6 +24,7 @@ TEST_TARGET_IP ?= ""
 TEST_SERVER_IP ?= ""
 
 TEST_EXPORT_DEPENDS = ""
+TEST_EXPORT_DEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
 TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock"
 
 python do_testexport() {
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index a70d3a8..7fd0f62 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -68,6 +68,8 @@ TEST_TARGET ?= "qemu"
 
 TESTIMAGEDEPENDS = ""
 TESTIMAGEDEPENDS_qemuall = "qemu-native:do_populate_sysroot qemu-helper-native:do_populate_sysroot"
+TESTIMAGEDEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
+TESTIMAGEDEPENDS_qemuall += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
 
 TESTIMAGELOCK = "${TMPDIR}/testimage.lock"
 TESTIMAGELOCK_qemuall = ""
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] testexport-tarball.bb: Add recipe
  2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
  2016-06-01 10:46 ` [PATCH 1/5] oetest.py: Add install/uninstall functionality for DUTs mariano.lopez
  2016-06-01 10:46 ` [PATCH 2/5] testimage.bbclass: Make dependency of cpio when using RPMs mariano.lopez
@ 2016-06-01 10:46 ` mariano.lopez
  2016-06-01 10:46 ` [PATCH 4/5] testexport.bbclass: Add support for testexport-tarball mariano.lopez
  2016-06-01 10:46 ` [PATCH 5/5] testexport.bbclass: Create tarballs for easy release mariano.lopez
  4 siblings, 0 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

This new recipe is used when exporting runtime test outside
packages that won't be installed in the testing system but
are required for the runtime testing.

This new recipe is almost identical to buildtools-tarball,
but is able to define the SDK packages in local.conf.

[YOCTO #7850]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/recipes-core/meta/testexport-tarball.bb | 56 ++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 meta/recipes-core/meta/testexport-tarball.bb

diff --git a/meta/recipes-core/meta/testexport-tarball.bb b/meta/recipes-core/meta/testexport-tarball.bb
new file mode 100644
index 0000000..951d3be
--- /dev/null
+++ b/meta/recipes-core/meta/testexport-tarball.bb
@@ -0,0 +1,56 @@
+DESCRIPTION = "SDK type target for standalone tarball containing packages defined by TEST_EXPORT_TOOLS. The \
+               tarball can be used to run missing programs on testing systems which don't have such tools.\
+               This recipe is almost the same as buildtools-tarball"
+SUMMARY = "Standalone tarball for test systems with missing software"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
+                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+TOOLCHAIN_TARGET_TASK ?= ""
+
+TOOLCHAIN_HOST_TASK ?= "${TEST_EXPORT_SDK_PACKAGES}"
+
+SDK_PACKAGE_ARCHS += "tesexport-tools-${SDKPKGSUFFIX}"
+
+TOOLCHAIN_OUTPUTNAME ?= "${TEST_EXPORT_SDK_NAME}"
+
+SDK_TITLE = "Testexport tools"
+
+RDEPENDS = "${TOOLCHAIN_HOST_TASK}"
+
+EXCLUDE_FROM_WORLD = "1"
+
+inherit meta
+inherit populate_sdk
+inherit toolchain-scripts
+
+create_sdk_files_append () {
+	rm -f ${SDK_OUTPUT}/${SDKPATH}/site-config-*
+	rm -f ${SDK_OUTPUT}/${SDKPATH}/environment-setup-*
+	rm -f ${SDK_OUTPUT}/${SDKPATH}/version-*
+
+	# Generate new (mini) sdk-environment-setup file
+	script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-${SDK_SYS}}
+	touch $script
+	echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:$PATH' >> $script
+	# In order for the self-extraction script to correctly extract and set up things,
+	# we need a 'OECORE_NATIVE_SYSROOT=xxx' line in environment setup script.
+	# However, testexport-tarball is inherently a tool set instead of a fully functional SDK,
+	# so instead of exporting the variable, we use a comment here.
+	echo '#OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
+	toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${SDK_SYS}
+
+	echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
+
+	if [ "${SDKMACHINE}" = "i686" ]; then
+		echo 'export NO32LIBS="0"' >>$script
+		echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script
+		echo '[ $? != 0 ] && export BB_ENV_EXTRAWHITE="NO32LIBS $BB_ENV_EXTRAWHITE"' >>$script
+	fi
+}
+
+# testexport-tarball doesn't need config site
+TOOLCHAIN_NEED_CONFIGSITE_CACHE = ""
+
+# The recipe doesn't need any default deps
+INHIBIT_DEFAULT_DEPS = "1"
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] testexport.bbclass: Add support for testexport-tarball
  2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
                   ` (2 preceding siblings ...)
  2016-06-01 10:46 ` [PATCH 3/5] testexport-tarball.bb: Add recipe mariano.lopez
@ 2016-06-01 10:46 ` mariano.lopez
  2016-06-01 10:46 ` [PATCH 5/5] testexport.bbclass: Create tarballs for easy release mariano.lopez
  4 siblings, 0 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

Add support to export the SDK tarball needed when a test
system doesn't have the required software to perform runtime
tests.

The support is when exporting the test and when running
the test on a remote system. The user of this feature just
need to set TEST_EXPORT_SDK_ENABLED to "1" and declare
the sdk packages in TEST_EXPORT_SDK_PACKAGES.

[YOCTO #7850]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/classes/testexport.bbclass | 16 ++++++++++++++++
 meta/lib/oeqa/runexported.py    | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index a3c6a35..33acadd 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -23,8 +23,14 @@ TEST_TARGET ?= "simpleremote"
 TEST_TARGET_IP ?= ""
 TEST_SERVER_IP ?= ""
 
+TEST_EXPORT_SDK_PACKAGES ?= ""
+TEST_EXPORT_SDK_ENABLED ?= "0"
+TEST_EXPORT_SDK_NAME ?= "testexport-tools-nativesdk"
+TEST_EXPORT_SDK_DIR ?= "sdk"
+
 TEST_EXPORT_DEPENDS = ""
 TEST_EXPORT_DEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
+TEST_EXPORT_DEPENDS += "${@bb.utils.contains('TEST_EXPORT_SDK_ENABLED', '1', 'testexport-tarball:do_populate_sdk', '', d)}"
 TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock"
 
 python do_testexport() {
@@ -135,6 +141,16 @@ def exportTests(d,tc):
             dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
             shutil.copy2(src_f, dst_f)
 
+    # Copy SDK
+    if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
+        sdk_deploy = d.getVar("SDK_DEPLOY", True)
+        tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
+        tarball_path = os.path.join(sdk_deploy, tarball_name)
+        export_sdk_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True),
+                                      d.getVar("TEST_EXPORT_SDK_DIR", True))
+        bb.utils.mkdirhier(export_sdk_dir)
+        shutil.copy2(tarball_path, export_sdk_dir)
+
     bb.plain("Exported tests to: %s" % exportpath)
 
 def testexport_main(d):
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index 52c1171..1e0dc35 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -31,8 +31,8 @@ except ImportError:
 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
 
 from oeqa.oetest import ExportTestContext
+from oeqa.utils.commands import runCmd
 from oeqa.utils.sshcontrol import SSHControl
-from oeqa.utils.dump import get_host_dumper
 
 # this isn't pretty but we need a fake target object
 # for running the tests externally as we don't care
@@ -107,6 +107,8 @@ def main():
         if not os.path.isdir(d["DEPLOY_DIR"]):
             print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
 
+    extract_sdk(d)
+
     target = FakeTarget(d)
     for key in loaded["target"].keys():
         setattr(target, key, loaded["target"][key])
@@ -118,6 +120,37 @@ def main():
 
     return 0
 
+def extract_sdk(d):
+    """
+    Extract SDK if needed
+    """
+
+    export_dir = os.path.dirname(os.path.realpath(__file__))
+    tools_dir = d.getVar("TEST_EXPORT_SDK_DIR", True)
+    tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
+    tarball_path = os.path.join(export_dir, tools_dir, tarball_name)
+    extract_path = os.path.join(export_dir, "sysroot")
+    if os.path.isfile(tarball_path):
+        print ("Found SDK tarball %s. Extracting..." % tarball_path)
+        result = runCmd("%s -y -d %s" % (tarball_path, extract_path))
+        for f in os.listdir(extract_path):
+            if f.startswith("environment-setup"):
+                print("Setting up SDK environment...")
+                env_file = os.path.join(extract_path, f)
+                update_env(env_file)
+
+def update_env(env_file):
+    """
+    Source a file and update environment
+    """
+
+    cmd = ". %s; env -0" % env_file
+    result = runCmd(cmd)
+
+    for line in result.output.split("\0"):
+        (key, _, value) = line.partition("=")
+        os.environ[key] = value
+
 if __name__ == "__main__":
     try:
         ret = main()
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] testexport.bbclass: Create tarballs for easy release
  2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
                   ` (3 preceding siblings ...)
  2016-06-01 10:46 ` [PATCH 4/5] testexport.bbclass: Add support for testexport-tarball mariano.lopez
@ 2016-06-01 10:46 ` mariano.lopez
  4 siblings, 0 replies; 6+ messages in thread
From: mariano.lopez @ 2016-06-01 10:46 UTC (permalink / raw
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

This create tarballs in the testexport directory in order
to make easier to distribute the test in another systems.

There are three tarballs, one for the metadata that is not
arch dependant, another for packages needed by the DUT
(this depends of target MACHINE), and the last one for the
SDK needed by the systems that perform the tests.

[YOCTO #8481]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/classes/testexport.bbclass | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index 33acadd..d519f22 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -127,6 +127,9 @@ def exportTests(d,tc):
         for f in files:
             shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
 
+    # Create tar file for common parts of testexport
+    create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True))
+
     # Copy packages needed for runtime testing
     export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
     test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True)
@@ -141,6 +144,9 @@ def exportTests(d,tc):
             dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
             shutil.copy2(src_f, dst_f)
 
+    # Create tar file for packages needed by the DUT
+    create_tarball(d, "testexport_packages_%s.tar.gz" % d.getVar("MACHINE", True), export_pkg_dir)
+
     # Copy SDK
     if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
         sdk_deploy = d.getVar("SDK_DEPLOY", True)
@@ -151,6 +157,9 @@ def exportTests(d,tc):
         bb.utils.mkdirhier(export_sdk_dir)
         shutil.copy2(tarball_path, export_sdk_dir)
 
+    # Create tar file for the sdk
+    create_tarball(d, "testexport_sdk_%s.tar.gz" % d.getVar("SDK_ARCH", True), export_sdk_dir)
+
     bb.plain("Exported tests to: %s" % exportpath)
 
 def testexport_main(d):
@@ -182,6 +191,23 @@ def testexport_main(d):
     tc.extract_packages()
     exportTests(d,tc)
 
+def create_tarball(d, tar_name, src_dir):
+
+    import tarfile
+
+    tar_path = os.path.join(d.getVar("TEST_EXPORT_DIR", True), tar_name)
+    current_dir = os.getcwd()
+    src_dir = src_dir.rstrip('/')
+    dir_name = os.path.dirname(src_dir)
+    base_name = os.path.basename(src_dir)
+
+    os.chdir(dir_name)
+    tar = tarfile.open(tar_path, "w:gz")
+    tar.add(base_name)
+    tar.close()
+    os.chdir(current_dir)
+
+
 testexport_main[vardepsexclude] =+ "BB_ORIGENV"
 
 inherit testimage
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-01 18:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-01 10:46 [PATCH 0/5] Enable installation of packages in DUT mariano.lopez
2016-06-01 10:46 ` [PATCH 1/5] oetest.py: Add install/uninstall functionality for DUTs mariano.lopez
2016-06-01 10:46 ` [PATCH 2/5] testimage.bbclass: Make dependency of cpio when using RPMs mariano.lopez
2016-06-01 10:46 ` [PATCH 3/5] testexport-tarball.bb: Add recipe mariano.lopez
2016-06-01 10:46 ` [PATCH 4/5] testexport.bbclass: Add support for testexport-tarball mariano.lopez
2016-06-01 10:46 ` [PATCH 5/5] testexport.bbclass: Create tarballs for easy release mariano.lopez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.