summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorJair Gonzalez <jair.de.jesus.gonzalez.plascencia@linux.intel.com>2016-12-16 21:46:18 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-22 08:50:17 +0000
commitdd37336b4dedf63d5c4daf7fd4d507091b7a7256 (patch)
tree8a3ff0fd81d13f167c12838dc338b46475d97456 /meta/lib
parentf8745bb51935e8fddab5daf3c1ad460a72e890bd (diff)
downloadpoky-dd37336b4dedf63d5c4daf7fd4d507091b7a7256.tar.gz
selftest/wic: extending test coverage for WIC script options
The previous WIC script selftest didn't cover all of its command line options. Some option variants were included in existing test cases and the following tests were added to complete covering them: 1552 Test wic --version 1553 Test wic help create 1554 Test wic help list 1555 Test wic list images 1556 Test wic list source-plugins 1557 Test wic listed images help 1558 Test debug 1563 Test skip build check 1564 Test build rootfs 1559 Test image vars directory selection 1562 Test alternate output directory (From OE-Core rev: b4d52c3f1e0ad2c14028ff08c0938d1b24b7f648) Signed-off-by: Jair Gonzalez <jair.de.jesus.gonzalez.plascencia@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/wic.py142
1 files changed, 128 insertions, 14 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 52b9538a68..3db00a6bb2 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -37,7 +37,9 @@ 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/"
40 image_is_ready = False 41 image_is_ready = False
42 wicenv_cache = {}
41 43
42 def setUpLocal(self): 44 def setUpLocal(self):
43 """This code is executed before each test method.""" 45 """This code is executed before each test method."""
@@ -56,10 +58,16 @@ class Wic(oeSelfTest):
56 58
57 rmtree(self.resultdir, ignore_errors=True) 59 rmtree(self.resultdir, ignore_errors=True)
58 60
61 @testcase(1552)
62 def test_version(self):
63 """Test wic --version"""
64 self.assertEqual(0, runCmd('wic --version').status)
65
59 @testcase(1208) 66 @testcase(1208)
60 def test_help(self): 67 def test_help(self):
61 """Test wic --help""" 68 """Test wic --help and wic -h"""
62 self.assertEqual(0, runCmd('wic --help').status) 69 self.assertEqual(0, runCmd('wic --help').status)
70 self.assertEqual(0, runCmd('wic -h').status)
63 71
64 @testcase(1209) 72 @testcase(1209)
65 def test_createhelp(self): 73 def test_createhelp(self):
@@ -71,6 +79,16 @@ class Wic(oeSelfTest):
71 """Test wic list --help""" 79 """Test wic list --help"""
72 self.assertEqual(0, runCmd('wic list --help').status) 80 self.assertEqual(0, runCmd('wic list --help').status)
73 81
82 @testcase(1553)
83 def test_help_create(self):
84 """Test wic help create"""
85 self.assertEqual(0, runCmd('wic help create').status)
86
87 @testcase(1554)
88 def test_help_list(self):
89 """Test wic help list"""
90 self.assertEqual(0, runCmd('wic help list').status)
91
74 @testcase(1215) 92 @testcase(1215)
75 def test_help_overview(self): 93 def test_help_overview(self):
76 """Test wic help overview""" 94 """Test wic help overview"""
@@ -86,6 +104,24 @@ class Wic(oeSelfTest):
86 """Test wic help kickstart""" 104 """Test wic help kickstart"""
87 self.assertEqual(0, runCmd('wic help kickstart').status) 105 self.assertEqual(0, runCmd('wic help kickstart').status)
88 106
107 @testcase(1555)
108 def test_list_images(self):
109 """Test wic list images"""
110 self.assertEqual(0, runCmd('wic list images').status)
111
112 @testcase(1556)
113 def test_list_source_plugins(self):
114 """Test wic list source-plugins"""
115 self.assertEqual(0, runCmd('wic list source-plugins').status)
116
117 @testcase(1557)
118 def test_listed_images_help(self):
119 """Test wic listed images help"""
120 output = runCmd('wic list images').output
121 imagelist = [line.split()[0] for line in output.splitlines()]
122 for image in imagelist:
123 self.assertEqual(0, runCmd('wic list %s help' % image).status)
124
89 @testcase(1213) 125 @testcase(1213)
90 def test_unsupported_subcommand(self): 126 def test_unsupported_subcommand(self):
91 """Test unsupported subcommand""" 127 """Test unsupported subcommand"""
@@ -99,8 +135,8 @@ class Wic(oeSelfTest):
99 135
100 @testcase(1211) 136 @testcase(1211)
101 def test_build_image_name(self): 137 def test_build_image_name(self):
102 """Test wic create directdisk --image-name core-image-minimal""" 138 """Test wic create directdisk --image-name=core-image-minimal"""
103 cmd = "wic create directdisk --image-name core-image-minimal" 139 cmd = "wic create directdisk --image-name=core-image-minimal"
104 self.assertEqual(0, runCmd(cmd).status) 140 self.assertEqual(0, runCmd(cmd).status)
105 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 141 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
106 142
@@ -162,6 +198,22 @@ class Wic(oeSelfTest):
162 self.assertEqual(0, runCmd(cmd).status) 198 self.assertEqual(0, runCmd(cmd).status)
163 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 199 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
164 200
201 @testcase(1562)
202 def test_alternate_output_dir(self):
203 """Test alternate output directory"""
204 self.assertEqual(0, runCmd("wic create directdisk "
205 "-e core-image-minimal "
206 "-o %s"
207 % self.alternate_resultdir).status)
208 self.assertEqual(1, len(glob(self.alternate_resultdir +
209 "build/directdisk-*.direct")))
210 self.assertEqual(0, runCmd("wic create mkefidisk -e "
211 "core-image-minimal "
212 "--outdir=%s"
213 % self.alternate_resultdir).status)
214 self.assertEqual(1, len(glob(self.alternate_resultdir +
215 "build/mkefidisk-*direct")))
216
165 @testcase(1212) 217 @testcase(1212)
166 def test_build_artifacts(self): 218 def test_build_artifacts(self):
167 """Test wic create directdisk providing all artifacts.""" 219 """Test wic create directdisk providing all artifacts."""
@@ -188,7 +240,7 @@ class Wic(oeSelfTest):
188 def test_compress_bzip2(self): 240 def test_compress_bzip2(self):
189 """Test compressing an image with bzip2""" 241 """Test compressing an image with bzip2"""
190 self.assertEqual(0, runCmd("wic create directdisk " 242 self.assertEqual(0, runCmd("wic create directdisk "
191 "--image-name core-image-minimal " 243 "--image-name=core-image-minimal "
192 "-c bzip2").status) 244 "-c bzip2").status)
193 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.bz2"))) 245 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.bz2")))
194 246
@@ -196,22 +248,58 @@ class Wic(oeSelfTest):
196 def test_compress_xz(self): 248 def test_compress_xz(self):
197 """Test compressing an image with xz""" 249 """Test compressing an image with xz"""
198 self.assertEqual(0, runCmd("wic create directdisk " 250 self.assertEqual(0, runCmd("wic create directdisk "
199 "--image-name core-image-minimal " 251 "--image-name=core-image-minimal "
200 "-c xz").status) 252 "--compress-with=xz").status)
201 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.xz"))) 253 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.xz")))
202 254
203 @testcase(1267) 255 @testcase(1267)
204 def test_wrong_compressor(self): 256 def test_wrong_compressor(self):
205 """Test how wic breaks if wrong compressor is provided""" 257 """Test how wic breaks if wrong compressor is provided"""
206 self.assertEqual(2, runCmd("wic create directdisk " 258 self.assertEqual(2, runCmd("wic create directdisk "
207 "--image-name core-image-minimal " 259 "--image-name=core-image-minimal "
208 "-c wrong", ignore_status=True).status) 260 "-c wrong", ignore_status=True).status)
209 261
262 @testcase(1558)
263 def test_debug(self):
264 """Test debug"""
265 self.assertEqual(0, runCmd("wic create directdisk "
266 "--image-name=core-image-minimal "
267 "-D").status)
268 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
269 self.assertEqual(0, runCmd("wic create directdisk "
270 "--image-name=core-image-minimal "
271 "--debug").status)
272 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
273
274 @testcase(1563)
275 def test_skip_build_check(self):
276 """Test skip build check"""
277 self.assertEqual(0, runCmd("wic create directdisk "
278 "--image-name=core-image-minimal "
279 "-s").status)
280 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
281 self.assertEqual(0, runCmd("wic create directdisk "
282 "--image-name=core-image-minimal "
283 "--skip-build-check").status)
284 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
285
286 @testcase(1564)
287 def test_build_rootfs(self):
288 """Test build rootfs"""
289 self.assertEqual(0, runCmd("wic create directdisk "
290 "--image-name=core-image-minimal "
291 "-f").status)
292 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
293 self.assertEqual(0, runCmd("wic create directdisk "
294 "--image-name=core-image-minimal "
295 "--build-rootfs").status)
296 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
297
210 @testcase(1268) 298 @testcase(1268)
211 def test_rootfs_indirect_recipes(self): 299 def test_rootfs_indirect_recipes(self):
212 """Test usage of rootfs plugin with rootfs recipes""" 300 """Test usage of rootfs plugin with rootfs recipes"""
213 status = runCmd("wic create directdisk-multi-rootfs " 301 status = runCmd("wic create directdisk-multi-rootfs "
214 "--image-name core-image-minimal " 302 "--image-name=core-image-minimal "
215 "--rootfs rootfs1=core-image-minimal " 303 "--rootfs rootfs1=core-image-minimal "
216 "--rootfs rootfs2=core-image-minimal").status 304 "--rootfs rootfs2=core-image-minimal").status
217 self.assertEqual(0, status) 305 self.assertEqual(0, status)
@@ -225,9 +313,9 @@ class Wic(oeSelfTest):
225 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) 313 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS'))
226 bbvars['wks'] = "directdisk-multi-rootfs" 314 bbvars['wks'] = "directdisk-multi-rootfs"
227 status = runCmd("wic create %(wks)s " 315 status = runCmd("wic create %(wks)s "
228 "-b %(staging_datadir)s " 316 "--bootimg-dir=%(staging_datadir)s "
229 "-k %(deploy_dir_image)s " 317 "--kernel-dir=%(deploy_dir_image)s "
230 "-n %(staging_dir_native)s " 318 "--native-sysroot=%(staging_dir_native)s "
231 "--rootfs-dir rootfs1=%(image_rootfs)s " 319 "--rootfs-dir rootfs1=%(image_rootfs)s "
232 "--rootfs-dir rootfs2=%(image_rootfs)s" 320 "--rootfs-dir rootfs2=%(image_rootfs)s"
233 % bbvars).status 321 % bbvars).status
@@ -237,19 +325,30 @@ class Wic(oeSelfTest):
237 @testcase(1496) 325 @testcase(1496)
238 def test_bmap(self): 326 def test_bmap(self):
239 """Test generation of .bmap file""" 327 """Test generation of .bmap file"""
328 cmd = "wic create directdisk -e core-image-minimal -m"
329 status = runCmd(cmd).status
330 self.assertEqual(0, status)
331 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
332 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
240 cmd = "wic create directdisk -e core-image-minimal --bmap" 333 cmd = "wic create directdisk -e core-image-minimal --bmap"
241 status = runCmd(cmd).status 334 status = runCmd(cmd).status
242 self.assertEqual(0, status) 335 self.assertEqual(0, status)
243 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct"))) 336 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
244 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap"))) 337 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
245 338
339 def _get_image_env_path(self, image):
340 """Generate and obtain the path to <image>.env"""
341 if image not in self.wicenv_cache:
342 self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status)
343 stdir = get_bb_var('STAGING_DIR_TARGET', image)
344 self.wicenv_cache[image] = os.path.join(stdir, 'imgdata')
345 return self.wicenv_cache[image]
346
246 @testcase(1347) 347 @testcase(1347)
247 def test_image_env(self): 348 def test_image_env(self):
248 """Test generation of <image>.env files.""" 349 """Test generation of <image>.env files."""
249 image = 'core-image-minimal' 350 image = 'core-image-minimal'
250 self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status) 351 imgdatadir = self._get_image_env_path(image)
251 stdir = get_bb_var('STAGING_DIR_TARGET', image)
252 imgdatadir = os.path.join(stdir, 'imgdata')
253 352
254 basename = get_bb_var('IMAGE_BASENAME', image) 353 basename = get_bb_var('IMAGE_BASENAME', image)
255 self.assertEqual(basename, image) 354 self.assertEqual(basename, image)
@@ -267,6 +366,21 @@ class Wic(oeSelfTest):
267 self.assertTrue(var in content, "%s is not in .env file" % var) 366 self.assertTrue(var in content, "%s is not in .env file" % var)
268 self.assertTrue(content[var]) 367 self.assertTrue(content[var])
269 368
369 @testcase(1559)
370 def test_image_vars_dir(self):
371 """Test image vars directory selection"""
372 image = 'core-image-minimal'
373 imgenvdir = self._get_image_env_path(image)
374
375 self.assertEqual(0, runCmd("wic create directdisk "
376 "--image-name=%s "
377 "-v %s"
378 % (image, imgenvdir)).status)
379 self.assertEqual(0, runCmd("wic create directdisk "
380 "--image-name=%s "
381 "--vars %s"
382 % (image, imgenvdir)).status)
383
270 @testcase(1351) 384 @testcase(1351)
271 def test_wic_image_type(self): 385 def test_wic_image_type(self):
272 """Test building wic images by bitbake""" 386 """Test building wic images by bitbake"""