Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] Add selftest to test testexport's SDK feature
@ 2016-07-07 14:48 mariano.lopez
  2016-07-07 14:48 ` [PATCH 1/2] lib/oeqa/utils/commands.py: Move updateEnv() from runexported.py mariano.lopez
  2016-07-07 14:48 ` [PATCH 2/2] selftest/runtime-test.py: Add test for testexport SDK feature mariano.lopez
  0 siblings, 2 replies; 3+ messages in thread
From: mariano.lopez @ 2016-07-07 14:48 UTC (permalink / raw)
  To: openembedded-core

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

This adds a new selftest for testexport in the CI to avoid
breaking SDK functionality.

This depends on:

http://lists.openembedded.org/pipermail/openembedded-core/2016-June/122785.html

The following changes since commit 242d70bf0af2eb56ed6da83d4ec7dce2172ebe70:

  selftest/runtime-test.py: Add test for import test from other layers (2016-07-06 11:37:49 +0000)

are available in the git repository at:

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

Mariano Lopez (2):
  lib/oeqa/utils/commands.py: Move updateEnv() from runexported.py
  selftest/runtime-test.py: Add test for testexport SDK feature

 meta/lib/oeqa/runexported.py           | 16 ++-------
 meta/lib/oeqa/selftest/runtime-test.py | 60 +++++++++++++++++++++++++++++++++-
 meta/lib/oeqa/utils/commands.py        | 31 ++++++++++++++++++
 3 files changed, 92 insertions(+), 15 deletions(-)

-- 
2.6.6



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

* [PATCH 1/2] lib/oeqa/utils/commands.py: Move updateEnv() from runexported.py
  2016-07-07 14:48 [PATCH 0/2] Add selftest to test testexport's SDK feature mariano.lopez
@ 2016-07-07 14:48 ` mariano.lopez
  2016-07-07 14:48 ` [PATCH 2/2] selftest/runtime-test.py: Add test for testexport SDK feature mariano.lopez
  1 sibling, 0 replies; 3+ messages in thread
From: mariano.lopez @ 2016-07-07 14:48 UTC (permalink / raw)
  To: openembedded-core

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

updateEnv() can be used in other places so move the
function to utils/commands.py

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/lib/oeqa/runexported.py    | 16 ++--------------
 meta/lib/oeqa/utils/commands.py | 12 ++++++++++++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index 5886739..125e86d 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -31,7 +31,7 @@ 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.commands import runCmd, updateEnv
 from oeqa.utils.sshcontrol import SSHControl
 
 # this isn't pretty but we need a fake target object
@@ -137,19 +137,7 @@ def extract_sdk(d):
             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
+                updateEnv(env_file)
 
 if __name__ == "__main__":
     try:
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 418643a..4f79d15 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -261,3 +261,15 @@ def runqemu(pn, ssh=True):
             qemu.stop()
         except:
             pass
+
+def updateEnv(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
-- 
2.6.6



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

* [PATCH 2/2] selftest/runtime-test.py: Add test for testexport SDK feature
  2016-07-07 14:48 [PATCH 0/2] Add selftest to test testexport's SDK feature mariano.lopez
  2016-07-07 14:48 ` [PATCH 1/2] lib/oeqa/utils/commands.py: Move updateEnv() from runexported.py mariano.lopez
@ 2016-07-07 14:48 ` mariano.lopez
  1 sibling, 0 replies; 3+ messages in thread
From: mariano.lopez @ 2016-07-07 14:48 UTC (permalink / raw)
  To: openembedded-core

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

This adds test_testexport_sdk() to test the SDK feature
of testexport in the CI in order to avoid breaking it.

[YOCTO #9765]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/lib/oeqa/selftest/runtime-test.py | 60 +++++++++++++++++++++++++++++++++-
 meta/lib/oeqa/utils/commands.py        | 19 +++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py
index 1e1d3b0..d2f9334 100644
--- a/meta/lib/oeqa/selftest/runtime-test.py
+++ b/meta/lib/oeqa/selftest/runtime-test.py
@@ -1,5 +1,5 @@
 from oeqa.selftest.base import oeSelfTest
-from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu, updateEnv, restoreEnv
 from oeqa.utils.decorators import testcase
 import os
 
@@ -43,6 +43,64 @@ class TestExport(oeSelfTest):
             failure = True if 'FAIL' in result.output else False
             self.assertNotEqual(True, failure, 'ping test failed')
 
+    def test_testexport_sdk(self):
+        """
+        Summary: Check sdk functionality for testexport.
+        Expected: 1. testexport directory must be created.
+                  2. SDK tarball must exists.
+                  3. Uncompressing of tarball must succeed.
+                  4. Check if the SDK directory is added to PATH.
+                  5. Run tar from the SDK directory.
+        Product: oe-core
+        Author: Mariano Lopez <mariano.lopez@intel.com>
+        """
+
+        features = 'INHERIT += "testexport"\n'
+        # These aren't the actual IP addresses but testexport class needs something defined
+        features += 'TEST_SERVER_IP = "192.168.7.1"\n'
+        features += 'TEST_TARGET_IP = "192.168.7.1"\n'
+        features += 'TEST_SUITES = "ping"\n'
+        features += 'TEST_EXPORT_SDK_ENABLED = "1"\n'
+        features += 'TEST_EXPORT_SDK_PACKAGES = "nativesdk-tar"\n'
+        self.write_config(features)
+
+        # Build tesexport for core-image-minimal
+        bitbake('core-image-minimal')
+        bitbake('-c testexport core-image-minimal')
+
+        # Check for SDK
+        testexport_dir = get_bb_var('TEST_EXPORT_DIR', 'core-image-minimal')
+        sdk_dir = get_bb_var('TEST_EXPORT_SDK_DIR', 'core-image-minimal')
+        tarball_name = "%s.sh" % get_bb_var('TEST_EXPORT_SDK_NAME', 'core-image-minimal')
+        tarball_path = os.path.join(testexport_dir, sdk_dir, tarball_name)
+        self.assertEqual(os.path.isfile(tarball_path), True, "Couldn't find SDK tarball: %s" % tarball_path)
+
+        # Uncompress SDK
+        extract_path = os.path.join(testexport_dir, "sysroot")
+        result = runCmd("%s -y -d %s" % (tarball_path, extract_path))
+
+        # Setting up environment
+        current_env = dict(os.environ)
+        for f in os.listdir(extract_path):
+            if f.startswith("environment-setup"):
+                env_file = os.path.join(extract_path, f)
+                updateEnv(env_file)
+
+        # Check if the SDK directory was added to PATH
+        working_path = False
+        for path in os.environ['PATH'].split(":"):
+            if testexport_dir in path:
+                working_path = True
+                sdk_path = path
+                break
+
+        self.assertEqual(working_path, True, "Couldn't find SDK path in PATH")
+
+        # Execute tar from SDK path
+        cmd_tar = os.path.join(sdk_path, "tar")
+        result = runCmd("%s --version" % cmd_tar)
+
+        restoreEnv(current_env)
 
 class TestImage(oeSelfTest):
 
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 4f79d15..4cfa2e1 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -273,3 +273,22 @@ def updateEnv(env_file):
     for line in result.output.split("\0"):
         (key, _, value) = line.partition("=")
         os.environ[key] = value
+
+def restoreEnv(old_env):
+    """
+    Restore environment with os.environ.
+
+    os.environ.clear() will throw an exception if there is
+    environment variable without any value, this function
+    will deal with such cases.
+    """
+
+    keys = list(os.environ.keys())
+
+    for var in keys:
+        if var:
+            if not os.environ[var]:
+                os.environ[var] = "tmp"
+            del os.environ[var]
+
+    os.environ.update(old_env)
-- 
2.6.6



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

end of thread, other threads:[~2016-07-07 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-07 14:48 [PATCH 0/2] Add selftest to test testexport's SDK feature mariano.lopez
2016-07-07 14:48 ` [PATCH 1/2] lib/oeqa/utils/commands.py: Move updateEnv() from runexported.py mariano.lopez
2016-07-07 14:48 ` [PATCH 2/2] selftest/runtime-test.py: Add test for testexport SDK feature mariano.lopez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox