[OE-core] [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases.
Burton, Ross
ross.burton at intel.com
Wed Jun 24 14:22:30 UTC 2015
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 at intel.com> wrote:
> Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate at 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 at intel.com>
> + AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at 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 at intel.com>
> + AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at 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 at intel.com>
> + AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate at 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 at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20150624/34ae8b58/attachment-0002.html>
More information about the Openembedded-core
mailing list