[oe-commits] [openembedded-core] 18/28: oeqa/selftest/cases: imagefeatures enable threaded runs

git at git.openembedded.org git at git.openembedded.org
Thu Jul 20 09:44:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 4dce9cc54957d31852815875beccfe0d49ba02e7
Author: Aníbal Limón <anibal.limon at linux.intel.com>
AuthorDate: Tue Jun 13 15:20:10 2017 -0500

    oeqa/selftest/cases: imagefeatures enable threaded runs
    
    - Change to use wrapper methos from OESelfTestCase.
    - Move tests that use runqemu to its own module because
      it needs tinfoil and run in the main thread.
    
    Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 meta/lib/oeqa/selftest/cases/imagefeatures.py      | 86 ++++------------------
 meta/lib/oeqa/selftest/cases/imagefeatures_boot.py | 63 ++++++++++++++++
 2 files changed, 77 insertions(+), 72 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py
index 91d8e9b..31622b1 100644
--- a/meta/lib/oeqa/selftest/cases/imagefeatures.py
+++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py
@@ -1,69 +1,11 @@
+import os
+
 from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
 from oeqa.core.decorator.oeid import OETestID
-from oeqa.utils.sshcontrol import SSHControl
-import os
 
 class ImageFeatures(OESelftestTestCase):
-
-    test_user = 'tester'
-    root_user = 'root'
-
-    @OETestID(1107)
-    def test_non_root_user_can_connect_via_ssh_without_password(self):
-        """
-        Summary: Check if non root user can connect via ssh without password
-        Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
-                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
-        Product: oe-core
-        Author: Ionut Chisanovici <ionutx.chisanovici at intel.com>
-        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at intel.com>
-        """
-
-        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
-        features += 'INHERIT += "extrausers"\n'
-        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
-        self.write_config(features)
-
-        # Build a core-image-minimal
-        bitbake('core-image-minimal')
-
-        with runqemu("core-image-minimal") as qemu:
-            # Attempt to ssh with each user into qemu with empty password
-            for user in [self.root_user, self.test_user]:
-                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
-                status, output = ssh.run("true")
-                self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output))
-
-    @OETestID(1115)
-    def test_all_users_can_connect_via_ssh_without_password(self):
-        """
-        Summary:     Check if all users can connect via ssh without password
-        Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed.
-                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
-        Product:     oe-core
-        Author:      Ionut Chisanovici <ionutx.chisanovici at intel.com>
-        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at intel.com>
-        """
-
-        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n'
-        features += 'INHERIT += "extrausers"\n'
-        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
-        self.write_config(features)
-
-        # Build a core-image-minimal
-        bitbake('core-image-minimal')
-
-        with runqemu("core-image-minimal") as qemu:
-            # Attempt to ssh with each user into qemu with empty password
-            for user in [self.root_user, self.test_user]:
-                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
-                status, output = ssh.run("true")
-                if user == 'root':
-                    self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been')
-                else:
-                    self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)
-
+    _use_own_builddir = True
+    _main_thread = False
 
     @OETestID(1116)
     def test_clutter_image_can_be_built(self):
@@ -76,7 +18,7 @@ class ImageFeatures(OESelftestTestCase):
         """
 
         # Build a core-image-clutter
-        bitbake('core-image-clutter')
+        self.bitbake('core-image-clutter')
 
     @OETestID(1117)
     def test_wayland_support_in_image(self):
@@ -89,12 +31,12 @@ class ImageFeatures(OESelftestTestCase):
         AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at intel.com>
         """
 
-        distro_features = get_bb_var('DISTRO_FEATURES')
+        distro_features = self.get_bb_var('DISTRO_FEATURES')
         if not ('opengl' in distro_features and 'wayland' in distro_features):
             self.skipTest('neither opengl nor wayland present on DISTRO_FEATURES so core-image-weston cannot be built')
 
         # Build a core-image-weston
-        bitbake('core-image-weston')
+        self.bitbake('core-image-weston')
 
     @OETestID(1497)
     def test_bmap(self):
@@ -110,10 +52,10 @@ class ImageFeatures(OESelftestTestCase):
         self.write_config(features)
 
         image_name = 'core-image-minimal'
-        bitbake(image_name)
+        self.bitbake(image_name)
 
-        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
-        link_name = get_bb_var('IMAGE_LINK_NAME', image_name)
+        deploy_dir_image = self.get_bb_var('DEPLOY_DIR_IMAGE')
+        link_name = self.get_bb_var('IMAGE_LINK_NAME', image_name)
         image_path = os.path.join(deploy_dir_image, "%s.ext4" % link_name)
         bmap_path = "%s.bmap" % image_path
 
@@ -134,7 +76,7 @@ class ImageFeatures(OESelftestTestCase):
         """
         image_name = 'core-image-minimal'
 
-        img_types = [itype for itype in get_bb_var("IMAGE_TYPES", image_name).split() \
+        img_types = [itype for itype in self.get_bb_var("IMAGE_TYPES", image_name).split() \
                          if itype not in ('container', 'elf', 'multiubi')]
 
         config = 'IMAGE_FSTYPES += "%s"\n'\
@@ -143,10 +85,10 @@ class ImageFeatures(OESelftestTestCase):
 
         self.write_config(config)
 
-        bitbake(image_name)
+        self.bitbake(image_name)
 
-        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
-        link_name = get_bb_var('IMAGE_LINK_NAME', image_name)
+        deploy_dir_image = self.get_bb_var('DEPLOY_DIR_IMAGE')
+        link_name = self.get_bb_var('IMAGE_LINK_NAME', image_name)
         for itype in img_types:
             image_path = os.path.join(deploy_dir_image, "%s.%s" % (link_name, itype))
             # check if result image is in deploy directory
diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures_boot.py b/meta/lib/oeqa/selftest/cases/imagefeatures_boot.py
new file mode 100644
index 0000000..2cdf4ad
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/imagefeatures_boot.py
@@ -0,0 +1,63 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.core.decorator.oeid import OETestID
+from oeqa.utils.commands import runqemu
+from oeqa.utils.sshcontrol import SSHControl
+
+class ImageFeaturesBoot(OESelftestTestCase):
+    test_user = 'tester'
+    root_user = 'root'
+
+    @OETestID(1107)
+    def test_non_root_user_can_connect_via_ssh_without_password(self):
+        """
+        Summary: Check if non root user can connect via ssh without password
+        Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
+                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
+        Product: oe-core
+        Author: Ionut Chisanovici <ionutx.chisanovici at intel.com>
+        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at intel.com>
+        """
+
+        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
+        features += 'INHERIT += "extrausers"\n'
+        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
+        self.write_config(features)
+
+        # Build a core-image-minimal
+        self.bitbake('core-image-minimal')
+
+        with runqemu("core-image-minimal") as qemu:
+            # Attempt to ssh with each user into qemu with empty password
+            for user in [self.root_user, self.test_user]:
+                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
+                status, output = ssh.run("true")
+                self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output))
+
+    @OETestID(1115)
+    def test_all_users_can_connect_via_ssh_without_password(self):
+        """
+        Summary:     Check if all users can connect via ssh without password
+        Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed.
+                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
+        Product:     oe-core
+        Author:      Ionut Chisanovici <ionutx.chisanovici at intel.com>
+        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at intel.com>
+        """
+
+        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n'
+        features += 'INHERIT += "extrausers"\n'
+        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
+        self.write_config(features)
+
+        # Build a core-image-minimal
+        self.bitbake('core-image-minimal')
+
+        with runqemu("core-image-minimal") as qemu:
+            # Attempt to ssh with each user into qemu with empty password
+            for user in [self.root_user, self.test_user]:
+                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
+                status, output = ssh.run("true")
+                if user == 'root':
+                    self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been')
+                else:
+                    self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list