summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-23 11:12:00 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-25 16:48:27 +0100
commitb84b0733963d1f246fb93819ec246bbbe5852031 (patch)
treea07135c685c8e47b5a5de13dc93e451df4253208
parente3dcd61337fb5f89a3f875ec9dd7551529722feb (diff)
downloadpoky-b84b0733963d1f246fb93819ec246bbbe5852031.tar.gz
selftest/wic: clean up runCmd error code handling
runCmd handles checking exit 0 internally unless specified otherwise and its error messages are much more useful including the failed command output. Clean up the unneeded 0 exit code checks in the wic tests. (From OE-Core rev: 394f7d4efe80e390e2c9b0be5e6d10954395a82b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py192
1 files changed, 82 insertions, 110 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 6793efb62e..cfee9d1e71 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -99,58 +99,58 @@ class Wic(WicTestCase):
99 @OETestID(1552) 99 @OETestID(1552)
100 def test_version(self): 100 def test_version(self):
101 """Test wic --version""" 101 """Test wic --version"""
102 self.assertEqual(0, runCmd('wic --version').status) 102 runCmd('wic --version')
103 103
104 @OETestID(1208) 104 @OETestID(1208)
105 def test_help(self): 105 def test_help(self):
106 """Test wic --help and wic -h""" 106 """Test wic --help and wic -h"""
107 self.assertEqual(0, runCmd('wic --help').status) 107 runCmd('wic --help')
108 self.assertEqual(0, runCmd('wic -h').status) 108 runCmd('wic -h')
109 109
110 @OETestID(1209) 110 @OETestID(1209)
111 def test_createhelp(self): 111 def test_createhelp(self):
112 """Test wic create --help""" 112 """Test wic create --help"""
113 self.assertEqual(0, runCmd('wic create --help').status) 113 runCmd('wic create --help')
114 114
115 @OETestID(1210) 115 @OETestID(1210)
116 def test_listhelp(self): 116 def test_listhelp(self):
117 """Test wic list --help""" 117 """Test wic list --help"""
118 self.assertEqual(0, runCmd('wic list --help').status) 118 runCmd('wic list --help')
119 119
120 @OETestID(1553) 120 @OETestID(1553)
121 def test_help_create(self): 121 def test_help_create(self):
122 """Test wic help create""" 122 """Test wic help create"""
123 self.assertEqual(0, runCmd('wic help create').status) 123 runCmd('wic help create')
124 124
125 @OETestID(1554) 125 @OETestID(1554)
126 def test_help_list(self): 126 def test_help_list(self):
127 """Test wic help list""" 127 """Test wic help list"""
128 self.assertEqual(0, runCmd('wic help list').status) 128 runCmd('wic help list')
129 129
130 @OETestID(1215) 130 @OETestID(1215)
131 def test_help_overview(self): 131 def test_help_overview(self):
132 """Test wic help overview""" 132 """Test wic help overview"""
133 self.assertEqual(0, runCmd('wic help overview').status) 133 runCmd('wic help overview')
134 134
135 @OETestID(1216) 135 @OETestID(1216)
136 def test_help_plugins(self): 136 def test_help_plugins(self):
137 """Test wic help plugins""" 137 """Test wic help plugins"""
138 self.assertEqual(0, runCmd('wic help plugins').status) 138 runCmd('wic help plugins')
139 139
140 @OETestID(1217) 140 @OETestID(1217)
141 def test_help_kickstart(self): 141 def test_help_kickstart(self):
142 """Test wic help kickstart""" 142 """Test wic help kickstart"""
143 self.assertEqual(0, runCmd('wic help kickstart').status) 143 runCmd('wic help kickstart')
144 144
145 @OETestID(1555) 145 @OETestID(1555)
146 def test_list_images(self): 146 def test_list_images(self):
147 """Test wic list images""" 147 """Test wic list images"""
148 self.assertEqual(0, runCmd('wic list images').status) 148 runCmd('wic list images')
149 149
150 @OETestID(1556) 150 @OETestID(1556)
151 def test_list_source_plugins(self): 151 def test_list_source_plugins(self):
152 """Test wic list source-plugins""" 152 """Test wic list source-plugins"""
153 self.assertEqual(0, runCmd('wic list source-plugins').status) 153 runCmd('wic list source-plugins')
154 154
155 @OETestID(1557) 155 @OETestID(1557)
156 def test_listed_images_help(self): 156 def test_listed_images_help(self):
@@ -158,7 +158,7 @@ class Wic(WicTestCase):
158 output = runCmd('wic list images').output 158 output = runCmd('wic list images').output
159 imagelist = [line.split()[0] for line in output.splitlines()] 159 imagelist = [line.split()[0] for line in output.splitlines()]
160 for image in imagelist: 160 for image in imagelist:
161 self.assertEqual(0, runCmd('wic list %s help' % image).status) 161 runCmd('wic list %s help' % image)
162 162
163 @OETestID(1213) 163 @OETestID(1213)
164 def test_unsupported_subcommand(self): 164 def test_unsupported_subcommand(self):
@@ -174,7 +174,7 @@ class Wic(WicTestCase):
174 def test_build_image_name(self): 174 def test_build_image_name(self):
175 """Test wic create wictestdisk --image-name=core-image-minimal""" 175 """Test wic create wictestdisk --image-name=core-image-minimal"""
176 cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir 176 cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
177 self.assertEqual(0, runCmd(cmd).status) 177 runCmd(cmd)
178 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 178 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
179 179
180 @OETestID(1157) 180 @OETestID(1157)
@@ -182,7 +182,7 @@ class Wic(WicTestCase):
182 def test_gpt_image(self): 182 def test_gpt_image(self):
183 """Test creation of core-image-minimal with gpt table and UUID boot""" 183 """Test creation of core-image-minimal with gpt table and UUID boot"""
184 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir 184 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
185 self.assertEqual(0, runCmd(cmd).status) 185 runCmd(cmd)
186 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 186 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
187 187
188 @OETestID(1346) 188 @OETestID(1346)
@@ -196,7 +196,7 @@ class Wic(WicTestCase):
196 bitbake('core-image-minimal core-image-minimal-initramfs') 196 bitbake('core-image-minimal core-image-minimal-initramfs')
197 self.remove_config(config) 197 self.remove_config(config)
198 cmd = "wic create mkhybridiso --image-name core-image-minimal -o %s" % self.resultdir 198 cmd = "wic create mkhybridiso --image-name core-image-minimal -o %s" % self.resultdir
199 self.assertEqual(0, runCmd(cmd).status) 199 runCmd(cmd)
200 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) 200 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct")))
201 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) 201 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso")))
202 202
@@ -205,7 +205,7 @@ class Wic(WicTestCase):
205 def test_qemux86_directdisk(self): 205 def test_qemux86_directdisk(self):
206 """Test creation of qemux-86-directdisk image""" 206 """Test creation of qemux-86-directdisk image"""
207 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir 207 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir
208 self.assertEqual(0, runCmd(cmd).status) 208 runCmd(cmd)
209 self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) 209 self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct")))
210 210
211 @OETestID(1350) 211 @OETestID(1350)
@@ -213,7 +213,7 @@ class Wic(WicTestCase):
213 def test_mkefidisk(self): 213 def test_mkefidisk(self):
214 """Test creation of mkefidisk image""" 214 """Test creation of mkefidisk image"""
215 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir 215 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
216 self.assertEqual(0, runCmd(cmd).status) 216 runCmd(cmd)
217 self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) 217 self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct")))
218 218
219 @OETestID(1385) 219 @OETestID(1385)
@@ -225,7 +225,7 @@ class Wic(WicTestCase):
225 bitbake('core-image-minimal') 225 bitbake('core-image-minimal')
226 self.remove_config(config) 226 self.remove_config(config)
227 cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir 227 cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir
228 self.assertEqual(0, runCmd(cmd).status) 228 runCmd(cmd)
229 self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) 229 self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct")))
230 230
231 @OETestID(1560) 231 @OETestID(1560)
@@ -237,7 +237,7 @@ class Wic(WicTestCase):
237 bitbake('core-image-minimal') 237 bitbake('core-image-minimal')
238 self.remove_config(config) 238 self.remove_config(config)
239 cmd = "wic create systemd-bootdisk -e core-image-minimal -o %s" % self.resultdir 239 cmd = "wic create systemd-bootdisk -e core-image-minimal -o %s" % self.resultdir
240 self.assertEqual(0, runCmd(cmd).status) 240 runCmd(cmd)
241 self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct"))) 241 self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct")))
242 242
243 @OETestID(1561) 243 @OETestID(1561)
@@ -246,7 +246,7 @@ class Wic(WicTestCase):
246 cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir 246 cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir
247 kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') 247 kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal')
248 self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype) 248 self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype)
249 self.assertEqual(0, runCmd(cmd).status) 249 runCmd(cmd)
250 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 250 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
251 251
252 @OETestID(1562) 252 @OETestID(1562)
@@ -260,7 +260,7 @@ class Wic(WicTestCase):
260 bitbake('core-image-minimal') 260 bitbake('core-image-minimal')
261 self.remove_config(config) 261 self.remove_config(config)
262 cmd = "wic create directdisk -e core-image-minimal" 262 cmd = "wic create directdisk -e core-image-minimal"
263 self.assertEqual(0, runCmd(cmd).status) 263 runCmd(cmd)
264 self.assertEqual(1, len(glob("directdisk-*.direct"))) 264 self.assertEqual(1, len(glob("directdisk-*.direct")))
265 265
266 @OETestID(1212) 266 @OETestID(1212)
@@ -273,37 +273,36 @@ class Wic(WicTestCase):
273 'core-image-minimal')) 273 'core-image-minimal'))
274 bbvars = {key.lower(): value for key, value in bb_vars.items()} 274 bbvars = {key.lower(): value for key, value in bb_vars.items()}
275 bbvars['resultdir'] = self.resultdir 275 bbvars['resultdir'] = self.resultdir
276 status = runCmd("wic create directdisk " 276 runCmd("wic create directdisk "
277 "-b %(staging_datadir)s " 277 "-b %(staging_datadir)s "
278 "-k %(deploy_dir_image)s " 278 "-k %(deploy_dir_image)s "
279 "-n %(recipe_sysroot_native)s " 279 "-n %(recipe_sysroot_native)s "
280 "-r %(image_rootfs)s " 280 "-r %(image_rootfs)s "
281 "-o %(resultdir)s" % bbvars).status 281 "-o %(resultdir)s" % bbvars)
282 self.assertEqual(0, status)
283 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 282 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
284 283
285 @OETestID(1264) 284 @OETestID(1264)
286 def test_compress_gzip(self): 285 def test_compress_gzip(self):
287 """Test compressing an image with gzip""" 286 """Test compressing an image with gzip"""
288 self.assertEqual(0, runCmd("wic create wictestdisk " 287 runCmd("wic create wictestdisk "
289 "--image-name core-image-minimal " 288 "--image-name core-image-minimal "
290 "-c gzip -o %s" % self.resultdir).status) 289 "-c gzip -o %s" % self.resultdir)
291 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz"))) 290 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz")))
292 291
293 @OETestID(1265) 292 @OETestID(1265)
294 def test_compress_bzip2(self): 293 def test_compress_bzip2(self):
295 """Test compressing an image with bzip2""" 294 """Test compressing an image with bzip2"""
296 self.assertEqual(0, runCmd("wic create wictestdisk " 295 runCmd("wic create wictestdisk "
297 "--image-name=core-image-minimal " 296 "--image-name=core-image-minimal "
298 "-c bzip2 -o %s" % self.resultdir).status) 297 "-c bzip2 -o %s" % self.resultdir)
299 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2"))) 298 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2")))
300 299
301 @OETestID(1266) 300 @OETestID(1266)
302 def test_compress_xz(self): 301 def test_compress_xz(self):
303 """Test compressing an image with xz""" 302 """Test compressing an image with xz"""
304 self.assertEqual(0, runCmd("wic create wictestdisk " 303 runCmd("wic create wictestdisk "
305 "--image-name=core-image-minimal " 304 "--image-name=core-image-minimal "
306 "--compress-with=xz -o %s" % self.resultdir).status) 305 "--compress-with=xz -o %s" % self.resultdir)
307 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz"))) 306 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz")))
308 307
309 @OETestID(1267) 308 @OETestID(1267)
@@ -317,63 +316,62 @@ class Wic(WicTestCase):
317 @OETestID(1558) 316 @OETestID(1558)
318 def test_debug_short(self): 317 def test_debug_short(self):
319 """Test -D option""" 318 """Test -D option"""
320 self.assertEqual(0, runCmd("wic create wictestdisk " 319 runCmd("wic create wictestdisk "
321 "--image-name=core-image-minimal " 320 "--image-name=core-image-minimal "
322 "-D -o %s" % self.resultdir).status) 321 "-D -o %s" % self.resultdir)
323 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 322 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
324 323
325 @OETestID(1658) 324 @OETestID(1658)
326 def test_debug_long(self): 325 def test_debug_long(self):
327 """Test --debug option""" 326 """Test --debug option"""
328 self.assertEqual(0, runCmd("wic create wictestdisk " 327 runCmd("wic create wictestdisk "
329 "--image-name=core-image-minimal " 328 "--image-name=core-image-minimal "
330 "--debug -o %s" % self.resultdir).status) 329 "--debug -o %s" % self.resultdir)
331 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 330 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
332 331
333 @OETestID(1563) 332 @OETestID(1563)
334 def test_skip_build_check_short(self): 333 def test_skip_build_check_short(self):
335 """Test -s option""" 334 """Test -s option"""
336 self.assertEqual(0, runCmd("wic create wictestdisk " 335 runCmd("wic create wictestdisk "
337 "--image-name=core-image-minimal " 336 "--image-name=core-image-minimal "
338 "-s -o %s" % self.resultdir).status) 337 "-s -o %s" % self.resultdir)
339 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 338 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
340 339
341 @OETestID(1671) 340 @OETestID(1671)
342 def test_skip_build_check_long(self): 341 def test_skip_build_check_long(self):
343 """Test --skip-build-check option""" 342 """Test --skip-build-check option"""
344 self.assertEqual(0, runCmd("wic create wictestdisk " 343 runCmd("wic create wictestdisk "
345 "--image-name=core-image-minimal " 344 "--image-name=core-image-minimal "
346 "--skip-build-check " 345 "--skip-build-check "
347 "--outdir %s" % self.resultdir).status) 346 "--outdir %s" % self.resultdir)
348 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 347 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
349 348
350 @OETestID(1564) 349 @OETestID(1564)
351 def test_build_rootfs_short(self): 350 def test_build_rootfs_short(self):
352 """Test -f option""" 351 """Test -f option"""
353 self.assertEqual(0, runCmd("wic create wictestdisk " 352 runCmd("wic create wictestdisk "
354 "--image-name=core-image-minimal " 353 "--image-name=core-image-minimal "
355 "-f -o %s" % self.resultdir).status) 354 "-f -o %s" % self.resultdir)
356 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 355 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
357 356
358 @OETestID(1656) 357 @OETestID(1656)
359 def test_build_rootfs_long(self): 358 def test_build_rootfs_long(self):
360 """Test --build-rootfs option""" 359 """Test --build-rootfs option"""
361 self.assertEqual(0, runCmd("wic create wictestdisk " 360 runCmd("wic create wictestdisk "
362 "--image-name=core-image-minimal " 361 "--image-name=core-image-minimal "
363 "--build-rootfs " 362 "--build-rootfs "
364 "--outdir %s" % self.resultdir).status) 363 "--outdir %s" % self.resultdir)
365 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 364 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
366 365
367 @OETestID(1268) 366 @OETestID(1268)
368 @only_for_arch(['i586', 'i686', 'x86_64']) 367 @only_for_arch(['i586', 'i686', 'x86_64'])
369 def test_rootfs_indirect_recipes(self): 368 def test_rootfs_indirect_recipes(self):
370 """Test usage of rootfs plugin with rootfs recipes""" 369 """Test usage of rootfs plugin with rootfs recipes"""
371 status = runCmd("wic create directdisk-multi-rootfs " 370 runCmd("wic create directdisk-multi-rootfs "
372 "--image-name=core-image-minimal " 371 "--image-name=core-image-minimal "
373 "--rootfs rootfs1=core-image-minimal " 372 "--rootfs rootfs1=core-image-minimal "
374 "--rootfs rootfs2=core-image-minimal " 373 "--rootfs rootfs2=core-image-minimal "
375 "--outdir %s" % self.resultdir).status 374 "--outdir %s" % self.resultdir)
376 self.assertEqual(0, status)
377 self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) 375 self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct")))
378 376
379 @OETestID(1269) 377 @OETestID(1269)
@@ -387,14 +385,13 @@ class Wic(WicTestCase):
387 bbvars = {key.lower(): value for key, value in bb_vars.items()} 385 bbvars = {key.lower(): value for key, value in bb_vars.items()}
388 bbvars['wks'] = "directdisk-multi-rootfs" 386 bbvars['wks'] = "directdisk-multi-rootfs"
389 bbvars['resultdir'] = self.resultdir 387 bbvars['resultdir'] = self.resultdir
390 status = runCmd("wic create %(wks)s " 388 runCmd("wic create %(wks)s "
391 "--bootimg-dir=%(staging_datadir)s " 389 "--bootimg-dir=%(staging_datadir)s "
392 "--kernel-dir=%(deploy_dir_image)s " 390 "--kernel-dir=%(deploy_dir_image)s "
393 "--native-sysroot=%(recipe_sysroot_native)s " 391 "--native-sysroot=%(recipe_sysroot_native)s "
394 "--rootfs-dir rootfs1=%(image_rootfs)s " 392 "--rootfs-dir rootfs1=%(image_rootfs)s "
395 "--rootfs-dir rootfs2=%(image_rootfs)s " 393 "--rootfs-dir rootfs2=%(image_rootfs)s "
396 "--outdir %(resultdir)s" % bbvars).status 394 "--outdir %(resultdir)s" % bbvars)
397 self.assertEqual(0, status)
398 self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) 395 self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars)))
399 396
400 @OETestID(1661) 397 @OETestID(1661)
@@ -413,8 +410,8 @@ part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr
413part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr 410part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr
414part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr""" 411part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr"""
415 % (rootfs_dir, rootfs_dir)) 412 % (rootfs_dir, rootfs_dir))
416 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ 413 runCmd("wic create %s -e core-image-minimal -o %s" \
417 % (wks_file, self.resultdir)).status) 414 % (wks_file, self.resultdir))
418 415
419 os.remove(wks_file) 416 os.remove(wks_file)
420 wicout = glob(self.resultdir + "%s-*direct" % 'temp') 417 wicout = glob(self.resultdir + "%s-*direct" % 'temp')
@@ -424,7 +421,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
424 421
425 # verify partition size with wic 422 # verify partition size with wic
426 res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg) 423 res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg)
427 self.assertEqual(0, res.status)
428 424
429 # parse parted output which looks like this: 425 # parse parted output which looks like this:
430 # BYT;\n 426 # BYT;\n
@@ -440,8 +436,8 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
440 self.assertEqual(7, len(partln)) 436 self.assertEqual(7, len(partln))
441 start = int(partln[1].rstrip("B")) / 512 437 start = int(partln[1].rstrip("B")) / 512
442 length = int(partln[3].rstrip("B")) / 512 438 length = int(partln[3].rstrip("B")) / 512
443 self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" % 439 runCmd("dd if=%s of=%s skip=%d count=%d" %
444 (wicimg, part_file, start, length)).status) 440 (wicimg, part_file, start, length))
445 441
446 def extract_files(debugfs_output): 442 def extract_files(debugfs_output):
447 """ 443 """
@@ -465,7 +461,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
465 # /usr. 461 # /usr.
466 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 462 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
467 os.path.join(self.resultdir, "selftest_img.part1")) 463 os.path.join(self.resultdir, "selftest_img.part1"))
468 self.assertEqual(0, res.status)
469 files = extract_files(res.output) 464 files = extract_files(res.output)
470 self.assertIn("etc", files) 465 self.assertIn("etc", files)
471 self.assertNotIn("usr", files) 466 self.assertNotIn("usr", files)
@@ -474,7 +469,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
474 # directories. 469 # directories.
475 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 470 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
476 os.path.join(self.resultdir, "selftest_img.part2")) 471 os.path.join(self.resultdir, "selftest_img.part2"))
477 self.assertEqual(0, res.status)
478 files = extract_files(res.output) 472 files = extract_files(res.output)
479 self.assertNotIn("etc", files) 473 self.assertNotIn("etc", files)
480 self.assertNotIn("usr", files) 474 self.assertNotIn("usr", files)
@@ -484,7 +478,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
484 # directory, but not the files inside it. 478 # directory, but not the files inside it.
485 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 479 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
486 os.path.join(self.resultdir, "selftest_img.part3")) 480 os.path.join(self.resultdir, "selftest_img.part3"))
487 self.assertEqual(0, res.status)
488 files = extract_files(res.output) 481 files = extract_files(res.output)
489 self.assertNotIn("etc", files) 482 self.assertNotIn("etc", files)
490 self.assertNotIn("usr", files) 483 self.assertNotIn("usr", files)
@@ -492,7 +485,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
492 self.assertIn("bin", files) 485 self.assertIn("bin", files)
493 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % \ 486 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % \
494 os.path.join(self.resultdir, "selftest_img.part3")) 487 os.path.join(self.resultdir, "selftest_img.part3"))
495 self.assertEqual(0, res.status)
496 files = extract_files(res.output) 488 files = extract_files(res.output)
497 self.assertIn(".", files) 489 self.assertIn(".", files)
498 self.assertIn("..", files) 490 self.assertIn("..", files)
@@ -530,8 +522,7 @@ class Wic2(WicTestCase):
530 def test_bmap_short(self): 522 def test_bmap_short(self):
531 """Test generation of .bmap file -m option""" 523 """Test generation of .bmap file -m option"""
532 cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir 524 cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir
533 status = runCmd(cmd).status 525 runCmd(cmd)
534 self.assertEqual(0, status)
535 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 526 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
536 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) 527 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
537 528
@@ -539,8 +530,7 @@ class Wic2(WicTestCase):
539 def test_bmap_long(self): 530 def test_bmap_long(self):
540 """Test generation of .bmap file --bmap option""" 531 """Test generation of .bmap file --bmap option"""
541 cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir 532 cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir
542 status = runCmd(cmd).status 533 runCmd(cmd)
543 self.assertEqual(0, status)
544 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 534 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
545 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap"))) 535 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
546 536
@@ -584,10 +574,10 @@ class Wic2(WicTestCase):
584 imgenvdir = self._get_image_env_path(image) 574 imgenvdir = self._get_image_env_path(image)
585 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 575 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
586 576
587 self.assertEqual(0, runCmd("wic create wictestdisk " 577 runCmd("wic create wictestdisk "
588 "--image-name=%s -v %s -n %s -o %s" 578 "--image-name=%s -v %s -n %s -o %s"
589 % (image, imgenvdir, native_sysroot, 579 % (image, imgenvdir, native_sysroot,
590 self.resultdir)).status) 580 self.resultdir))
591 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 581 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
592 582
593 @OETestID(1665) 583 @OETestID(1665)
@@ -597,13 +587,13 @@ class Wic2(WicTestCase):
597 imgenvdir = self._get_image_env_path(image) 587 imgenvdir = self._get_image_env_path(image)
598 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 588 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
599 589
600 self.assertEqual(0, runCmd("wic create wictestdisk " 590 runCmd("wic create wictestdisk "
601 "--image-name=%s " 591 "--image-name=%s "
602 "--vars %s " 592 "--vars %s "
603 "--native-sysroot %s " 593 "--native-sysroot %s "
604 "--outdir %s" 594 "--outdir %s"
605 % (image, imgenvdir, native_sysroot, 595 % (image, imgenvdir, native_sysroot,
606 self.resultdir)).status) 596 self.resultdir))
607 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 597 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
608 598
609 @OETestID(1351) 599 @OETestID(1351)
@@ -685,8 +675,8 @@ class Wic2(WicTestCase):
685 """ 675 """
686 wkspath, wksname = Wic2._make_fixed_size_wks(200) 676 wkspath, wksname = Wic2._make_fixed_size_wks(200)
687 677
688 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ 678 runCmd("wic create %s -e core-image-minimal -o %s" \
689 % (wkspath, self.resultdir)).status) 679 % (wkspath, self.resultdir))
690 os.remove(wkspath) 680 os.remove(wkspath)
691 wicout = glob(self.resultdir + "%s-*direct" % wksname) 681 wicout = glob(self.resultdir + "%s-*direct" % wksname)
692 self.assertEqual(1, len(wicout)) 682 self.assertEqual(1, len(wicout))
@@ -750,7 +740,7 @@ class Wic2(WicTestCase):
750 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) 740 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n'])
751 wks.flush() 741 wks.flush()
752 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 742 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
753 self.assertEqual(0, runCmd(cmd).status) 743 runCmd(cmd)
754 wksname = os.path.splitext(os.path.basename(wks.name))[0] 744 wksname = os.path.splitext(os.path.basename(wks.name))[0]
755 out = glob(self.resultdir + "%s-*direct" % wksname) 745 out = glob(self.resultdir + "%s-*direct" % wksname)
756 self.assertEqual(1, len(out)) 746 self.assertEqual(1, len(out))
@@ -770,7 +760,7 @@ class Wic2(WicTestCase):
770 'part emptybtrfs --fstype btrfs --size 150M\n']) 760 'part emptybtrfs --fstype btrfs --size 150M\n'])
771 wks.flush() 761 wks.flush()
772 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 762 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
773 self.assertEqual(0, runCmd(cmd).status) 763 runCmd(cmd)
774 wksname = os.path.splitext(os.path.basename(wks.name))[0] 764 wksname = os.path.splitext(os.path.basename(wks.name))[0]
775 out = glob(self.resultdir + "%s-*direct" % wksname) 765 out = glob(self.resultdir + "%s-*direct" % wksname)
776 self.assertEqual(1, len(out)) 766 self.assertEqual(1, len(out))
@@ -783,7 +773,7 @@ class Wic2(WicTestCase):
783 '--overhead-factor 1.2 --size 100k\n']) 773 '--overhead-factor 1.2 --size 100k\n'])
784 wks.flush() 774 wks.flush()
785 cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) 775 cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir)
786 self.assertEqual(0, runCmd(cmd).status) 776 runCmd(cmd)
787 wksname = os.path.splitext(os.path.basename(wks.name))[0] 777 wksname = os.path.splitext(os.path.basename(wks.name))[0]
788 out = glob(self.resultdir + "%s-*direct" % wksname) 778 out = glob(self.resultdir + "%s-*direct" % wksname)
789 self.assertEqual(1, len(out)) 779 self.assertEqual(1, len(out))
@@ -795,7 +785,7 @@ class Wic2(WicTestCase):
795 cmd = "wic create sdimage-bootpart -e %s -o %s" % (img, self.resultdir) 785 cmd = "wic create sdimage-bootpart -e %s -o %s" % (img, self.resultdir)
796 config = 'IMAGE_BOOT_FILES = "%s*"' % get_bb_var('KERNEL_IMAGETYPE', img) 786 config = 'IMAGE_BOOT_FILES = "%s*"' % get_bb_var('KERNEL_IMAGETYPE', img)
797 self.append_config(config) 787 self.append_config(config)
798 self.assertEqual(0, runCmd(cmd).status) 788 runCmd(cmd)
799 self.remove_config(config) 789 self.remove_config(config)
800 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 790 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
801 791
@@ -831,9 +821,9 @@ class Wic2(WicTestCase):
831 @OETestID(1857) 821 @OETestID(1857)
832 def test_wic_ls(self): 822 def test_wic_ls(self):
833 """Test listing image content using 'wic ls'""" 823 """Test listing image content using 'wic ls'"""
834 self.assertEqual(0, runCmd("wic create wictestdisk " 824 runCmd("wic create wictestdisk "
835 "--image-name=core-image-minimal " 825 "--image-name=core-image-minimal "
836 "-D -o %s" % self.resultdir).status) 826 "-D -o %s" % self.resultdir)
837 images = glob(self.resultdir + "wictestdisk-*.direct") 827 images = glob(self.resultdir + "wictestdisk-*.direct")
838 self.assertEqual(1, len(images)) 828 self.assertEqual(1, len(images))
839 829
@@ -841,20 +831,18 @@ class Wic2(WicTestCase):
841 831
842 # list partitions 832 # list partitions
843 result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) 833 result = runCmd("wic ls %s -n %s" % (images[0], sysroot))
844 self.assertEqual(0, result.status)
845 self.assertEqual(3, len(result.output.split('\n'))) 834 self.assertEqual(3, len(result.output.split('\n')))
846 835
847 # list directory content of the first partition 836 # list directory content of the first partition
848 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 837 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
849 self.assertEqual(0, result.status)
850 self.assertEqual(6, len(result.output.split('\n'))) 838 self.assertEqual(6, len(result.output.split('\n')))
851 839
852 @OETestID(1856) 840 @OETestID(1856)
853 def test_wic_cp(self): 841 def test_wic_cp(self):
854 """Test copy files and directories to the the wic image.""" 842 """Test copy files and directories to the the wic image."""
855 self.assertEqual(0, runCmd("wic create wictestdisk " 843 runCmd("wic create wictestdisk "
856 "--image-name=core-image-minimal " 844 "--image-name=core-image-minimal "
857 "-D -o %s" % self.resultdir).status) 845 "-D -o %s" % self.resultdir)
858 images = glob(self.resultdir + "wictestdisk-*.direct") 846 images = glob(self.resultdir + "wictestdisk-*.direct")
859 self.assertEqual(1, len(images)) 847 self.assertEqual(1, len(images))
860 848
@@ -862,19 +850,16 @@ class Wic2(WicTestCase):
862 850
863 # list directory content of the first partition 851 # list directory content of the first partition
864 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 852 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
865 self.assertEqual(0, result.status)
866 self.assertEqual(6, len(result.output.split('\n'))) 853 self.assertEqual(6, len(result.output.split('\n')))
867 854
868 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile: 855 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile:
869 testfile.write("test") 856 testfile.write("test")
870 857
871 # copy file to the partition 858 # copy file to the partition
872 result = runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot)) 859 runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot))
873 self.assertEqual(0, result.status)
874 860
875 # check if file is there 861 # check if file is there
876 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 862 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
877 self.assertEqual(0, result.status)
878 self.assertEqual(7, len(result.output.split('\n'))) 863 self.assertEqual(7, len(result.output.split('\n')))
879 self.assertTrue(os.path.basename(testfile.name) in result.output) 864 self.assertTrue(os.path.basename(testfile.name) in result.output)
880 865
@@ -885,21 +870,19 @@ class Wic2(WicTestCase):
885 copy(testfile.name, testdir) 870 copy(testfile.name, testdir)
886 871
887 # copy directory to the partition 872 # copy directory to the partition
888 result = runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot)) 873 runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot))
889 self.assertEqual(0, result.status)
890 874
891 # check if directory is there 875 # check if directory is there
892 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 876 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
893 self.assertEqual(0, result.status)
894 self.assertEqual(8, len(result.output.split('\n'))) 877 self.assertEqual(8, len(result.output.split('\n')))
895 self.assertTrue(os.path.basename(testdir) in result.output) 878 self.assertTrue(os.path.basename(testdir) in result.output)
896 879
897 @OETestID(1858) 880 @OETestID(1858)
898 def test_wic_rm(self): 881 def test_wic_rm(self):
899 """Test removing files and directories from the the wic image.""" 882 """Test removing files and directories from the the wic image."""
900 self.assertEqual(0, runCmd("wic create mkefidisk " 883 runCmd("wic create mkefidisk "
901 "--image-name=core-image-minimal " 884 "--image-name=core-image-minimal "
902 "-D -o %s" % self.resultdir).status) 885 "-D -o %s" % self.resultdir)
903 images = glob(self.resultdir + "mkefidisk-*.direct") 886 images = glob(self.resultdir + "mkefidisk-*.direct")
904 self.assertEqual(1, len(images)) 887 self.assertEqual(1, len(images))
905 888
@@ -907,21 +890,17 @@ class Wic2(WicTestCase):
907 890
908 # list directory content of the first partition 891 # list directory content of the first partition
909 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 892 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
910 self.assertEqual(0, result.status)
911 self.assertIn('\nBZIMAGE ', result.output) 893 self.assertIn('\nBZIMAGE ', result.output)
912 self.assertIn('\nEFI <DIR> ', result.output) 894 self.assertIn('\nEFI <DIR> ', result.output)
913 895
914 # remove file 896 # remove file
915 result = runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot)) 897 runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot))
916 self.assertEqual(0, result.status)
917 898
918 # remove directory 899 # remove directory
919 result = runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot)) 900 runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot))
920 self.assertEqual(0, result.status)
921 901
922 # check if they're removed 902 # check if they're removed
923 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot)) 903 result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
924 self.assertEqual(0, result.status)
925 self.assertNotIn('\nBZIMAGE ', result.output) 904 self.assertNotIn('\nBZIMAGE ', result.output)
926 self.assertNotIn('\nEFI <DIR> ', result.output) 905 self.assertNotIn('\nEFI <DIR> ', result.output)
927 906
@@ -940,7 +919,7 @@ class Wic2(WicTestCase):
940 'part emptybtrfs --fstype btrfs --size 100M --mkfs-extraopts "--mixed -K"\n']) 919 'part emptybtrfs --fstype btrfs --size 100M --mkfs-extraopts "--mixed -K"\n'])
941 wks.flush() 920 wks.flush()
942 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) 921 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
943 self.assertEqual(0, runCmd(cmd).status) 922 runCmd(cmd)
944 wksname = os.path.splitext(os.path.basename(wks.name))[0] 923 wksname = os.path.splitext(os.path.basename(wks.name))[0]
945 out = glob(self.resultdir + "%s-*direct" % wksname) 924 out = glob(self.resultdir + "%s-*direct" % wksname)
946 self.assertEqual(1, len(out)) 925 self.assertEqual(1, len(out))
@@ -970,7 +949,7 @@ class Wic2(WicTestCase):
970 949
971 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') 950 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
972 cmd = "wic write -n %s --expand 1:0 %s %s" % (sysroot, image_path, new_image_path) 951 cmd = "wic write -n %s --expand 1:0 %s %s" % (sysroot, image_path, new_image_path)
973 self.assertEqual(0, runCmd(cmd).status) 952 runCmd(cmd)
974 953
975 # check if partitions are expanded 954 # check if partitions are expanded
976 orig = runCmd("wic ls %s -n %s" % (image_path, sysroot)) 955 orig = runCmd("wic ls %s -n %s" % (image_path, sysroot))
@@ -1000,9 +979,9 @@ class Wic2(WicTestCase):
1000 979
1001 def test_wic_ls_ext(self): 980 def test_wic_ls_ext(self):
1002 """Test listing content of the ext partition using 'wic ls'""" 981 """Test listing content of the ext partition using 'wic ls'"""
1003 self.assertEqual(0, runCmd("wic create wictestdisk " 982 runCmd("wic create wictestdisk "
1004 "--image-name=core-image-minimal " 983 "--image-name=core-image-minimal "
1005 "-D -o %s" % self.resultdir).status) 984 "-D -o %s" % self.resultdir)
1006 images = glob(self.resultdir + "wictestdisk-*.direct") 985 images = glob(self.resultdir + "wictestdisk-*.direct")
1007 self.assertEqual(1, len(images)) 986 self.assertEqual(1, len(images))
1008 987
@@ -1010,15 +989,14 @@ class Wic2(WicTestCase):
1010 989
1011 # list directory content of the second ext4 partition 990 # list directory content of the second ext4 partition
1012 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 991 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
1013 self.assertEqual(0, result.status)
1014 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset( 992 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(
1015 set(line.split()[-1] for line in result.output.split('\n') if line))) 993 set(line.split()[-1] for line in result.output.split('\n') if line)))
1016 994
1017 def test_wic_cp_ext(self): 995 def test_wic_cp_ext(self):
1018 """Test copy files and directories to the ext partition.""" 996 """Test copy files and directories to the ext partition."""
1019 self.assertEqual(0, runCmd("wic create wictestdisk " 997 runCmd("wic create wictestdisk "
1020 "--image-name=core-image-minimal " 998 "--image-name=core-image-minimal "
1021 "-D -o %s" % self.resultdir).status) 999 "-D -o %s" % self.resultdir)
1022 images = glob(self.resultdir + "wictestdisk-*.direct") 1000 images = glob(self.resultdir + "wictestdisk-*.direct")
1023 self.assertEqual(1, len(images)) 1001 self.assertEqual(1, len(images))
1024 1002
@@ -1026,7 +1004,6 @@ class Wic2(WicTestCase):
1026 1004
1027 # list directory content of the ext4 partition 1005 # list directory content of the ext4 partition
1028 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 1006 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
1029 self.assertEqual(0, result.status)
1030 dirs = set(line.split()[-1] for line in result.output.split('\n') if line) 1007 dirs = set(line.split()[-1] for line in result.output.split('\n') if line)
1031 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs)) 1008 self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs))
1032 1009
@@ -1034,20 +1011,18 @@ class Wic2(WicTestCase):
1034 testfile.write("test") 1011 testfile.write("test")
1035 1012
1036 # copy file to the partition 1013 # copy file to the partition
1037 result = runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot)) 1014 runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot))
1038 self.assertEqual(0, result.status)
1039 1015
1040 # check if file is there 1016 # check if file is there
1041 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot)) 1017 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
1042 self.assertEqual(0, result.status)
1043 newdirs = set(line.split()[-1] for line in result.output.split('\n') if line) 1018 newdirs = set(line.split()[-1] for line in result.output.split('\n') if line)
1044 self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)])) 1019 self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)]))
1045 1020
1046 def test_wic_rm_ext(self): 1021 def test_wic_rm_ext(self):
1047 """Test removing files from the ext partition.""" 1022 """Test removing files from the ext partition."""
1048 self.assertEqual(0, runCmd("wic create mkefidisk " 1023 runCmd("wic create mkefidisk "
1049 "--image-name=core-image-minimal " 1024 "--image-name=core-image-minimal "
1050 "-D -o %s" % self.resultdir).status) 1025 "-D -o %s" % self.resultdir)
1051 images = glob(self.resultdir + "mkefidisk-*.direct") 1026 images = glob(self.resultdir + "mkefidisk-*.direct")
1052 self.assertEqual(1, len(images)) 1027 self.assertEqual(1, len(images))
1053 1028
@@ -1055,14 +1030,11 @@ class Wic2(WicTestCase):
1055 1030
1056 # list directory content of the /etc directory on ext4 partition 1031 # list directory content of the /etc directory on ext4 partition
1057 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1032 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot))
1058 self.assertEqual(0, result.status)
1059 self.assertTrue('fstab' in [line.split()[-1] for line in result.output.split('\n') if line]) 1033 self.assertTrue('fstab' in [line.split()[-1] for line in result.output.split('\n') if line])
1060 1034
1061 # remove file 1035 # remove file
1062 result = runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot)) 1036 runCmd("wic rm %s:2/etc/fstab -n %s" % (images[0], sysroot))
1063 self.assertEqual(0, result.status)
1064 1037
1065 # check if it's removed 1038 # check if it's removed
1066 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot)) 1039 result = runCmd("wic ls %s:2/etc/ -n %s" % (images[0], sysroot))
1067 self.assertEqual(0, result.status)
1068 self.assertTrue('fstab' not in [line.split()[-1] for line in result.output.split('\n') if line]) 1040 self.assertTrue('fstab' not in [line.split()[-1] for line in result.output.split('\n') if line])