Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | from oeqa.selftest.base import oeSelfTest |
| 2 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu |
| 3 | from oeqa.utils.decorators import testcase |
| 4 | from oeqa.utils.sshcontrol import SSHControl |
| 5 | import os |
| 6 | import sys |
| 7 | import logging |
| 8 | |
| 9 | class ImageFeatures(oeSelfTest): |
| 10 | |
| 11 | test_user = 'tester' |
| 12 | root_user = 'root' |
| 13 | |
| 14 | @testcase(1107) |
| 15 | def test_non_root_user_can_connect_via_ssh_without_password(self): |
| 16 | """ |
| 17 | Summary: Check if non root user can connect via ssh without password |
| 18 | Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed. |
| 19 | 2. Connection to the image via ssh using tester user without providing a password should be allowed. |
| 20 | Product: oe-core |
| 21 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> |
| 22 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
| 23 | """ |
| 24 | |
| 25 | features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' |
| 26 | features += 'INHERIT += "extrausers"\n' |
| 27 | features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 28 | self.write_config(features) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | |
| 30 | # Build a core-image-minimal |
| 31 | bitbake('core-image-minimal') |
| 32 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 33 | with runqemu("core-image-minimal") as qemu: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | # Attempt to ssh with each user into qemu with empty password |
| 35 | for user in [self.root_user, self.test_user]: |
| 36 | ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user) |
| 37 | status, output = ssh.run("true") |
| 38 | self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output)) |
| 39 | |
| 40 | @testcase(1115) |
| 41 | def test_all_users_can_connect_via_ssh_without_password(self): |
| 42 | """ |
| 43 | Summary: Check if all users can connect via ssh without password |
| 44 | Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed. |
| 45 | 2. Connection to the image via ssh using tester user without providing a password should be allowed. |
| 46 | Product: oe-core |
| 47 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> |
| 48 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
| 49 | """ |
| 50 | |
| 51 | features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' |
| 52 | features += 'INHERIT += "extrausers"\n' |
| 53 | features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 54 | self.write_config(features) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | |
| 56 | # Build a core-image-minimal |
| 57 | bitbake('core-image-minimal') |
| 58 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 59 | with runqemu("core-image-minimal") as qemu: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | # Attempt to ssh with each user into qemu with empty password |
| 61 | for user in [self.root_user, self.test_user]: |
| 62 | ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user) |
| 63 | status, output = ssh.run("true") |
| 64 | if user == 'root': |
| 65 | self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been') |
| 66 | else: |
| 67 | self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output) |
| 68 | |
| 69 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | @testcase(1116) |
| 71 | def test_clutter_image_can_be_built(self): |
| 72 | """ |
| 73 | Summary: Check if clutter image can be built |
| 74 | Expected: 1. core-image-clutter can be built |
| 75 | Product: oe-core |
| 76 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> |
| 77 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
| 78 | """ |
| 79 | |
| 80 | # Build a core-image-clutter |
| 81 | bitbake('core-image-clutter') |
| 82 | |
| 83 | @testcase(1117) |
| 84 | def test_wayland_support_in_image(self): |
| 85 | """ |
| 86 | Summary: Check Wayland support in image |
| 87 | Expected: 1. Wayland image can be build |
| 88 | 2. Wayland feature can be installed |
| 89 | Product: oe-core |
| 90 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> |
| 91 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> |
| 92 | """ |
| 93 | |
| 94 | features = 'DISTRO_FEATURES_append = " wayland"\n' |
| 95 | features += 'CORE_IMAGE_EXTRA_INSTALL += "wayland weston"' |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 96 | self.write_config(features) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | |
| 98 | # Build a core-image-weston |
| 99 | bitbake('core-image-weston') |
| 100 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 101 | def test_bmap(self): |
| 102 | """ |
| 103 | Summary: Check bmap support |
| 104 | Expected: 1. core-image-minimal can be build with bmap support |
| 105 | 2. core-image-minimal is sparse |
| 106 | Product: oe-core |
| 107 | Author: Ed Bartosh <ed.bartosh@linux.intel.com> |
| 108 | """ |
| 109 | |
| 110 | features = 'IMAGE_FSTYPES += " ext4 ext4.bmap"' |
| 111 | self.write_config(features) |
| 112 | |
| 113 | image_name = 'core-image-minimal' |
| 114 | bitbake(image_name) |
| 115 | |
| 116 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') |
| 117 | link_name = get_bb_var('IMAGE_LINK_NAME', image_name) |
| 118 | image_path = os.path.join(deploy_dir_image, "%s.ext4" % link_name) |
| 119 | bmap_path = "%s.bmap" % image_path |
| 120 | |
| 121 | # check if result image and bmap file are in deploy directory |
| 122 | self.assertTrue(os.path.exists(image_path)) |
| 123 | self.assertTrue(os.path.exists(bmap_path)) |
| 124 | |
| 125 | # check if result image is sparse |
| 126 | image_stat = os.stat(image_path) |
| 127 | self.assertTrue(image_stat.st_size > image_stat.st_blocks * 512) |