1# 2# Copyright (c) 2015, Intel Corporation. 3# 4# SPDX-License-Identifier: GPL-2.0-only 5# 6# AUTHORS 7# Ed Bartosh <ed.bartosh@linux.intel.com> 8 9"""Test cases for wic.""" 10 11import os 12import sys 13import unittest 14 15from glob import glob 16from shutil import rmtree, copy 17from functools import wraps, lru_cache 18from tempfile import NamedTemporaryFile 19 20from oeqa.selftest.case import OESelftestTestCase 21from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu 22 23 24@lru_cache(maxsize=32) 25def get_host_arch(recipe): 26 """A cached call to get_bb_var('HOST_ARCH', <recipe>)""" 27 return get_bb_var('HOST_ARCH', recipe) 28 29 30def only_for_arch(archs, image='core-image-minimal'): 31 """Decorator for wrapping test cases that can be run only for specific target 32 architectures. A list of compatible architectures is passed in `archs`. 33 Current architecture will be determined by parsing bitbake output for 34 `image` recipe. 35 """ 36 def wrapper(func): 37 @wraps(func) 38 def wrapped_f(*args, **kwargs): 39 arch = get_host_arch(image) 40 if archs and arch not in archs: 41 raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch) 42 return func(*args, **kwargs) 43 wrapped_f.__name__ = func.__name__ 44 return wrapped_f 45 return wrapper 46 47 48class WicTestCase(OESelftestTestCase): 49 """Wic test class.""" 50 51 image_is_ready = False 52 wicenv_cache = {} 53 54 def setUpLocal(self): 55 """This code is executed before each test method.""" 56 self.resultdir = self.builddir + "/wic-tmp/" 57 super(WicTestCase, self).setUpLocal() 58 59 # Do this here instead of in setUpClass as the base setUp does some 60 # clean up which can result in the native tools built earlier in 61 # setUpClass being unavailable. 62 if not WicTestCase.image_is_ready: 63 if get_bb_var('USE_NLS') == 'yes': 64 bitbake('wic-tools') 65 else: 66 self.skipTest('wic-tools cannot be built due its (intltool|gettext)-native dependency and NLS disable') 67 68 bitbake('core-image-minimal') 69 WicTestCase.image_is_ready = True 70 71 rmtree(self.resultdir, ignore_errors=True) 72 73 def tearDownLocal(self): 74 """Remove resultdir as it may contain images.""" 75 rmtree(self.resultdir, ignore_errors=True) 76 super(WicTestCase, self).tearDownLocal() 77 78 def _get_image_env_path(self, image): 79 """Generate and obtain the path to <image>.env""" 80 if image not in WicTestCase.wicenv_cache: 81 self.assertEqual(0, bitbake('%s -c do_rootfs_wicenv' % image).status) 82 bb_vars = get_bb_vars(['STAGING_DIR', 'MACHINE'], image) 83 stdir = bb_vars['STAGING_DIR'] 84 machine = bb_vars['MACHINE'] 85 WicTestCase.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata') 86 return WicTestCase.wicenv_cache[image] 87 88class Wic(WicTestCase): 89 90 def test_version(self): 91 """Test wic --version""" 92 runCmd('wic --version') 93 94 def test_help(self): 95 """Test wic --help and wic -h""" 96 runCmd('wic --help') 97 runCmd('wic -h') 98 99 def test_createhelp(self): 100 """Test wic create --help""" 101 runCmd('wic create --help') 102 103 def test_listhelp(self): 104 """Test wic list --help""" 105 runCmd('wic list --help') 106 107 def test_help_create(self): 108 """Test wic help create""" 109 runCmd('wic help create') 110 111 def test_help_list(self): 112 """Test wic help list""" 113 runCmd('wic help list') 114 115 def test_help_overview(self): 116 """Test wic help overview""" 117 runCmd('wic help overview') 118 119 def test_help_plugins(self): 120 """Test wic help plugins""" 121 runCmd('wic help plugins') 122 123 def test_help_kickstart(self): 124 """Test wic help kickstart""" 125 runCmd('wic help kickstart') 126 127 def test_list_images(self): 128 """Test wic list images""" 129 runCmd('wic list images') 130 131 def test_list_source_plugins(self): 132 """Test wic list source-plugins""" 133 runCmd('wic list source-plugins') 134 135 def test_listed_images_help(self): 136 """Test wic listed images help""" 137 output = runCmd('wic list images').output 138 imagelist = [line.split()[0] for line in output.splitlines()] 139 for image in imagelist: 140 runCmd('wic list %s help' % image) 141 142 def test_unsupported_subcommand(self): 143 """Test unsupported subcommand""" 144 self.assertNotEqual(0, runCmd('wic unsupported', ignore_status=True).status) 145 146 def test_no_command(self): 147 """Test wic without command""" 148 self.assertEqual(1, runCmd('wic', ignore_status=True).status) 149 150 def test_build_image_name(self): 151 """Test wic create wictestdisk --image-name=core-image-minimal""" 152 cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir 153 runCmd(cmd) 154 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 155 156 @only_for_arch(['i586', 'i686', 'x86_64']) 157 def test_gpt_image(self): 158 """Test creation of core-image-minimal with gpt table and UUID boot""" 159 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir 160 runCmd(cmd) 161 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 162 163 @only_for_arch(['i586', 'i686', 'x86_64']) 164 def test_iso_image(self): 165 """Test creation of hybrid iso image with legacy and EFI boot""" 166 config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\ 167 'MACHINE_FEATURES_append = " efi"\n'\ 168 'DEPENDS_pn-core-image-minimal += "syslinux"\n' 169 self.append_config(config) 170 bitbake('core-image-minimal core-image-minimal-initramfs') 171 self.remove_config(config) 172 cmd = "wic create mkhybridiso --image-name core-image-minimal -o %s" % self.resultdir 173 runCmd(cmd) 174 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) 175 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) 176 177 @only_for_arch(['i586', 'i686', 'x86_64']) 178 def test_qemux86_directdisk(self): 179 """Test creation of qemux-86-directdisk image""" 180 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir 181 runCmd(cmd) 182 self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) 183 184 @only_for_arch(['i586', 'i686', 'x86_64']) 185 def test_mkefidisk(self): 186 """Test creation of mkefidisk image""" 187 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir 188 runCmd(cmd) 189 self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) 190 191 @only_for_arch(['i586', 'i686', 'x86_64']) 192 def test_bootloader_config(self): 193 """Test creation of directdisk-bootloader-config image""" 194 config = 'DEPENDS_pn-core-image-minimal += "syslinux"\n' 195 self.append_config(config) 196 bitbake('core-image-minimal') 197 self.remove_config(config) 198 cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir 199 runCmd(cmd) 200 self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) 201 202 @only_for_arch(['i586', 'i686', 'x86_64']) 203 def test_systemd_bootdisk(self): 204 """Test creation of systemd-bootdisk image""" 205 config = 'MACHINE_FEATURES_append = " efi"\n' 206 self.append_config(config) 207 bitbake('core-image-minimal') 208 self.remove_config(config) 209 cmd = "wic create systemd-bootdisk -e core-image-minimal -o %s" % self.resultdir 210 runCmd(cmd) 211 self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct"))) 212 213 def test_sdimage_bootpart(self): 214 """Test creation of sdimage-bootpart image""" 215 cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir 216 kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') 217 self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype) 218 runCmd(cmd) 219 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 220 221 @only_for_arch(['i586', 'i686', 'x86_64']) 222 def test_default_output_dir(self): 223 """Test default output location""" 224 for fname in glob("directdisk-*.direct"): 225 os.remove(fname) 226 config = 'DEPENDS_pn-core-image-minimal += "syslinux"\n' 227 self.append_config(config) 228 bitbake('core-image-minimal') 229 self.remove_config(config) 230 cmd = "wic create directdisk -e core-image-minimal" 231 runCmd(cmd) 232 self.assertEqual(1, len(glob("directdisk-*.direct"))) 233 234 @only_for_arch(['i586', 'i686', 'x86_64']) 235 def test_build_artifacts(self): 236 """Test wic create directdisk providing all artifacts.""" 237 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 238 'wic-tools') 239 bb_vars.update(get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_ROOTFS'], 240 'core-image-minimal')) 241 bbvars = {key.lower(): value for key, value in bb_vars.items()} 242 bbvars['resultdir'] = self.resultdir 243 runCmd("wic create directdisk " 244 "-b %(staging_datadir)s " 245 "-k %(deploy_dir_image)s " 246 "-n %(recipe_sysroot_native)s " 247 "-r %(image_rootfs)s " 248 "-o %(resultdir)s" % bbvars) 249 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 250 251 def test_compress_gzip(self): 252 """Test compressing an image with gzip""" 253 runCmd("wic create wictestdisk " 254 "--image-name core-image-minimal " 255 "-c gzip -o %s" % self.resultdir) 256 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz"))) 257 258 def test_compress_bzip2(self): 259 """Test compressing an image with bzip2""" 260 runCmd("wic create wictestdisk " 261 "--image-name=core-image-minimal " 262 "-c bzip2 -o %s" % self.resultdir) 263 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2"))) 264 265 def test_compress_xz(self): 266 """Test compressing an image with xz""" 267 runCmd("wic create wictestdisk " 268 "--image-name=core-image-minimal " 269 "--compress-with=xz -o %s" % self.resultdir) 270 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz"))) 271 272 def test_wrong_compressor(self): 273 """Test how wic breaks if wrong compressor is provided""" 274 self.assertEqual(2, runCmd("wic create wictestdisk " 275 "--image-name=core-image-minimal " 276 "-c wrong -o %s" % self.resultdir, 277 ignore_status=True).status) 278 279 def test_debug_short(self): 280 """Test -D option""" 281 runCmd("wic create wictestdisk " 282 "--image-name=core-image-minimal " 283 "-D -o %s" % self.resultdir) 284 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 285 286 def test_debug_long(self): 287 """Test --debug option""" 288 runCmd("wic create wictestdisk " 289 "--image-name=core-image-minimal " 290 "--debug -o %s" % self.resultdir) 291 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 292 293 def test_skip_build_check_short(self): 294 """Test -s option""" 295 runCmd("wic create wictestdisk " 296 "--image-name=core-image-minimal " 297 "-s -o %s" % self.resultdir) 298 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 299 300 def test_skip_build_check_long(self): 301 """Test --skip-build-check option""" 302 runCmd("wic create wictestdisk " 303 "--image-name=core-image-minimal " 304 "--skip-build-check " 305 "--outdir %s" % self.resultdir) 306 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 307 308 def test_build_rootfs_short(self): 309 """Test -f option""" 310 runCmd("wic create wictestdisk " 311 "--image-name=core-image-minimal " 312 "-f -o %s" % self.resultdir) 313 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 314 315 def test_build_rootfs_long(self): 316 """Test --build-rootfs option""" 317 runCmd("wic create wictestdisk " 318 "--image-name=core-image-minimal " 319 "--build-rootfs " 320 "--outdir %s" % self.resultdir) 321 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 322 323 @only_for_arch(['i586', 'i686', 'x86_64']) 324 def test_rootfs_indirect_recipes(self): 325 """Test usage of rootfs plugin with rootfs recipes""" 326 runCmd("wic create directdisk-multi-rootfs " 327 "--image-name=core-image-minimal " 328 "--rootfs rootfs1=core-image-minimal " 329 "--rootfs rootfs2=core-image-minimal " 330 "--outdir %s" % self.resultdir) 331 self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) 332 333 @only_for_arch(['i586', 'i686', 'x86_64']) 334 def test_rootfs_artifacts(self): 335 """Test usage of rootfs plugin with rootfs paths""" 336 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 337 'wic-tools') 338 bb_vars.update(get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_ROOTFS'], 339 'core-image-minimal')) 340 bbvars = {key.lower(): value for key, value in bb_vars.items()} 341 bbvars['wks'] = "directdisk-multi-rootfs" 342 bbvars['resultdir'] = self.resultdir 343 runCmd("wic create %(wks)s " 344 "--bootimg-dir=%(staging_datadir)s " 345 "--kernel-dir=%(deploy_dir_image)s " 346 "--native-sysroot=%(recipe_sysroot_native)s " 347 "--rootfs-dir rootfs1=%(image_rootfs)s " 348 "--rootfs-dir rootfs2=%(image_rootfs)s " 349 "--outdir %(resultdir)s" % bbvars) 350 self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) 351 352 def test_exclude_path(self): 353 """Test --exclude-path wks option.""" 354 355 oldpath = os.environ['PATH'] 356 os.environ['PATH'] = get_bb_var("PATH", "wic-tools") 357 358 try: 359 wks_file = 'temp.wks' 360 with open(wks_file, 'w') as wks: 361 rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal') 362 wks.write(""" 363part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr 364part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr 365part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr""" 366 % (rootfs_dir, rootfs_dir)) 367 runCmd("wic create %s -e core-image-minimal -o %s" \ 368 % (wks_file, self.resultdir)) 369 370 os.remove(wks_file) 371 wicout = glob(self.resultdir + "%s-*direct" % 'temp') 372 self.assertEqual(1, len(wicout)) 373 374 wicimg = wicout[0] 375 376 # verify partition size with wic 377 res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg) 378 379 # parse parted output which looks like this: 380 # BYT;\n 381 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n 382 # 1:0.00MiB:200MiB:200MiB:ext4::;\n 383 partlns = res.output.splitlines()[2:] 384 385 self.assertEqual(3, len(partlns)) 386 387 for part in [1, 2, 3]: 388 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part) 389 partln = partlns[part-1].split(":") 390 self.assertEqual(7, len(partln)) 391 start = int(partln[1].rstrip("B")) / 512 392 length = int(partln[3].rstrip("B")) / 512 393 runCmd("dd if=%s of=%s skip=%d count=%d" % 394 (wicimg, part_file, start, length)) 395 396 def extract_files(debugfs_output): 397 """ 398 extract file names from the output of debugfs -R 'ls -p', 399 which looks like this: 400 401 /2/040755/0/0/.//\n 402 /2/040755/0/0/..//\n 403 /11/040700/0/0/lost+found^M//\n 404 /12/040755/1002/1002/run//\n 405 /13/040755/1002/1002/sys//\n 406 /14/040755/1002/1002/bin//\n 407 /80/040755/1002/1002/var//\n 408 /92/040755/1002/1002/tmp//\n 409 """ 410 # NOTE the occasional ^M in file names 411 return [line.split('/')[5].strip() for line in \ 412 debugfs_output.strip().split('/\n')] 413 414 # Test partition 1, should contain the normal root directories, except 415 # /usr. 416 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 417 os.path.join(self.resultdir, "selftest_img.part1")) 418 files = extract_files(res.output) 419 self.assertIn("etc", files) 420 self.assertNotIn("usr", files) 421 422 # Partition 2, should contain common directories for /usr, not root 423 # directories. 424 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 425 os.path.join(self.resultdir, "selftest_img.part2")) 426 files = extract_files(res.output) 427 self.assertNotIn("etc", files) 428 self.assertNotIn("usr", files) 429 self.assertIn("share", files) 430 431 # Partition 3, should contain the same as partition 2, including the bin 432 # directory, but not the files inside it. 433 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 434 os.path.join(self.resultdir, "selftest_img.part3")) 435 files = extract_files(res.output) 436 self.assertNotIn("etc", files) 437 self.assertNotIn("usr", files) 438 self.assertIn("share", files) 439 self.assertIn("bin", files) 440 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % \ 441 os.path.join(self.resultdir, "selftest_img.part3")) 442 files = extract_files(res.output) 443 self.assertIn(".", files) 444 self.assertIn("..", files) 445 self.assertEqual(2, len(files)) 446 447 for part in [1, 2, 3]: 448 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part) 449 os.remove(part_file) 450 451 finally: 452 os.environ['PATH'] = oldpath 453 454 def test_exclude_path_errors(self): 455 """Test --exclude-path wks option error handling.""" 456 wks_file = 'temp.wks' 457 458 # Absolute argument. 459 with open(wks_file, 'w') as wks: 460 wks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path /usr") 461 self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ 462 % (wks_file, self.resultdir), ignore_status=True).status) 463 os.remove(wks_file) 464 465 # Argument pointing to parent directory. 466 with open(wks_file, 'w') as wks: 467 wks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path ././..") 468 self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ 469 % (wks_file, self.resultdir), ignore_status=True).status) 470 os.remove(wks_file) 471 472class Wic2(WicTestCase): 473 474 def test_bmap_short(self): 475 """Test generation of .bmap file -m option""" 476 cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir 477 runCmd(cmd) 478 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 479 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) 480 481 def test_bmap_long(self): 482 """Test generation of .bmap file --bmap option""" 483 cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir 484 runCmd(cmd) 485 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 486 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) 487 488 def test_image_env(self): 489 """Test generation of <image>.env files.""" 490 image = 'core-image-minimal' 491 imgdatadir = self._get_image_env_path(image) 492 493 bb_vars = get_bb_vars(['IMAGE_BASENAME', 'WICVARS'], image) 494 basename = bb_vars['IMAGE_BASENAME'] 495 self.assertEqual(basename, image) 496 path = os.path.join(imgdatadir, basename) + '.env' 497 self.assertTrue(os.path.isfile(path)) 498 499 wicvars = set(bb_vars['WICVARS'].split()) 500 # filter out optional variables 501 wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES', 502 'INITRD', 'INITRD_LIVE', 'ISODIR','INITRAMFS_IMAGE', 503 'INITRAMFS_IMAGE_BUNDLE', 'INITRAMFS_LINK_NAME')) 504 with open(path) as envfile: 505 content = dict(line.split("=", 1) for line in envfile) 506 # test if variables used by wic present in the .env file 507 for var in wicvars: 508 self.assertTrue(var in content, "%s is not in .env file" % var) 509 self.assertTrue(content[var]) 510 511 def test_image_vars_dir_short(self): 512 """Test image vars directory selection -v option""" 513 image = 'core-image-minimal' 514 imgenvdir = self._get_image_env_path(image) 515 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 516 517 runCmd("wic create wictestdisk " 518 "--image-name=%s -v %s -n %s -o %s" 519 % (image, imgenvdir, native_sysroot, 520 self.resultdir)) 521 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 522 523 def test_image_vars_dir_long(self): 524 """Test image vars directory selection --vars option""" 525 image = 'core-image-minimal' 526 imgenvdir = self._get_image_env_path(image) 527 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 528 529 runCmd("wic create wictestdisk " 530 "--image-name=%s " 531 "--vars %s " 532 "--native-sysroot %s " 533 "--outdir %s" 534 % (image, imgenvdir, native_sysroot, 535 self.resultdir)) 536 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 537 538 @only_for_arch(['i586', 'i686', 'x86_64']) 539 def test_wic_image_type(self): 540 """Test building wic images by bitbake""" 541 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 542 'MACHINE_FEATURES_append = " efi"\n' 543 self.append_config(config) 544 self.assertEqual(0, bitbake('wic-image-minimal').status) 545 self.remove_config(config) 546 547 bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) 548 deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] 549 machine = bb_vars['MACHINE'] 550 prefix = os.path.join(deploy_dir, 'wic-image-minimal-%s.' % machine) 551 # check if we have result image and manifests symlinks 552 # pointing to existing files 553 for suffix in ('wic', 'manifest'): 554 path = prefix + suffix 555 self.assertTrue(os.path.islink(path)) 556 self.assertTrue(os.path.isfile(os.path.realpath(path))) 557 558 @only_for_arch(['i586', 'i686', 'x86_64']) 559 def test_qemu(self): 560 """Test wic-image-minimal under qemu""" 561 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 562 'MACHINE_FEATURES_append = " efi"\n' 563 self.append_config(config) 564 self.assertEqual(0, bitbake('wic-image-minimal').status) 565 self.remove_config(config) 566 567 with runqemu('wic-image-minimal', ssh=False) as qemu: 568 cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' " \ 569 "-e '/dev/root /|/dev/sda2 /' -e '/dev/sda3 /media' -e '/dev/sda4 /mnt'" 570 status, output = qemu.run_serial(cmd) 571 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 572 self.assertEqual(output, '4') 573 cmd = "grep UUID= /etc/fstab" 574 status, output = qemu.run_serial(cmd) 575 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 576 self.assertEqual(output, 'UUID=2c71ef06-a81d-4735-9d3a-379b69c6bdba\t/media\text4\tdefaults\t0\t0') 577 578 @only_for_arch(['i586', 'i686', 'x86_64']) 579 def test_qemu_efi(self): 580 """Test core-image-minimal efi image under qemu""" 581 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n' 582 self.append_config(config) 583 self.assertEqual(0, bitbake('core-image-minimal ovmf').status) 584 self.remove_config(config) 585 586 with runqemu('core-image-minimal', ssh=False, 587 runqemuparams='ovmf', image_fstype='wic') as qemu: 588 cmd = "grep sda. /proc/partitions |wc -l" 589 status, output = qemu.run_serial(cmd) 590 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 591 self.assertEqual(output, '3') 592 593 @staticmethod 594 def _make_fixed_size_wks(size): 595 """ 596 Create a wks of an image with a single partition. Size of the partition is set 597 using --fixed-size flag. Returns a tuple: (path to wks file, wks image name) 598 """ 599 with NamedTemporaryFile("w", suffix=".wks", delete=False) as tempf: 600 wkspath = tempf.name 601 tempf.write("part " \ 602 "--source rootfs --ondisk hda --align 4 --fixed-size %d " 603 "--fstype=ext4\n" % size) 604 wksname = os.path.splitext(os.path.basename(wkspath))[0] 605 606 return wkspath, wksname 607 608 def test_fixed_size(self): 609 """ 610 Test creation of a simple image with partition size controlled through 611 --fixed-size flag 612 """ 613 wkspath, wksname = Wic2._make_fixed_size_wks(200) 614 615 runCmd("wic create %s -e core-image-minimal -o %s" \ 616 % (wkspath, self.resultdir)) 617 os.remove(wkspath) 618 wicout = glob(self.resultdir + "%s-*direct" % wksname) 619 self.assertEqual(1, len(wicout)) 620 621 wicimg = wicout[0] 622 623 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 624 625 # verify partition size with wic 626 res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg, 627 native_sysroot=native_sysroot) 628 629 # parse parted output which looks like this: 630 # BYT;\n 631 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n 632 # 1:0.00MiB:200MiB:200MiB:ext4::;\n 633 partlns = res.output.splitlines()[2:] 634 635 self.assertEqual(1, len(partlns)) 636 self.assertEqual("1:0.00MiB:200MiB:200MiB:ext4::;", partlns[0]) 637 638 def test_fixed_size_error(self): 639 """ 640 Test creation of a simple image with partition size controlled through 641 --fixed-size flag. The size of partition is intentionally set to 1MiB 642 in order to trigger an error in wic. 643 """ 644 wkspath, wksname = Wic2._make_fixed_size_wks(1) 645 646 self.assertEqual(1, runCmd("wic create %s -e core-image-minimal -o %s" \ 647 % (wkspath, self.resultdir), ignore_status=True).status) 648 os.remove(wkspath) 649 wicout = glob(self.resultdir + "%s-*direct" % wksname) 650 self.assertEqual(0, len(wicout)) 651 652 @only_for_arch(['i586', 'i686', 'x86_64']) 653 def test_rawcopy_plugin_qemu(self): 654 """Test rawcopy plugin in qemu""" 655 # build ext4 and wic images 656 for fstype in ("ext4", "wic"): 657 config = 'IMAGE_FSTYPES = "%s"\nWKS_FILE = "test_rawcopy_plugin.wks.in"\n' % fstype 658 self.append_config(config) 659 self.assertEqual(0, bitbake('core-image-minimal').status) 660 self.remove_config(config) 661 662 with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu: 663 cmd = "grep sda. /proc/partitions |wc -l" 664 status, output = qemu.run_serial(cmd) 665 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 666 self.assertEqual(output, '2') 667 668 def test_rawcopy_plugin(self): 669 """Test rawcopy plugin""" 670 img = 'core-image-minimal' 671 machine = get_bb_var('MACHINE', img) 672 with NamedTemporaryFile("w", suffix=".wks") as wks: 673 wks.writelines(['part /boot --active --source bootimg-pcbios\n', 674 'part / --source rawcopy --sourceparams="file=%s-%s.ext4" --use-uuid\n'\ 675 % (img, machine), 676 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) 677 wks.flush() 678 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 679 runCmd(cmd) 680 wksname = os.path.splitext(os.path.basename(wks.name))[0] 681 out = glob(self.resultdir + "%s-*direct" % wksname) 682 self.assertEqual(1, len(out)) 683 684 @only_for_arch(['i586', 'i686', 'x86_64']) 685 def test_biosplusefi_plugin_qemu(self): 686 """Test biosplusefi plugin in qemu""" 687 for fstype in ("ext4", "wic"): 688 config = 'IMAGE_FSTYPES = "%s"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' % fstype 689 self.append_config(config) 690 self.assertEqual(0, bitbake('core-image-minimal').status) 691 self.remove_config(config) 692 693 with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu: 694 # Check that we have ONLY two /dev/sda* partitions (/boot and /) 695 cmd = "grep sda. /proc/partitions | wc -l" 696 status, output = qemu.run_serial(cmd) 697 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 698 self.assertEqual(output, '2') 699 # Check that /dev/sda1 is /boot and that either /dev/root OR /dev/sda2 is / 700 cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' -e '/dev/root /|/dev/sda2 /'" 701 status, output = qemu.run_serial(cmd) 702 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 703 self.assertEqual(output, '2') 704 # Check that /boot has EFI bootx64.efi (required for EFI) 705 cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l" 706 status, output = qemu.run_serial(cmd) 707 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 708 self.assertEqual(output, '1') 709 # Check that "BOOTABLE" flag is set on boot partition (required for PC-Bios) 710 # Trailing "cat" seems to be required; otherwise run_serial() sends back echo of the input command 711 cmd = "fdisk -l /dev/sda | grep /dev/sda1 | awk {print'$2'} | cat" 712 status, output = qemu.run_serial(cmd) 713 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 714 self.assertEqual(output, '*') 715 716 @only_for_arch(['i586', 'i686', 'x86_64']) 717 def test_biosplusefi_plugin(self): 718 """Test biosplusefi plugin""" 719 # Wic generation below may fail depending on the order of the unittests 720 # This is because bootimg-pcbios (that bootimg-biosplusefi uses) generate its MBR inside STAGING_DATADIR directory 721 # which may or may not exists depending on what was built already 722 # If an image hasn't been built yet, directory ${STAGING_DATADIR}/syslinux won't exists and _get_bootimg_dir() 723 # will raise with "Couldn't find correct bootimg_dir" 724 # The easiest way to work-around this issue is to make sure we already built an image here, hence the bitbake call 725 for fstype in ("ext4", "wic"): 726 config = 'IMAGE_FSTYPES = "%s"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' % fstype 727 self.append_config(config) 728 self.assertEqual(0, bitbake('core-image-minimal').status) 729 self.remove_config(config) 730 731 img = 'core-image-minimal' 732 with NamedTemporaryFile("w", suffix=".wks") as wks: 733 wks.writelines(['part /boot --active --source bootimg-biosplusefi --sourceparams="loader=grub-efi"\n', 734 'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\ 735 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) 736 wks.flush() 737 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 738 runCmd(cmd) 739 wksname = os.path.splitext(os.path.basename(wks.name))[0] 740 out = glob(self.resultdir + "%s-*.direct" % wksname) 741 self.assertEqual(1, len(out)) 742 743 def test_fs_types(self): 744 """Test filesystem types for empty and not empty partitions""" 745 img = 'core-image-minimal' 746 with NamedTemporaryFile("w", suffix=".wks") as wks: 747 wks.writelines(['part ext2 --fstype ext2 --source rootfs\n', 748 'part btrfs --fstype btrfs --source rootfs --size 40M\n', 749 'part squash --fstype squashfs --source rootfs\n', 750 'part swap --fstype swap --size 1M\n', 751 'part emptyvfat --fstype vfat --size 1M\n', 752 'part emptymsdos --fstype msdos --size 1M\n', 753 'part emptyext2 --fstype ext2 --size 1M\n', 754 'part emptybtrfs --fstype btrfs --size 150M\n']) 755 wks.flush() 756 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 757 runCmd(cmd) 758 wksname = os.path.splitext(os.path.basename(wks.name))[0] 759 out = glob(self.resultdir + "%s-*direct" % wksname) 760 self.assertEqual(1, len(out)) 761 762 def test_kickstart_parser(self): 763 """Test wks parser options""" 764 with NamedTemporaryFile("w", suffix=".wks") as wks: 765 wks.writelines(['part / --fstype ext3 --source rootfs --system-id 0xFF '\ 766 '--overhead-factor 1.2 --size 100k\n']) 767 wks.flush() 768 cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) 769 runCmd(cmd) 770 wksname = os.path.splitext(os.path.basename(wks.name))[0] 771 out = glob(self.resultdir + "%s-*direct" % wksname) 772 self.assertEqual(1, len(out)) 773 774 def test_image_bootpart_globbed(self): 775 """Test globbed sources with image-bootpart plugin""" 776 img = "core-image-minimal" 777 cmd = "wic create sdimage-bootpart -e %s -o %s" % (img, self.resultdir) 778 config = 'IMAGE_BOOT_FILES = "%s*"' % get_bb_var('KERNEL_IMAGETYPE', img) 779 self.append_config(config) 780 runCmd(cmd) 781 self.remove_config(config) 782 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 783 784 def test_sparse_copy(self): 785 """Test sparse_copy with FIEMAP and SEEK_HOLE filemap APIs""" 786 libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'wic') 787 sys.path.insert(0, libpath) 788 from filemap import FilemapFiemap, FilemapSeek, sparse_copy, ErrorNotSupp 789 with NamedTemporaryFile("w", suffix=".wic-sparse") as sparse: 790 src_name = sparse.name 791 src_size = 1024 * 10 792 sparse.truncate(src_size) 793 # write one byte to the file 794 with open(src_name, 'r+b') as sfile: 795 sfile.seek(1024 * 4) 796 sfile.write(b'\x00') 797 dest = sparse.name + '.out' 798 # copy src file to dest using different filemap APIs 799 for api in (FilemapFiemap, FilemapSeek, None): 800 if os.path.exists(dest): 801 os.unlink(dest) 802 try: 803 sparse_copy(sparse.name, dest, api=api) 804 except ErrorNotSupp: 805 continue # skip unsupported API 806 dest_stat = os.stat(dest) 807 self.assertEqual(dest_stat.st_size, src_size) 808 # 8 blocks is 4K (physical sector size) 809 self.assertEqual(dest_stat.st_blocks, 8) 810 os.unlink(dest) 811 812 def test_wic_ls(self): 813 """Test listing image content using 'wic ls'""" 814 runCmd("wic create wictestdisk " 815 "--image-name=core-image-minimal " 816 "-D -o %s" % self.resultdir) 817 images = glob(self.resultdir + "wictestdisk-*.direct") 818 self.assertEqual(1, len(images)) 819 820 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 821 822 # list partitions 823 result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) 824 self.assertEqual(3, len(result.output.split('\n'))) 825 826 # list directory content of the first partition 827 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 828 self.assertEqual(6, len(result.output.split('\n'))) 829 830 def test_wic_cp(self): 831 """Test copy files and directories to the the wic image.""" 832 runCmd("wic create wictestdisk " 833 "--image-name=core-image-minimal " 834 "-D -o %s" % self.resultdir) 835 images = glob(self.resultdir + "wictestdisk-*.direct") 836 self.assertEqual(1, len(images)) 837 838 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 839 840 # list directory content of the first partition 841 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 842 self.assertEqual(6, len(result.output.split('\n'))) 843 844 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: 845 testfile.write("test") 846 847 # copy file to the partition 848 runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot)) 849 850 # check if file is there 851 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 852 self.assertEqual(7, len(result.output.split('\n'))) 853 self.assertTrue(os.path.basename(testfile.name) in result.output) 854 855 # prepare directory 856 testdir = os.path.join(self.resultdir, 'wic-test-cp-dir') 857 testsubdir = os.path.join(testdir, 'subdir') 858 os.makedirs(os.path.join(testsubdir)) 859 copy(testfile.name, testdir) 860 861 # copy directory to the partition 862 runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot)) 863 864 # check if directory is there 865 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 866 self.assertEqual(8, len(result.output.split('\n'))) 867 self.assertTrue(os.path.basename(testdir) in result.output) 868 869 def test_wic_rm(self): 870 """Test removing files and directories from the the wic image.""" 871 runCmd("wic create mkefidisk " 872 "--image-name=core-image-minimal " 873 "-D -o %s" % self.resultdir) 874 images = glob(self.resultdir + "mkefidisk-*.direct") 875 self.assertEqual(1, len(images)) 876 877 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 878 879 # list directory content of the first partition 880 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 881 self.assertIn('\nBZIMAGE ', result.output) 882 self.assertIn('\nEFI <DIR> ', result.output) 883 884 # remove file 885 runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) 886 887 # remove directory 888 runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot)) 889 890 # check if they're removed 891 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 892 self.assertNotIn('\nBZIMAGE ', result.output) 893 self.assertNotIn('\nEFI <DIR> ', result.output) 894 895 def test_mkfs_extraopts(self): 896 """Test wks option --mkfs-extraopts for empty and not empty partitions""" 897 img = 'core-image-minimal' 898 with NamedTemporaryFile("w", suffix=".wks") as wks: 899 wks.writelines( 900 ['part ext2 --fstype ext2 --source rootfs --mkfs-extraopts "-D -F -i 8192"\n', 901 "part btrfs --fstype btrfs --source rootfs --size 40M --mkfs-extraopts='--quiet'\n", 902 'part squash --fstype squashfs --source rootfs --mkfs-extraopts "-no-sparse -b 4096"\n', 903 'part emptyvfat --fstype vfat --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', 904 'part emptymsdos --fstype msdos --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', 905 'part emptyext2 --fstype ext2 --size 1M --mkfs-extraopts "-D -F -i 8192"\n', 906 'part emptybtrfs --fstype btrfs --size 100M --mkfs-extraopts "--mixed -K"\n']) 907 wks.flush() 908 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 909 runCmd(cmd) 910 wksname = os.path.splitext(os.path.basename(wks.name))[0] 911 out = glob(self.resultdir + "%s-*direct" % wksname) 912 self.assertEqual(1, len(out)) 913 914 def test_expand_mbr_image(self): 915 """Test wic write --expand command for mbr image""" 916 # build an image 917 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "directdisk.wks"\n' 918 self.append_config(config) 919 self.assertEqual(0, bitbake('core-image-minimal').status) 920 921 # get path to the image 922 bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) 923 deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] 924 machine = bb_vars['MACHINE'] 925 image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) 926 927 self.remove_config(config) 928 929 try: 930 # expand image to 1G 931 new_image_path = None 932 with NamedTemporaryFile(mode='wb', suffix='.wic.exp', 933 dir=deploy_dir, delete=False) as sparse: 934 sparse.truncate(1024 ** 3) 935 new_image_path = sparse.name 936 937 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 938 cmd = "wic write -n %s --expand 1:0 %s %s" % (sysroot, image_path, new_image_path) 939 runCmd(cmd) 940 941 # check if partitions are expanded 942 orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) 943 exp = runCmd("wic ls %s -n %s" % (new_image_path, sysroot)) 944 orig_sizes = [int(line.split()[3]) for line in orig.output.split('\n')[1:]] 945 exp_sizes = [int(line.split()[3]) for line in exp.output.split('\n')[1:]] 946 self.assertEqual(orig_sizes[0], exp_sizes[0]) # first partition is not resized 947 self.assertTrue(orig_sizes[1] < exp_sizes[1]) 948 949 # Check if all free space is partitioned 950 result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path)) 951 self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output) 952 953 os.rename(image_path, image_path + '.bak') 954 os.rename(new_image_path, image_path) 955 956 # Check if it boots in qemu 957 with runqemu('core-image-minimal', ssh=False) as qemu: 958 cmd = "ls /etc/" 959 status, output = qemu.run_serial('true') 960 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 961 finally: 962 if os.path.exists(new_image_path): 963 os.unlink(new_image_path) 964 if os.path.exists(image_path + '.bak'): 965 os.rename(image_path + '.bak', image_path) 966 967 def test_wic_ls_ext(self): 968 """Test listing content of the ext partition using 'wic ls'""" 969 runCmd("wic create wictestdisk " 970 "--image-name=core-image-minimal " 971 "-D -o %s" % self.resultdir) 972 images = glob(self.resultdir + "wictestdisk-*.direct") 973 self.assertEqual(1, len(images)) 974 975 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 976 977 # list directory content of the second ext4 partition 978 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 979 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset( 980 set(line.split()[-1] for line in result.output.split('\n') if line))) 981 982 def test_wic_cp_ext(self): 983 """Test copy files and directories to the ext partition.""" 984 runCmd("wic create wictestdisk " 985 "--image-name=core-image-minimal " 986 "-D -o %s" % self.resultdir) 987 images = glob(self.resultdir + "wictestdisk-*.direct") 988 self.assertEqual(1, len(images)) 989 990 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 991 992 # list directory content of the ext4 partition 993 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 994 dirs = set(line.split()[-1] for line in result.output.split('\n') if line) 995 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs)) 996 997 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: 998 testfile.write("test") 999 1000 # copy file to the partition 1001 runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot)) 1002 1003 # check if file is there 1004 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 1005 newdirs = set(line.split()[-1] for line in result.output.split('\n') if line) 1006 self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)])) 1007 1008 def test_wic_rm_ext(self): 1009 """Test removing files from the ext partition.""" 1010 runCmd("wic create mkefidisk " 1011 "--image-name=core-image-minimal " 1012 "-D -o %s" % self.resultdir) 1013 images = glob(self.resultdir + "mkefidisk-*.direct") 1014 self.assertEqual(1, len(images)) 1015 1016 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 1017 1018 # list directory content of the /etc directory on ext4 partition 1019 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1020 self.assertTrue('fstab' in [line.split()[-1] for line in result.output.split('\n') if line]) 1021 1022 # remove file 1023 runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot)) 1024 1025 # check if it's removed 1026 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1027 self.assertTrue('fstab' not in [line.split()[-1] for line in result.output.split('\n') if line]) 1028