summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorDaniel Istrate <daniel.alexandrux.istrate@intel.com>2015-06-29 12:04:59 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-08 00:01:19 +0100
commit923fb2e558de5a5b176224bcff65b826cfa97dd9 (patch)
tree8d033a8a7e1a5e869fa2d69e1f60a4c6d8aece6b /meta
parent75fa966d7c1ceaf0d40889addb4ab3cc2d05c47a (diff)
downloadpoky-923fb2e558de5a5b176224bcff65b826cfa97dd9.tar.gz
oeqa/selftest: Added new testsuite for image features.
Automated 5 oe-selftest testcase: - 1107: Check if non root user can connect via ssh without password - 1115: Check if all users can connect via ssh without password - 1114: Check rpm version 4 support on image - 1101: Check if efi/gummiboot images can be buit - 1103: Check that wic command can create efi/gummiboot installation images (From OE-Core rev: ea414da3ecc59a48a0f2fb719fc86538b47fafb8) Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/imagefeatures.py282
1 files changed, 282 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py
new file mode 100644
index 0000000000..e49f4986a0
--- /dev/null
+++ b/meta/lib/oeqa/selftest/imagefeatures.py
@@ -0,0 +1,282 @@
1from oeqa.selftest.base import oeSelfTest
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var
3from oeqa.utils.decorators import testcase
4import pexpect
5from os.path import expanduser, isfile
6from os import system
7import glob
8
9
10class ImageFeatures(oeSelfTest):
11
12 @testcase(1107)
13 def test_non_root_user_can_connect_via_ssh_without_password(self):
14 """
15 Summary: Check if non root user can connect via ssh without password
16 Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
17 2. Connection to the image via ssh using tester user without providing a password should be allowed.
18 Product: oe-core
19 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
20 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
21 """
22
23 test_user = 'tester'
24 root_user = 'root'
25 prompt = r'qemux86:\S+[$#]\s+'
26 tap_inf_ip = '192.168.7.2'
27
28 features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n'
29 features += 'INHERIT += "extrausers"\n'
30 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user)
31
32 # Append 'features' to local.conf
33 self.append_config(features)
34
35 # Build a core-image-minimal
36 ret = bitbake('core-image-minimal')
37 self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
38
39 rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip)
40 # Delete the ssh keys for 192.168.7.2 (qemu)
41 ret = runCmd(rm_ssh_keys_cmd)
42 self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.')
43
44 # Boot qemu image
45 proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
46 try:
47 proc_qemu.expect('qemux86 login:', timeout=100)
48 except:
49 system('pkill qemu')
50 proc_qemu.close()
51 self.fail('Failed to start qemu.')
52
53 # Attempt to ssh with each user into qemu with empty password
54 for user in [root_user, test_user]:
55 proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user))
56 index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
57 if index == 0:
58 proc_ssh.sendline('yes')
59 try:
60 proc_ssh.expect(prompt)
61 except:
62 system('pkill qemu')
63 proc_qemu.close()
64 proc_ssh.terminate()
65 self.fail('Failed to ssh with {} user into qemu.'.format(user))
66 elif index == 1:
67 # user successfully logged in with empty password
68 pass
69 elif index == 2:
70 system('pkill qemu')
71 proc_qemu.close()
72 proc_ssh.terminate()
73 self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user))
74 else:
75 system('pkill qemu')
76 proc_qemu.close()
77 proc_ssh.terminate()
78 self.fail('Failed to ssh with {} user into qemu (eof).'.format(user))
79
80 # Cleanup
81 system('pkill qemu')
82 proc_qemu.close()
83 proc_ssh.terminate()
84 ret = runCmd(rm_ssh_keys_cmd)
85 self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).')
86
87 @testcase(1115)
88 def test_all_users_can_connect_via_ssh_without_password(self):
89 """
90 Summary: Check if all users can connect via ssh without password
91 Expected: 1. Connection to the image via ssh using root or tester user without providing a password should be allowed.
92 Product: oe-core
93 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
94 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
95 """
96 test_user = 'tester'
97 root_user = 'root'
98 prompt = r'qemux86:\S+[$#]\s+'
99 tap_inf_ip = '192.168.7.2'
100
101 features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh allow-empty-password"\n'
102 features += 'INHERIT += "extrausers"\n'
103 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user)
104
105 # Append 'features' to local.conf
106 self.append_config(features)
107
108 # Build a core-image-minimal
109 ret = bitbake('core-image-minimal')
110 self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
111
112 rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip)
113 # Delete the ssh keys for 192.168.7.2 (qemu)
114 ret = runCmd(rm_ssh_keys_cmd)
115 self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.')
116
117 # Boot qemu image
118 proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
119 try:
120 proc_qemu.expect('qemux86 login:', timeout=100)
121 except:
122 system('pkill qemu')
123 proc_qemu.close()
124 self.fail('Failed to start qemu.')
125
126 # Attempt to ssh with each user into qemu with empty password
127 for user in [root_user, test_user]:
128 proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user))
129 index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF])
130 if index == 0:
131 proc_ssh.sendline('yes')
132 try:
133 proc_ssh.expect(prompt)
134 except:
135 system('pkill qemu')
136 proc_qemu.close()
137 proc_ssh.terminate()
138 self.fail('Failed to ssh with {} user into qemu.'.format(user))
139 elif index == 1:
140 # user successfully logged in with empty password
141 pass
142 elif index == 2:
143 system('pkill qemu')
144 proc_qemu.close()
145 proc_ssh.terminate()
146 self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user))
147 else:
148 system('pkill qemu')
149 proc_qemu.close()
150 proc_ssh.terminate()
151 self.fail('Failed to ssh with {} user into qemu (eof).'.format(user))
152
153 # Cleanup
154 system('pkill qemu')
155 proc_qemu.close()
156 proc_ssh.terminate()
157 ret = runCmd(rm_ssh_keys_cmd)
158 self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).')
159
160 @testcase(1114)
161 def test_rpm_version_4_support_on_image(self):
162 """
163 Summary: Check rpm version 4 support on image
164 Expected: Rpm version must be 4.11.2
165 Product: oe-core
166 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
167 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
168 """
169
170 root_user = 'root'
171 prompt = '{}@qemux86:~# '.format(root_user)
172 rpm_version = '4.11.2'
173 features = 'IMAGE_INSTALL_append = " rpm"\n'
174 features += 'PREFERRED_VERSION_rpm = "{}"\n'.format(rpm_version)
175 features += 'PREFERRED_VERSION_rpm-native = "{}"\n'.format(rpm_version)
176 features += 'RPMROOTFSDEPENDS_remove = "rpmresolve-native:do_populate_sysroot"'
177
178 # Append 'features' to local.conf
179 self.append_config(features)
180
181 # Build a core-image-minimal
182 ret = bitbake('core-image-minimal')
183 self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
184
185 # Boot qemu image & get rpm version
186 proc_qemu = pexpect.spawn('runqemu qemux86 nographic')
187 try:
188 proc_qemu.expect('qemux86 login:', timeout=100)
189 proc_qemu.sendline(root_user)
190 proc_qemu.expect(prompt)
191 proc_qemu.sendline('rpm --version')
192 proc_qemu.expect(prompt)
193 except:
194 system('pkill qemu')
195 proc_qemu.close()
196 self.fail('Failed to boot qemu.')
197
198 found_rpm_version = proc_qemu.before
199
200 # Make sure the retrieved rpm version is the expected one
201 if rpm_version not in found_rpm_version:
202 system('pkill qemu')
203 proc_qemu.close()
204 self.fail('RPM version is not {}, found instead {}.'.format(rpm_version, found_rpm_version))
205
206 # Cleanup (close qemu)
207 system('pkill qemu')
208 proc_qemu.close()
209
210
211class Gummiboot(oeSelfTest):
212
213 meta_intel_dir = ''
214
215 def setUpLocal(self):
216 """
217 Common setup for test cases: 1101, 1103
218 """
219
220 self.meta_intel_dir = get_bb_var('COREBASE') + '/meta-intel'
221 meta_nuc_dir = self.meta_intel_dir + '/meta-nuc'
222 meta_intel_repo = 'http://git.yoctoproject.org/git/meta-intel'
223
224 # Delete meta_intel_dir
225 system('rm -rf ' + self.meta_intel_dir)
226
227 # Delete meta-intel dir even if the setUp fails
228 self.add_command_to_tearDown('rm -rf ' + self.meta_intel_dir)
229
230 # Clone meta-intel
231 ret = runCmd('git clone ' + meta_intel_repo + ' ' + self.meta_intel_dir)
232 self.assertEqual(0, ret.status, 'Failed to clone meta-intel.')
233
234 # Add meta-intel and meta-nuc layers in conf/bblayers.conf
235 features = 'BBLAYERS += "' + self.meta_intel_dir + ' ' + meta_nuc_dir + '"'
236 self.append_bblayers_config(features)
237
238 # Set EFI_PROVIDER = "gummiboot" and MACHINE = "nuc" in conf/local.conf
239 features = 'EFI_PROVIDER = "gummiboot"\n'
240 features += 'MACHINE = "nuc"'
241 self.append_config(features)
242
243 # Run "bitbake core-image-minimal" to build a nuc efi/gummiboot image
244 ret = bitbake('core-image-minimal')
245 self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal')
246
247 @testcase(1101)
248 def test_efi_gummiboot_images_can_be_build(self):
249 """
250 Summary: Check if efi/gummiboot images can be buit
251 Expected: 1. File gummibootx64.efi should be available in build/tmp/deploy/images/nuc
252 2. Efi/gummiboot images can be built
253 Product: oe-core
254 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
255 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
256 """
257
258 look_for_file = 'gummibootx64.efi'
259 file_location = get_bb_var('COREBASE') + '/build/tmp/deploy/images/nuc/'
260
261 found = isfile(file_location + look_for_file)
262 self.assertTrue(found, 'File {} not found under {}.'.format(look_for_file, file_location))
263
264 @testcase(1103)
265 def test_wic_command_can_create_efi_gummiboot_installation_images(self):
266 """
267 Summary: Check that wic command can create efi/gummiboot installation images
268 Expected: A .direct file in folder /var/tmp/wic/ must be created.
269 Product: oe-core
270 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
271 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
272 """
273
274 # Create efi/gummiboot installation images
275 wic_create_cmd = 'wic create mkgummidisk -e core-image-minimal'
276 ret = runCmd(wic_create_cmd)
277 self.assertEqual(0, ret.status, 'Failed to create efi/gummiboot installation images.')
278
279 # Verify that a .direct file was created
280 direct_file = '/var/tmp/wic/build/*.direct'
281 ret = glob.glob(direct_file)
282 self.assertEqual(1, len(ret), 'Failed to find the .direct file')