blob: 76896c798168add39313018e94446c39a296c62a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001from oeqa.selftest.base import oeSelfTest
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
3from oeqa.utils.decorators import testcase
4from oeqa.utils.sshcontrol import SSHControl
5import os
6import sys
7import logging
8
9class 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 Williamsf1e5d692016-03-30 15:21:19 -050028 self.write_config(features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
30 # Build a core-image-minimal
31 bitbake('core-image-minimal')
32
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 with runqemu("core-image-minimal") as qemu:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 # 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 Williamsf1e5d692016-03-30 15:21:19 -050054 self.write_config(features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055
56 # Build a core-image-minimal
57 bitbake('core-image-minimal')
58
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059 with runqemu("core-image-minimal") as qemu:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 # 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 Williamsc124f4f2015-09-15 14:41:29 -050070 @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
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094 distro_features = get_bb_var('DISTRO_FEATURES')
95 if not ('opengl' in distro_features and 'wayland' in distro_features):
96 self.skipTest('neither opengl nor wayland present on DISTRO_FEATURES so core-image-weston cannot be built')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097
98 # Build a core-image-weston
99 bitbake('core-image-weston')
100
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600101 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)