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 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' 688 self.append_config(config) 689 self.assertEqual(0, bitbake('core-image-minimal').status) 690 self.remove_config(config) 691 692 with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu: 693 # Check that we have ONLY two /dev/sda* partitions (/boot and /) 694 cmd = "grep sda. /proc/partitions | wc -l" 695 status, output = qemu.run_serial(cmd) 696 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 697 self.assertEqual(output, '2') 698 # Check that /dev/sda1 is /boot and that either /dev/root OR /dev/sda2 is / 699 cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' -e '/dev/root /|/dev/sda2 /'" 700 status, output = qemu.run_serial(cmd) 701 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 702 self.assertEqual(output, '2') 703 # Check that /boot has EFI bootx64.efi (required for EFI) 704 cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l" 705 status, output = qemu.run_serial(cmd) 706 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 707 self.assertEqual(output, '1') 708 # Check that "BOOTABLE" flag is set on boot partition (required for PC-Bios) 709 # Trailing "cat" seems to be required; otherwise run_serial() sends back echo of the input command 710 cmd = "fdisk -l /dev/sda | grep /dev/sda1 | awk {print'$2'} | cat" 711 status, output = qemu.run_serial(cmd) 712 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 713 self.assertEqual(output, '*') 714 715 @only_for_arch(['i586', 'i686', 'x86_64']) 716 def test_biosplusefi_plugin(self): 717 """Test biosplusefi plugin""" 718 # Wic generation below may fail depending on the order of the unittests 719 # This is because bootimg-pcbios (that bootimg-biosplusefi uses) generate its MBR inside STAGING_DATADIR directory 720 # which may or may not exists depending on what was built already 721 # If an image hasn't been built yet, directory ${STAGING_DATADIR}/syslinux won't exists and _get_bootimg_dir() 722 # will raise with "Couldn't find correct bootimg_dir" 723 # The easiest way to work-around this issue is to make sure we already built an image here, hence the bitbake call 724 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' 725 self.append_config(config) 726 self.assertEqual(0, bitbake('core-image-minimal').status) 727 self.remove_config(config) 728 729 img = 'core-image-minimal' 730 with NamedTemporaryFile("w", suffix=".wks") as wks: 731 wks.writelines(['part /boot --active --source bootimg-biosplusefi --sourceparams="loader=grub-efi"\n', 732 'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\ 733 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) 734 wks.flush() 735 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 736 runCmd(cmd) 737 wksname = os.path.splitext(os.path.basename(wks.name))[0] 738 out = glob(self.resultdir + "%s-*.direct" % wksname) 739 self.assertEqual(1, len(out)) 740 741 def test_fs_types(self): 742 """Test filesystem types for empty and not empty partitions""" 743 img = 'core-image-minimal' 744 with NamedTemporaryFile("w", suffix=".wks") as wks: 745 wks.writelines(['part ext2 --fstype ext2 --source rootfs\n', 746 'part btrfs --fstype btrfs --source rootfs --size 40M\n', 747 'part squash --fstype squashfs --source rootfs\n', 748 'part swap --fstype swap --size 1M\n', 749 'part emptyvfat --fstype vfat --size 1M\n', 750 'part emptymsdos --fstype msdos --size 1M\n', 751 'part emptyext2 --fstype ext2 --size 1M\n', 752 'part emptybtrfs --fstype btrfs --size 150M\n']) 753 wks.flush() 754 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 755 runCmd(cmd) 756 wksname = os.path.splitext(os.path.basename(wks.name))[0] 757 out = glob(self.resultdir + "%s-*direct" % wksname) 758 self.assertEqual(1, len(out)) 759 760 def test_kickstart_parser(self): 761 """Test wks parser options""" 762 with NamedTemporaryFile("w", suffix=".wks") as wks: 763 wks.writelines(['part / --fstype ext3 --source rootfs --system-id 0xFF '\ 764 '--overhead-factor 1.2 --size 100k\n']) 765 wks.flush() 766 cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) 767 runCmd(cmd) 768 wksname = os.path.splitext(os.path.basename(wks.name))[0] 769 out = glob(self.resultdir + "%s-*direct" % wksname) 770 self.assertEqual(1, len(out)) 771 772 def test_image_bootpart_globbed(self): 773 """Test globbed sources with image-bootpart plugin""" 774 img = "core-image-minimal" 775 cmd = "wic create sdimage-bootpart -e %s -o %s" % (img, self.resultdir) 776 config = 'IMAGE_BOOT_FILES = "%s*"' % get_bb_var('KERNEL_IMAGETYPE', img) 777 self.append_config(config) 778 runCmd(cmd) 779 self.remove_config(config) 780 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 781 782 def test_sparse_copy(self): 783 """Test sparse_copy with FIEMAP and SEEK_HOLE filemap APIs""" 784 libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'wic') 785 sys.path.insert(0, libpath) 786 from filemap import FilemapFiemap, FilemapSeek, sparse_copy, ErrorNotSupp 787 with NamedTemporaryFile("w", suffix=".wic-sparse") as sparse: 788 src_name = sparse.name 789 src_size = 1024 * 10 790 sparse.truncate(src_size) 791 # write one byte to the file 792 with open(src_name, 'r+b') as sfile: 793 sfile.seek(1024 * 4) 794 sfile.write(b'\x00') 795 dest = sparse.name + '.out' 796 # copy src file to dest using different filemap APIs 797 for api in (FilemapFiemap, FilemapSeek, None): 798 if os.path.exists(dest): 799 os.unlink(dest) 800 try: 801 sparse_copy(sparse.name, dest, api=api) 802 except ErrorNotSupp: 803 continue # skip unsupported API 804 dest_stat = os.stat(dest) 805 self.assertEqual(dest_stat.st_size, src_size) 806 # 8 blocks is 4K (physical sector size) 807 self.assertEqual(dest_stat.st_blocks, 8) 808 os.unlink(dest) 809 810 def test_wic_ls(self): 811 """Test listing image content using 'wic ls'""" 812 runCmd("wic create wictestdisk " 813 "--image-name=core-image-minimal " 814 "-D -o %s" % self.resultdir) 815 images = glob(self.resultdir + "wictestdisk-*.direct") 816 self.assertEqual(1, len(images)) 817 818 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 819 820 # list partitions 821 result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) 822 self.assertEqual(3, len(result.output.split('\n'))) 823 824 # list directory content of the first partition 825 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 826 self.assertEqual(6, len(result.output.split('\n'))) 827 828 def test_wic_cp(self): 829 """Test copy files and directories to the the wic image.""" 830 runCmd("wic create wictestdisk " 831 "--image-name=core-image-minimal " 832 "-D -o %s" % self.resultdir) 833 images = glob(self.resultdir + "wictestdisk-*.direct") 834 self.assertEqual(1, len(images)) 835 836 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 837 838 # list directory content of the first partition 839 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 840 self.assertEqual(6, len(result.output.split('\n'))) 841 842 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: 843 testfile.write("test") 844 845 # copy file to the partition 846 runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot)) 847 848 # check if file is there 849 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 850 self.assertEqual(7, len(result.output.split('\n'))) 851 self.assertTrue(os.path.basename(testfile.name) in result.output) 852 853 # prepare directory 854 testdir = os.path.join(self.resultdir, 'wic-test-cp-dir') 855 testsubdir = os.path.join(testdir, 'subdir') 856 os.makedirs(os.path.join(testsubdir)) 857 copy(testfile.name, testdir) 858 859 # copy directory to the partition 860 runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot)) 861 862 # check if directory is there 863 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 864 self.assertEqual(8, len(result.output.split('\n'))) 865 self.assertTrue(os.path.basename(testdir) in result.output) 866 867 def test_wic_rm(self): 868 """Test removing files and directories from the the wic image.""" 869 runCmd("wic create mkefidisk " 870 "--image-name=core-image-minimal " 871 "-D -o %s" % self.resultdir) 872 images = glob(self.resultdir + "mkefidisk-*.direct") 873 self.assertEqual(1, len(images)) 874 875 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 876 877 # list directory content of the first partition 878 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 879 self.assertIn('\nBZIMAGE ', result.output) 880 self.assertIn('\nEFI <DIR> ', result.output) 881 882 # remove file 883 runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) 884 885 # remove directory 886 runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot)) 887 888 # check if they're removed 889 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 890 self.assertNotIn('\nBZIMAGE ', result.output) 891 self.assertNotIn('\nEFI <DIR> ', result.output) 892 893 def test_mkfs_extraopts(self): 894 """Test wks option --mkfs-extraopts for empty and not empty partitions""" 895 img = 'core-image-minimal' 896 with NamedTemporaryFile("w", suffix=".wks") as wks: 897 wks.writelines( 898 ['part ext2 --fstype ext2 --source rootfs --mkfs-extraopts "-D -F -i 8192"\n', 899 "part btrfs --fstype btrfs --source rootfs --size 40M --mkfs-extraopts='--quiet'\n", 900 'part squash --fstype squashfs --source rootfs --mkfs-extraopts "-no-sparse -b 4096"\n', 901 'part emptyvfat --fstype vfat --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', 902 'part emptymsdos --fstype msdos --size 1M --mkfs-extraopts "-S 1024 -s 64"\n', 903 'part emptyext2 --fstype ext2 --size 1M --mkfs-extraopts "-D -F -i 8192"\n', 904 'part emptybtrfs --fstype btrfs --size 100M --mkfs-extraopts "--mixed -K"\n']) 905 wks.flush() 906 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 907 runCmd(cmd) 908 wksname = os.path.splitext(os.path.basename(wks.name))[0] 909 out = glob(self.resultdir + "%s-*direct" % wksname) 910 self.assertEqual(1, len(out)) 911 912 def test_expand_mbr_image(self): 913 """Test wic write --expand command for mbr image""" 914 # build an image 915 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "directdisk.wks"\n' 916 self.append_config(config) 917 self.assertEqual(0, bitbake('core-image-minimal').status) 918 919 # get path to the image 920 bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) 921 deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] 922 machine = bb_vars['MACHINE'] 923 image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) 924 925 self.remove_config(config) 926 927 try: 928 # expand image to 1G 929 new_image_path = None 930 with NamedTemporaryFile(mode='wb', suffix='.wic.exp', 931 dir=deploy_dir, delete=False) as sparse: 932 sparse.truncate(1024 ** 3) 933 new_image_path = sparse.name 934 935 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 936 cmd = "wic write -n %s --expand 1:0 %s %s" % (sysroot, image_path, new_image_path) 937 runCmd(cmd) 938 939 # check if partitions are expanded 940 orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) 941 exp = runCmd("wic ls %s -n %s" % (new_image_path, sysroot)) 942 orig_sizes = [int(line.split()[3]) for line in orig.output.split('\n')[1:]] 943 exp_sizes = [int(line.split()[3]) for line in exp.output.split('\n')[1:]] 944 self.assertEqual(orig_sizes[0], exp_sizes[0]) # first partition is not resized 945 self.assertTrue(orig_sizes[1] < exp_sizes[1]) 946 947 # Check if all free space is partitioned 948 result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path)) 949 self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output) 950 951 os.rename(image_path, image_path + '.bak') 952 os.rename(new_image_path, image_path) 953 954 # Check if it boots in qemu 955 with runqemu('core-image-minimal', ssh=False) as qemu: 956 cmd = "ls /etc/" 957 status, output = qemu.run_serial('true') 958 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 959 finally: 960 if os.path.exists(new_image_path): 961 os.unlink(new_image_path) 962 if os.path.exists(image_path + '.bak'): 963 os.rename(image_path + '.bak', image_path) 964 965 def test_wic_ls_ext(self): 966 """Test listing content of the ext partition using 'wic ls'""" 967 runCmd("wic create wictestdisk " 968 "--image-name=core-image-minimal " 969 "-D -o %s" % self.resultdir) 970 images = glob(self.resultdir + "wictestdisk-*.direct") 971 self.assertEqual(1, len(images)) 972 973 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 974 975 # list directory content of the second ext4 partition 976 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 977 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset( 978 set(line.split()[-1] for line in result.output.split('\n') if line))) 979 980 def test_wic_cp_ext(self): 981 """Test copy files and directories to the ext partition.""" 982 runCmd("wic create wictestdisk " 983 "--image-name=core-image-minimal " 984 "-D -o %s" % self.resultdir) 985 images = glob(self.resultdir + "wictestdisk-*.direct") 986 self.assertEqual(1, len(images)) 987 988 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 989 990 # list directory content of the ext4 partition 991 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 992 dirs = set(line.split()[-1] for line in result.output.split('\n') if line) 993 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs)) 994 995 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: 996 testfile.write("test") 997 998 # copy file to the partition 999 runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot)) 1000 1001 # check if file is there 1002 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 1003 newdirs = set(line.split()[-1] for line in result.output.split('\n') if line) 1004 self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)])) 1005 1006 def test_wic_rm_ext(self): 1007 """Test removing files from the ext partition.""" 1008 runCmd("wic create mkefidisk " 1009 "--image-name=core-image-minimal " 1010 "-D -o %s" % self.resultdir) 1011 images = glob(self.resultdir + "mkefidisk-*.direct") 1012 self.assertEqual(1, len(images)) 1013 1014 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 1015 1016 # list directory content of the /etc directory on ext4 partition 1017 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1018 self.assertTrue('fstab' in [line.split()[-1] for line in result.output.split('\n') if line]) 1019 1020 # remove file 1021 runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot)) 1022 1023 # check if it's removed 1024 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1025 self.assertTrue('fstab' not in [line.split()[-1] for line in result.output.split('\n') if line]) 1026