All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases.
@ 2015-06-22  9:28 Daniel Istrate
  2015-06-22  9:28 ` [PATCH 2/2] oeqa/utils: Minor documentation update to ftools methods Daniel Istrate
  2015-06-24 14:22 ` [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Burton, Ross
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Istrate @ 2015-06-22  9:28 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
---
 meta/lib/oeqa/selftest/imagefeatures.py | 206 ++++++++++++++++++++++++++++++++
 1 file changed, 206 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/imagefeatures.py

diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py
new file mode 100644
index 0000000..f697956
--- /dev/null
+++ b/meta/lib/oeqa/selftest/imagefeatures.py
@@ -0,0 +1,206 @@
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import runCmd, bitbake 
+from oeqa.utils.decorators import testcase
+import pexpect
+from os.path import expanduser
+from os import system
+
+class ImageFeatures(oeSelfTest):
+
+    @testcase(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@intel.com>
+        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
+        """
+
+        test_user = 'tester'
+        root_user = 'root'
+        prompt = r'qemux86:\S+[$#]\s+'
+        tap_inf_ip = '192.168.7.2'
+
+        features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n'
+        features += 'INHERIT += "extrausers"\n'
+        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user)
+
+        # Append 'features' to local.conf
+        self.append_config(features)
+
+        # Build a core-image-minimal
+        ret = bitbake('core-image-minimal')
+        self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
+
+        rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip)
+        # Delete the ssh keys for 192.168.7.2 (qemu)
+        ret = runCmd(rm_ssh_keys_cmd)
+        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.')
+
+        # Boot qemu image
+        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
+        try:
+            proc_qemu.expect('qemux86 login:', timeout=100)
+        except:
+            system('pkill qemu')
+            proc_qemu.close()
+            self.fail('Failed to start qemu.')
+
+        # Attempt to ssh with each user into qemu with empty password
+        for user in [root_user, test_user]:
+            proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user))
+            index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
+            if index == 0:
+                proc_ssh.sendline('yes')
+                try:
+                    proc_ssh.expect(prompt)
+                except:
+                    system('pkill qemu')
+                    proc_qemu.close()
+                    proc_ssh.terminate()
+                    self.fail('Failed to ssh with {} user into qemu.'.format(user))
+            elif index == 1:
+                # user successfully logged in with empty password
+                pass
+            elif index == 2:
+                system('pkill qemu')
+                proc_qemu.close()
+                proc_ssh.terminate()
+                self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user))
+            else:
+                system('pkill qemu')
+                proc_qemu.close()
+                proc_ssh.terminate()
+                self.fail('Failed to ssh with {} user into qemu (eof).'.format(user))
+
+        # Cleanup
+        system('pkill qemu')
+        proc_qemu.close()
+        proc_ssh.terminate()
+        ret = runCmd(rm_ssh_keys_cmd)
+        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).')
+
+    @testcase(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 or tester user without providing a password should be allowed.
+        Product:     oe-core
+        Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com>
+        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
+        """
+        test_user = 'tester'
+        root_user = 'root'
+        prompt = r'qemux86:\S+[$#]\s+'
+        tap_inf_ip = '192.168.7.2'
+
+        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(test_user, test_user)
+
+        # Append 'features' to local.conf
+        self.append_config(features)
+
+        # Build a core-image-minimal
+        ret = bitbake('core-image-minimal')
+        self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
+
+        rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip)
+        # Delete the ssh keys for 192.168.7.2 (qemu)
+        ret = runCmd(rm_ssh_keys_cmd)
+        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.')
+
+        # Boot qemu image
+        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
+        try:
+            proc_qemu.expect('qemux86 login:', timeout=100)
+        except:
+            system('pkill qemu')
+            proc_qemu.close()
+            self.fail('Failed to start qemu.')
+
+        # Attempt to ssh with each user into qemu with empty password
+        for user in [root_user, test_user]:
+            proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user))
+            index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
+            if index == 0:
+                proc_ssh.sendline('yes')
+                try:
+                    proc_ssh.expect(prompt)
+                except:
+                    system('pkill qemu')
+                    proc_qemu.close()
+                    proc_ssh.terminate()
+                    self.fail('Failed to ssh with {} user into qemu.'.format(user))
+            elif index == 1:
+                # user successfully logged in with empty password
+                pass
+            elif index == 2:
+                system('pkill qemu')
+                proc_qemu.close()
+                proc_ssh.terminate()
+                self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user))
+            else:
+                system('pkill qemu')
+                proc_qemu.close()
+                proc_ssh.terminate()
+                self.fail('Failed to ssh with {} user into qemu (eof).'.format(user))
+
+        # Cleanup
+        system('pkill qemu')
+        proc_qemu.close()
+        proc_ssh.terminate()
+        ret = runCmd(rm_ssh_keys_cmd)
+        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).')
+
+    @testcase(1114)
+    def test_rpm_version_4_support_on_image(self):
+        """
+        Summary:     Check rpm version 4 support on image
+        Expected:    Rpm version must be 4.11.2
+        Product:     oe-core
+        Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com>
+        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
+        """
+
+        root_user = 'root'
+        prompt = '{}@qemux86:~# '.format(root_user)
+        rpm_version = '4.11.2'
+        features = 'IMAGE_INSTALL_append = " rpm"\n'
+        features += 'PREFERRED_VERSION_rpm = "{}"\n'.format(rpm_version)
+        features += 'PREFERRED_VERSION_rpm-native = "{}"\n'.format(rpm_version)
+        features += 'RPMROOTFSDEPENDS_remove = "rpmresolve-native:do_populate_sysroot"'
+
+        # Append 'features' to local.conf
+        self.append_config(features)
+
+        # Build a core-image-minimal
+        ret = bitbake('core-image-minimal')
+        self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
+
+        # Boot qemu image & get rpm version
+        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
+        try:
+            proc_qemu.expect('qemux86 login:', timeout=100)
+            proc_qemu.sendline(root_user)
+            proc_qemu.expect(prompt)
+            proc_qemu.sendline('rpm --version')
+            proc_qemu.expect(prompt)
+        except:
+            system('pkill qemu')
+            proc_qemu.close()
+            self.fail('Failed to boot qemu.')
+
+        found_rpm_version = proc_qemu.before
+
+        # Make sure the retrieved rpm version is the expected one
+        if rpm_version not in found_rpm_version:
+            system('pkill qemu')
+            proc_qemu.close()
+            self.fail('RPM version is not {}, found instead {}.'.format(rpm_version, found_rpm_version))
+
+        # Cleanup (close qemu)
+        system('pkill qemu')
+        proc_qemu.close()
\ No newline at end of file
-- 
2.1.4



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

* [PATCH 2/2] oeqa/utils: Minor documentation update to ftools methods.
  2015-06-22  9:28 [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Daniel Istrate
@ 2015-06-22  9:28 ` Daniel Istrate
  2015-06-24 14:22 ` [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Burton, Ross
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Istrate @ 2015-06-22  9:28 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
---
 meta/lib/oeqa/utils/ftools.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
index 64ebe3d..e396591 100644
--- a/meta/lib/oeqa/utils/ftools.py
+++ b/meta/lib/oeqa/utils/ftools.py
@@ -1,22 +1,26 @@
 import os
 import re
 
+# Replaces file (path) content with 'data'
 def write_file(path, data):
     wdata = data.rstrip() + "\n"
     with open(path, "w") as f:
         f.write(wdata)
 
+# Append 'data' to a specified file (path)
 def append_file(path, data):
     wdata = data.rstrip() + "\n"
     with open(path, "a") as f:
             f.write(wdata)
 
+# Returns the content of the specified file (path)
 def read_file(path):
     data = None
     with open(path) as f:
         data = f.read()
     return data
 
+# Removes 'data' from a specified file (path)
 def remove_from_file(path, data):
     lines = read_file(path).splitlines()
     rmdata = data.strip().splitlines()
-- 
2.1.4



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

* Re: [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases.
  2015-06-22  9:28 [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Daniel Istrate
  2015-06-22  9:28 ` [PATCH 2/2] oeqa/utils: Minor documentation update to ftools methods Daniel Istrate
@ 2015-06-24 14:22 ` Burton, Ross
  1 sibling, 0 replies; 3+ messages in thread
From: Burton, Ross @ 2015-06-24 14:22 UTC (permalink / raw)
  To: Daniel Istrate; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 10490 bytes --]

Instead of expecting a future developer to read the patch to see what
happened, please explain what the new test cases are in the commit log.

Ross

On 22 June 2015 at 10:28, Daniel Istrate <
daniel.alexandrux.istrate@intel.com> wrote:

> Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
> ---
>  meta/lib/oeqa/selftest/imagefeatures.py | 206
> ++++++++++++++++++++++++++++++++
>  1 file changed, 206 insertions(+)
>  create mode 100644 meta/lib/oeqa/selftest/imagefeatures.py
>
> diff --git a/meta/lib/oeqa/selftest/imagefeatures.py
> b/meta/lib/oeqa/selftest/imagefeatures.py
> new file mode 100644
> index 0000000..f697956
> --- /dev/null
> +++ b/meta/lib/oeqa/selftest/imagefeatures.py
> @@ -0,0 +1,206 @@
> +from oeqa.selftest.base import oeSelfTest
> +from oeqa.utils.commands import runCmd, bitbake
> +from oeqa.utils.decorators import testcase
> +import pexpect
> +from os.path import expanduser
> +from os import system
> +
> +class ImageFeatures(oeSelfTest):
> +
> +    @testcase(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@intel.com>
> +        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
> +        """
> +
> +        test_user = 'tester'
> +        root_user = 'root'
> +        prompt = r'qemux86:\S+[$#]\s+'
> +        tap_inf_ip = '192.168.7.2'
> +
> +        features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh
> empty-root-password"\n'
> +        features += 'INHERIT += "extrausers"\n'
> +        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s
> /bin/sh {};"'.format(test_user, test_user)
> +
> +        # Append 'features' to local.conf
> +        self.append_config(features)
> +
> +        # Build a core-image-minimal
> +        ret = bitbake('core-image-minimal')
> +        self.assertEqual(0, ret.status, 'Failed to build a
> core-image-minimal')
> +
> +        rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R
> {}'.format(expanduser('~'), tap_inf_ip)
> +        # Delete the ssh keys for 192.168.7.2 (qemu)
> +        ret = runCmd(rm_ssh_keys_cmd)
> +        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for
> qemu host.')
> +
> +        # Boot qemu image
> +        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
> +        try:
> +            proc_qemu.expect('qemux86 login:', timeout=100)
> +        except:
> +            system('pkill qemu')
> +            proc_qemu.close()
> +            self.fail('Failed to start qemu.')
> +
> +        # Attempt to ssh with each user into qemu with empty password
> +        for user in [root_user, test_user]:
> +            proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip,
> user))
> +            index = proc_ssh.expect(['Are you sure you want to continue
> connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
> +            if index == 0:
> +                proc_ssh.sendline('yes')
> +                try:
> +                    proc_ssh.expect(prompt)
> +                except:
> +                    system('pkill qemu')
> +                    proc_qemu.close()
> +                    proc_ssh.terminate()
> +                    self.fail('Failed to ssh with {} user into
> qemu.'.format(user))
> +            elif index == 1:
> +                # user successfully logged in with empty password
> +                pass
> +            elif index == 2:
> +                system('pkill qemu')
> +                proc_qemu.close()
> +                proc_ssh.terminate()
> +                self.fail('Failed to ssh with {} user into qemu
> (timeout).'.format(user))
> +            else:
> +                system('pkill qemu')
> +                proc_qemu.close()
> +                proc_ssh.terminate()
> +                self.fail('Failed to ssh with {} user into qemu
> (eof).'.format(user))
> +
> +        # Cleanup
> +        system('pkill qemu')
> +        proc_qemu.close()
> +        proc_ssh.terminate()
> +        ret = runCmd(rm_ssh_keys_cmd)
> +        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for
> qemu host (at cleanup).')
> +
> +    @testcase(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 or
> tester user without providing a password should be allowed.
> +        Product:     oe-core
> +        Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com>
> +        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
> +        """
> +        test_user = 'tester'
> +        root_user = 'root'
> +        prompt = r'qemux86:\S+[$#]\s+'
> +        tap_inf_ip = '192.168.7.2'
> +
> +        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(test_user, test_user)
> +
> +        # Append 'features' to local.conf
> +        self.append_config(features)
> +
> +        # Build a core-image-minimal
> +        ret = bitbake('core-image-minimal')
> +        self.assertEqual(0, ret.status, 'Failed to build a
> core-image-minimal')
> +
> +        rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R
> {}'.format(expanduser('~'), tap_inf_ip)
> +        # Delete the ssh keys for 192.168.7.2 (qemu)
> +        ret = runCmd(rm_ssh_keys_cmd)
> +        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for
> qemu host.')
> +
> +        # Boot qemu image
> +        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
> +        try:
> +            proc_qemu.expect('qemux86 login:', timeout=100)
> +        except:
> +            system('pkill qemu')
> +            proc_qemu.close()
> +            self.fail('Failed to start qemu.')
> +
> +        # Attempt to ssh with each user into qemu with empty password
> +        for user in [root_user, test_user]:
> +            proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip,
> user))
> +            index = proc_ssh.expect(['Are you sure you want to continue
> connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
> +            if index == 0:
> +                proc_ssh.sendline('yes')
> +                try:
> +                    proc_ssh.expect(prompt)
> +                except:
> +                    system('pkill qemu')
> +                    proc_qemu.close()
> +                    proc_ssh.terminate()
> +                    self.fail('Failed to ssh with {} user into
> qemu.'.format(user))
> +            elif index == 1:
> +                # user successfully logged in with empty password
> +                pass
> +            elif index == 2:
> +                system('pkill qemu')
> +                proc_qemu.close()
> +                proc_ssh.terminate()
> +                self.fail('Failed to ssh with {} user into qemu
> (timeout).'.format(user))
> +            else:
> +                system('pkill qemu')
> +                proc_qemu.close()
> +                proc_ssh.terminate()
> +                self.fail('Failed to ssh with {} user into qemu
> (eof).'.format(user))
> +
> +        # Cleanup
> +        system('pkill qemu')
> +        proc_qemu.close()
> +        proc_ssh.terminate()
> +        ret = runCmd(rm_ssh_keys_cmd)
> +        self.assertEqual(0, ret.status, 'Failed to delete ssh keys for
> qemu host (at cleanup).')
> +
> +    @testcase(1114)
> +    def test_rpm_version_4_support_on_image(self):
> +        """
> +        Summary:     Check rpm version 4 support on image
> +        Expected:    Rpm version must be 4.11.2
> +        Product:     oe-core
> +        Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com>
> +        AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
> +        """
> +
> +        root_user = 'root'
> +        prompt = '{}@qemux86:~# '.format(root_user)
> +        rpm_version = '4.11.2'
> +        features = 'IMAGE_INSTALL_append = " rpm"\n'
> +        features += 'PREFERRED_VERSION_rpm = "{}"\n'.format(rpm_version)
> +        features += 'PREFERRED_VERSION_rpm-native =
> "{}"\n'.format(rpm_version)
> +        features += 'RPMROOTFSDEPENDS_remove =
> "rpmresolve-native:do_populate_sysroot"'
> +
> +        # Append 'features' to local.conf
> +        self.append_config(features)
> +
> +        # Build a core-image-minimal
> +        ret = bitbake('core-image-minimal')
> +        self.assertEqual(0, ret.status, 'Failed to build a
> core-image-minimal')
> +
> +        # Boot qemu image & get rpm version
> +        proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
> +        try:
> +            proc_qemu.expect('qemux86 login:', timeout=100)
> +            proc_qemu.sendline(root_user)
> +            proc_qemu.expect(prompt)
> +            proc_qemu.sendline('rpm --version')
> +            proc_qemu.expect(prompt)
> +        except:
> +            system('pkill qemu')
> +            proc_qemu.close()
> +            self.fail('Failed to boot qemu.')
> +
> +        found_rpm_version = proc_qemu.before
> +
> +        # Make sure the retrieved rpm version is the expected one
> +        if rpm_version not in found_rpm_version:
> +            system('pkill qemu')
> +            proc_qemu.close()
> +            self.fail('RPM version is not {}, found instead
> {}.'.format(rpm_version, found_rpm_version))
> +
> +        # Cleanup (close qemu)
> +        system('pkill qemu')
> +        proc_qemu.close()
> \ No newline at end of file
> --
> 2.1.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[-- Attachment #2: Type: text/html, Size: 13578 bytes --]

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

end of thread, other threads:[~2015-06-24 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22  9:28 [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Daniel Istrate
2015-06-22  9:28 ` [PATCH 2/2] oeqa/utils: Minor documentation update to ftools methods Daniel Istrate
2015-06-24 14:22 ` [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases Burton, Ross

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.