summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/wic.py246
1 files changed, 72 insertions, 174 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 46bfb94ea9..e652fad24a 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -37,13 +37,13 @@ class Wic(oeSelfTest):
37 """Wic test class.""" 37 """Wic test class."""
38 38
39 resultdir = "/var/tmp/wic/build/" 39 resultdir = "/var/tmp/wic/build/"
40 alternate_resultdir = "/var/tmp/wic/build/alt/"
41 image_is_ready = False 40 image_is_ready = False
42 41
43 def setUpLocal(self): 42 def setUpLocal(self):
44 """This code is executed before each test method.""" 43 """This code is executed before each test method."""
45 self.write_config('IMAGE_FSTYPES += " hddimg"\n' 44 self.write_config('IMAGE_FSTYPES += " hddimg"\n'
46 'MACHINE_FEATURES_append = " efi"\n') 45 'MACHINE_FEATURES_append = " efi"\n'
46 'WKS_FILE = "wic-image-minimal"\n')
47 47
48 # Do this here instead of in setUpClass as the base setUp does some 48 # Do this here instead of in setUpClass as the base setUp does some
49 # clean up which can result in the native tools built earlier in 49 # clean up which can result in the native tools built earlier in
@@ -56,16 +56,10 @@ class Wic(oeSelfTest):
56 56
57 rmtree(self.resultdir, ignore_errors=True) 57 rmtree(self.resultdir, ignore_errors=True)
58 58
59 @testcase(1552)
60 def test_version(self):
61 """Test wic --version"""
62 self.assertEqual(0, runCmd('wic --version').status)
63
64 @testcase(1208) 59 @testcase(1208)
65 def test_help(self): 60 def test_help(self):
66 """Test wic --help and wic -h""" 61 """Test wic --help"""
67 self.assertEqual(0, runCmd('wic --help').status) 62 self.assertEqual(0, runCmd('wic --help').status)
68 self.assertEqual(0, runCmd('wic -h').status)
69 63
70 @testcase(1209) 64 @testcase(1209)
71 def test_createhelp(self): 65 def test_createhelp(self):
@@ -77,74 +71,19 @@ class Wic(oeSelfTest):
77 """Test wic list --help""" 71 """Test wic list --help"""
78 self.assertEqual(0, runCmd('wic list --help').status) 72 self.assertEqual(0, runCmd('wic list --help').status)
79 73
80 @testcase(1553)
81 def test_help_create(self):
82 """Test wic help create"""
83 self.assertEqual(0, runCmd('wic help create').status)
84
85 @testcase(1554)
86 def test_help_list(self):
87 """Test wic help list"""
88 self.assertEqual(0, runCmd('wic help list').status)
89
90 @testcase(1215)
91 def test_help_overview(self):
92 """Test wic help overview"""
93 self.assertEqual(0, runCmd('wic help overview').status)
94
95 @testcase(1216)
96 def test_help_plugins(self):
97 """Test wic help plugins"""
98 self.assertEqual(0, runCmd('wic help plugins').status)
99
100 @testcase(1217)
101 def test_help_kickstart(self):
102 """Test wic help kickstart"""
103 self.assertEqual(0, runCmd('wic help kickstart').status)
104
105 @testcase(1555)
106 def test_list_images(self):
107 """Test wic list images"""
108 self.assertEqual(0, runCmd('wic list images').status)
109
110 @testcase(1556)
111 def test_list_source_plugins(self):
112 """Test wic list source-plugins"""
113 self.assertEqual(0, runCmd('wic list source-plugins').status)
114
115 @testcase(1557)
116 def test_listed_images_help(self):
117 """Test wic listed images help"""
118 output = runCmd('wic list images').output
119 imageDetails = [line.split() for line in output.split('\n')]
120 imageList = [row[0] for row in imageDetails]
121 for image in imageList:
122 self.assertEqual(0, runCmd('wic list %s help' % image).status)
123
124 @testcase(1213)
125 def test_unsupported_subcommand(self):
126 """Test unsupported subcommand"""
127 self.assertEqual(1, runCmd('wic unsupported',
128 ignore_status=True).status)
129
130 @testcase(1214)
131 def test_no_command(self):
132 """Test wic without command"""
133 self.assertEqual(1, runCmd('wic', ignore_status=True).status)
134
135 @testcase(1211) 74 @testcase(1211)
136 def test_build_image_name(self): 75 def test_build_image_name(self):
137 """Test wic create directdisk --image-name core-image-minimal""" 76 """Test wic create directdisk --image-name core-image-minimal"""
138 self.assertEqual(0, runCmd("wic create directdisk " 77 self.assertEqual(0, runCmd("wic create directdisk "
139 "--image-name=core-image-minimal").status) 78 "--image-name core-image-minimal").status)
140 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 79 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
141 80
142 @testcase(1212) 81 @testcase(1212)
143 def test_build_artifacts(self): 82 def test_build_artifacts(self):
144 """Test wic create directdisk providing all artifacts.""" 83 """Test wic create directdisk providing all artifacts."""
145 bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) 84 bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \
146 for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', 85 for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE',
147 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) 86 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS'))
148 status = runCmd("wic create directdisk " 87 status = runCmd("wic create directdisk "
149 "-b %(staging_datadir)s " 88 "-b %(staging_datadir)s "
150 "-k %(deploy_dir_image)s " 89 "-k %(deploy_dir_image)s "
@@ -157,110 +96,113 @@ class Wic(oeSelfTest):
157 def test_gpt_image(self): 96 def test_gpt_image(self):
158 """Test creation of core-image-minimal with gpt table and UUID boot""" 97 """Test creation of core-image-minimal with gpt table and UUID boot"""
159 self.assertEqual(0, runCmd("wic create directdisk-gpt " 98 self.assertEqual(0, runCmd("wic create directdisk-gpt "
160 "--image-name core-image-minimal " 99 "--image-name core-image-minimal").status)
161 ).status)
162 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 100 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
163 101
102 @testcase(1213)
103 def test_unsupported_subcommand(self):
104 """Test unsupported subcommand"""
105 self.assertEqual(1, runCmd('wic unsupported',
106 ignore_status=True).status)
107
108 @testcase(1214)
109 def test_no_command(self):
110 """Test wic without command"""
111 self.assertEqual(1, runCmd('wic', ignore_status=True).status)
112
113 @testcase(1215)
114 def test_help_overview(self):
115 """Test wic help overview"""
116 self.assertEqual(0, runCmd('wic help overview').status)
117
118 @testcase(1216)
119 def test_help_plugins(self):
120 """Test wic help plugins"""
121 self.assertEqual(0, runCmd('wic help plugins').status)
122
123 @testcase(1217)
124 def test_help_kickstart(self):
125 """Test wic help kickstart"""
126 self.assertEqual(0, runCmd('wic help kickstart').status)
127
164 @testcase(1264) 128 @testcase(1264)
165 def test_compress_gzip(self): 129 def test_compress_gzip(self):
166 """Test compressing an image with gzip""" 130 """Test compressing an image with gzip"""
167 self.assertEqual(0, runCmd("wic create directdisk " 131 self.assertEqual(0, runCmd("wic create directdisk "
168 "-e core-image-minimal " 132 "--image-name core-image-minimal "
169 "-c gzip").status) 133 "-c gzip").status)
170 self.assertEqual(1, len(glob(self.resultdir + 134 self.assertEqual(1, len(glob(self.resultdir + \
171 "directdisk-*.direct.gz"))) 135 "directdisk-*.direct.gz")))
172 136
173 @testcase(1265) 137 @testcase(1265)
174 def test_compress_bzip2(self): 138 def test_compress_bzip2(self):
175 """Test compressing an image with bzip2""" 139 """Test compressing an image with bzip2"""
176 self.assertEqual(0, runCmd("wic create directdisk " 140 self.assertEqual(0, runCmd("wic create directdisk "
177 "--image-name=core-image-minimal " 141 "--image-name core-image-minimal "
178 "-c bzip2").status) 142 "-c bzip2").status)
179 self.assertEqual(1, len(glob(self.resultdir + 143 self.assertEqual(1, len(glob(self.resultdir + \
180 "directdisk-*.direct.bz2"))) 144 "directdisk-*.direct.bz2")))
181 145
182 @testcase(1266) 146 @testcase(1266)
183 def test_compress_xz(self): 147 def test_compress_xz(self):
184 """Test compressing an image with xz""" 148 """Test compressing an image with xz"""
185 self.assertEqual(0, runCmd("wic create directdisk " 149 self.assertEqual(0, runCmd("wic create directdisk "
186 "--image-name=core-image-minimal " 150 "--image-name core-image-minimal "
187 "--compress-with=xz").status) 151 "-c xz").status)
188 self.assertEqual(1, len(glob(self.resultdir + 152 self.assertEqual(1, len(glob(self.resultdir + \
189 "directdisk-*.direct.xz"))) 153 "directdisk-*.direct.xz")))
190 154
191 @testcase(1267) 155 @testcase(1267)
192 def test_wrong_compressor(self): 156 def test_wrong_compressor(self):
193 """Test how wic breaks if wrong compressor is provided""" 157 """Test how wic breaks if wrong compressor is provided"""
194 self.assertEqual(2, runCmd("wic create directdisk " 158 self.assertEqual(2, runCmd("wic create directdisk "
195 "--image-name=core-image-minimal " 159 "--image-name core-image-minimal "
196 "-c wrong", ignore_status=True).status) 160 "-c wrong", ignore_status=True).status)
197 161
198 @testcase(1558)
199 def test_debug_skip_build_check_and_build_rootfs(self):
200 """Test wic debug, skip-build-check and build_rootfs"""
201 self.assertEqual(0, runCmd("wic create directdisk "
202 "--image-name=core-image-minimal "
203 "-D -s -f").status)
204 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
205 self.assertEqual(0, runCmd("wic create directdisk "
206 "--image-name=core-image-minimal "
207 "--debug "
208 "--skip-build-check "
209 "--build-rootfs").status)
210 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
211
212 @testcase(1268) 162 @testcase(1268)
213 def test_rootfs_indirect_recipes(self): 163 def test_rootfs_indirect_recipes(self):
214 """Test usage of rootfs plugin with rootfs recipes""" 164 """Test usage of rootfs plugin with rootfs recipes"""
215 wks = "directdisk-multi-rootfs" 165 wks = "directdisk-multi-rootfs"
216 self.assertEqual(0, runCmd("wic create %s " 166 self.assertEqual(0, runCmd("wic create %s "
217 "--image-name=core-image-minimal " 167 "--image-name core-image-minimal "
218 "--rootfs rootfs1=core-image-minimal " 168 "--rootfs rootfs1=core-image-minimal "
219 "--rootfs rootfs2=core-image-minimal" 169 "--rootfs rootfs2=core-image-minimal" \
220 % wks).status) 170 % wks).status)
221 self.assertEqual(1, len(glob(self.resultdir + "%s*.direct" % wks))) 171 self.assertEqual(1, len(glob(self.resultdir + "%s*.direct" % wks)))
222 172
223 @testcase(1269) 173 @testcase(1269)
224 def test_rootfs_artifacts(self): 174 def test_rootfs_artifacts(self):
225 """Test usage of rootfs plugin with rootfs paths""" 175 """Test usage of rootfs plugin with rootfs paths"""
226 bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) 176 bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \
227 for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', 177 for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE',
228 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) 178 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS'))
229 bbvars['wks'] = "directdisk-multi-rootfs" 179 bbvars['wks'] = "directdisk-multi-rootfs"
230 status = runCmd("wic create %(wks)s " 180 status = runCmd("wic create %(wks)s "
231 "--bootimg-dir=%(staging_datadir)s " 181 "-b %(staging_datadir)s "
232 "--kernel-dir=%(deploy_dir_image)s " 182 "-k %(deploy_dir_image)s "
233 "--native-sysroot=%(staging_dir_native)s " 183 "-n %(staging_dir_native)s "
234 "--rootfs-dir rootfs1=%(image_rootfs)s " 184 "--rootfs-dir rootfs1=%(image_rootfs)s "
235 "--rootfs-dir rootfs2=%(image_rootfs)s" 185 "--rootfs-dir rootfs2=%(image_rootfs)s" \
236 % bbvars).status 186 % bbvars).status
237 self.assertEqual(0, status) 187 self.assertEqual(0, status)
238 self.assertEqual(1, len(glob(self.resultdir + 188 self.assertEqual(1, len(glob(self.resultdir + \
239 "%(wks)s-*.direct" % bbvars))) 189 "%(wks)s-*.direct" % bbvars)))
240 190
241 @testcase(1346) 191 @testcase(1346)
242 def test_iso_image(self): 192 def test_iso_image(self):
243 """Test creation of hybrid iso image with legacy and EFI boot""" 193 """Test creation of hybrid iso image with legacy and EFI boot"""
244 self.assertEqual(0, runCmd("wic create mkhybridiso " 194 self.assertEqual(0, runCmd("wic create mkhybridiso "
245 "--image-name core-image-minimal" 195 "--image-name core-image-minimal").status)
246 ).status) 196 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct")))
247 self.assertEqual(1, len(glob(self.resultdir + 197 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso")))
248 "HYBRID_ISO_IMG-*.direct")))
249 self.assertEqual(1, len(glob(self.resultdir +
250 "HYBRID_ISO_IMG-*.iso")))
251
252 def __get_image_env_path(self, image):
253 """Generate and obtain the path to <image>.env"""
254 self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status)
255 stdir = get_bb_var('STAGING_DIR_TARGET', image)
256 imgdatadir = os.path.join(stdir, 'imgdata')
257 return imgdatadir
258 198
259 @testcase(1347) 199 @testcase(1347)
260 def test_image_env(self): 200 def test_image_env(self):
261 """Test generation of <image>.env files""" 201 """Test generation of <image>.env files."""
262 image = 'core-image-minimal' 202 image = 'core-image-minimal'
263 imgdatadir = self.__get_image_env_path(image) 203 self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status)
204 stdir = get_bb_var('STAGING_DIR_TARGET', image)
205 imgdatadir = os.path.join(stdir, 'imgdata')
264 206
265 basename = get_bb_var('IMAGE_BASENAME', image) 207 basename = get_bb_var('IMAGE_BASENAME', image)
266 self.assertEqual(basename, image) 208 self.assertEqual(basename, image)
@@ -278,21 +220,6 @@ class Wic(oeSelfTest):
278 self.assertTrue(var in content, "%s is not in .env file" % var) 220 self.assertTrue(var in content, "%s is not in .env file" % var)
279 self.assertTrue(content[var]) 221 self.assertTrue(content[var])
280 222
281 @testcase(1559)
282 def test_image_vars_dir(self):
283 """Test image vars directory selection"""
284 image = 'core-image-minimal'
285 imgenvdir = self.__get_image_env_path(image)
286
287 self.assertEqual(0, runCmd("wic create directdisk "
288 "--image-name=%s "
289 "-v %s"
290 % (image, imgenvdir)).status)
291 self.assertEqual(0, runCmd("wic create directdisk "
292 "--image-name=%s "
293 "--vars %s"
294 % (image, imgenvdir)).status)
295
296 @testcase(1351) 223 @testcase(1351)
297 def test_wic_image_type(self): 224 def test_wic_image_type(self):
298 """Test building wic images by bitbake""" 225 """Test building wic images by bitbake"""
@@ -312,7 +239,7 @@ class Wic(oeSelfTest):
312 def test_qemux86_directdisk(self): 239 def test_qemux86_directdisk(self):
313 """Test creation of qemux-86-directdisk image""" 240 """Test creation of qemux-86-directdisk image"""
314 image = "qemux86-directdisk" 241 image = "qemux86-directdisk"
315 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" 242 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
316 % image).status) 243 % image).status)
317 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 244 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
318 245
@@ -320,8 +247,7 @@ class Wic(oeSelfTest):
320 def test_mkgummidisk(self): 247 def test_mkgummidisk(self):
321 """Test creation of mkgummidisk image""" 248 """Test creation of mkgummidisk image"""
322 image = "mkgummidisk" 249 image = "mkgummidisk"
323 self.assertEqual(0, runCmd("wic create %s --image-name " 250 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
324 "core-image-minimal"
325 % image).status) 251 % image).status)
326 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 252 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
327 253
@@ -329,7 +255,7 @@ class Wic(oeSelfTest):
329 def test_mkefidisk(self): 255 def test_mkefidisk(self):
330 """Test creation of mkefidisk image""" 256 """Test creation of mkefidisk image"""
331 image = "mkefidisk" 257 image = "mkefidisk"
332 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" 258 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
333 % image).status) 259 % image).status)
334 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 260 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
335 261
@@ -337,11 +263,11 @@ class Wic(oeSelfTest):
337 def test_directdisk_bootloader_config(self): 263 def test_directdisk_bootloader_config(self):
338 """Test creation of directdisk-bootloader-config image""" 264 """Test creation of directdisk-bootloader-config image"""
339 image = "directdisk-bootloader-config" 265 image = "directdisk-bootloader-config"
340 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" 266 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
341 % image).status) 267 % image).status)
342 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 268 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
343 269
344 @testcase(1424) 270 @testcase(1422)
345 def test_qemu(self): 271 def test_qemu(self):
346 """Test wic-image-minimal under qemu""" 272 """Test wic-image-minimal under qemu"""
347 self.assertEqual(0, bitbake('wic-image-minimal').status) 273 self.assertEqual(0, bitbake('wic-image-minimal').status)
@@ -349,56 +275,28 @@ class Wic(oeSelfTest):
349 with runqemu('wic-image-minimal', ssh=False) as qemu: 275 with runqemu('wic-image-minimal', ssh=False) as qemu:
350 command = "mount |grep '^/dev/' | cut -f1,3 -d ' '" 276 command = "mount |grep '^/dev/' | cut -f1,3 -d ' '"
351 status, output = qemu.run_serial(command) 277 status, output = qemu.run_serial(command)
352 self.assertEqual(1, status, 'Failed to run command "%s": %s' 278 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (command, output))
353 % (command, output))
354 self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt') 279 self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
355 280
356 @testcase(1496)
357 def test_bmap(self): 281 def test_bmap(self):
358 """Test generation of .bmap file""" 282 """Test generation of .bmap file"""
359 image = "directdisk" 283 image = "directdisk"
360 status = runCmd("wic create %s -e core-image-minimal -m" 284 status = runCmd("wic create %s -e core-image-minimal --bmap" % image).status
361 % image).status
362 self.assertEqual(0, status)
363 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
364 self.assertEqual(1, len(glob(self.resultdir +
365 "%s-*direct.bmap" % image)))
366 status = runCmd("wic create %s -e core-image-minimal --bmap"
367 % image).status
368 self.assertEqual(0, status) 285 self.assertEqual(0, status)
369 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 286 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
370 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct.bmap" 287 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct.bmap" % image)))
371 % image)))
372 288
373 @testcase(1560)
374 def test_systemd_bootdisk(self): 289 def test_systemd_bootdisk(self):
375 """Test creation of systemd-bootdisk image""" 290 """Test creation of systemd-bootdisk image"""
376 image = "systemd-bootdisk" 291 image = "systemd-bootdisk"
377 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" 292 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
378 % image).status) 293 % image).status)
379 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 294 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
380 295
381 @testcase(1561)
382 def test_sdimage_bootpart(self): 296 def test_sdimage_bootpart(self):
383 """Test creation of sdimage-bootpart image""" 297 """Test creation of sdimage-bootpart image"""
384 image = "sdimage-bootpart" 298 image = "sdimage-bootpart"
385 self.write_config('IMAGE_BOOT_FILES = "bzImage"\n') 299 self.write_config('IMAGE_BOOT_FILES = "bzImage"\n')
386 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" 300 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
387 % image).status) 301 % image).status)
388 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) 302 self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
389
390 @testcase(1562)
391 def test_alternate_output_dir(self):
392 """Test alternate output directory"""
393 self.assertEqual(0, runCmd("wic create directdisk "
394 "-e core-image-minimal "
395 "-o %s"
396 % self.alternate_resultdir).status)
397 self.assertEqual(1, len(glob(self.alternate_resultdir +
398 "build/directdisk-*.direct")))
399 self.assertEqual(0, runCmd("wic create mkefidisk -e "
400 "core-image-minimal "
401 "--outdir %s"
402 % self.alternate_resultdir).status)
403 self.assertEqual(1, len(glob(self.alternate_resultdir +
404 "build/mkefidisk-*direct")))