diff options
author | Jair Gonzalez <jair.de.jesus.gonzalez.plascencia@linux.intel.com> | 2016-12-16 16:12:55 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-22 08:46:37 +0000 |
commit | 5ba21836fe3c061a6271f855a9e26c66004d330a (patch) | |
tree | d0ed3eb8304faca85b0305826855b51d3a25667b /meta/lib | |
parent | b53e432206eaba7c6c67e4689c25b5e62d7ee9b2 (diff) | |
download | openembedded-core-5ba21836fe3c061a6271f855a9e26c66004d330a.tar.gz openembedded-core-5ba21836fe3c061a6271f855a9e26c66004d330a.tar.bz2 openembedded-core-5ba21836fe3c061a6271f855a9e26c66004d330a.zip |
selftest/wic: code cleanup
The following changes were added to improve the code readability:
- Removed redundant backlashes between brackets
- Aligned continuation lines according to PEP8 style
- Refactored command execution in the next methods for enhanced
legibility:
- test_build_image_name(self)
- test_gpt_image(self)
- test_qemux86_directdisk(self)
- test_rootfs_indirect_recipes(self)
- test_iso_image(self)
- test_mkgummidisk(self)
- test_mkefidisk(self)
- test_directdisk_bootloader_config(self)
- test_qemu(self)
- test_bmap(self)
- test_systemd_bootdisk(self)
- test_sdimage_bootpart(self)
Signed-off-by: Jair Gonzalez <jair.de.jesus.gonzalez.plascencia@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/wic.py | 107 |
1 files changed, 48 insertions, 59 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 8c7aefa19c..d130ba2658 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -74,16 +74,16 @@ class Wic(oeSelfTest): @testcase(1211) def test_build_image_name(self): """Test wic create directdisk --image-name core-image-minimal""" - self.assertEqual(0, runCmd("wic create directdisk " - "--image-name core-image-minimal").status) + cmd = "wic create directdisk --image-name core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) @testcase(1212) def test_build_artifacts(self): """Test wic create directdisk providing all artifacts.""" - bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \ - for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', - 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) + bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) + for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', + 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) status = runCmd("wic create directdisk " "-b %(staging_datadir)s " "-k %(deploy_dir_image)s " @@ -95,8 +95,8 @@ class Wic(oeSelfTest): @testcase(1157) def test_gpt_image(self): """Test creation of core-image-minimal with gpt table and UUID boot""" - self.assertEqual(0, runCmd("wic create directdisk-gpt " - "--image-name core-image-minimal").status) + cmd = "wic create directdisk-gpt --image-name core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) @testcase(1213) @@ -131,8 +131,7 @@ class Wic(oeSelfTest): self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal " "-c gzip").status) - self.assertEqual(1, len(glob(self.resultdir + \ - "directdisk-*.direct.gz"))) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.gz"))) @testcase(1265) def test_compress_bzip2(self): @@ -140,8 +139,7 @@ class Wic(oeSelfTest): self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal " "-c bzip2").status) - self.assertEqual(1, len(glob(self.resultdir + \ - "directdisk-*.direct.bz2"))) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.bz2"))) @testcase(1266) def test_compress_xz(self): @@ -149,8 +147,7 @@ class Wic(oeSelfTest): self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal " "-c xz").status) - self.assertEqual(1, len(glob(self.resultdir + \ - "directdisk-*.direct.xz"))) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.xz"))) @testcase(1267) def test_wrong_compressor(self): @@ -162,37 +159,35 @@ class Wic(oeSelfTest): @testcase(1268) def test_rootfs_indirect_recipes(self): """Test usage of rootfs plugin with rootfs recipes""" - wks = "directdisk-multi-rootfs" - self.assertEqual(0, runCmd("wic create %s " - "--image-name core-image-minimal " - "--rootfs rootfs1=core-image-minimal " - "--rootfs rootfs2=core-image-minimal" \ - % wks).status) - self.assertEqual(1, len(glob(self.resultdir + "%s*.direct" % wks))) + status = runCmd("wic create directdisk-multi-rootfs " + "--image-name core-image-minimal " + "--rootfs rootfs1=core-image-minimal " + "--rootfs rootfs2=core-image-minimal").status + self.assertEqual(0, status) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) @testcase(1269) def test_rootfs_artifacts(self): """Test usage of rootfs plugin with rootfs paths""" - bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \ - for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', - 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) + bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) + for var in ('STAGING_DATADIR', 'DEPLOY_DIR_IMAGE', + 'STAGING_DIR_NATIVE', 'IMAGE_ROOTFS')) bbvars['wks'] = "directdisk-multi-rootfs" status = runCmd("wic create %(wks)s " "-b %(staging_datadir)s " "-k %(deploy_dir_image)s " "-n %(staging_dir_native)s " "--rootfs-dir rootfs1=%(image_rootfs)s " - "--rootfs-dir rootfs2=%(image_rootfs)s" \ + "--rootfs-dir rootfs2=%(image_rootfs)s" % bbvars).status self.assertEqual(0, status) - self.assertEqual(1, len(glob(self.resultdir + \ - "%(wks)s-*.direct" % bbvars))) + self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) @testcase(1346) def test_iso_image(self): """Test creation of hybrid iso image with legacy and EFI boot""" - self.assertEqual(0, runCmd("wic create mkhybridiso " - "--image-name core-image-minimal").status) + cmd = "wic create mkhybridiso --image-name core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) @@ -238,34 +233,30 @@ class Wic(oeSelfTest): @testcase(1348) def test_qemux86_directdisk(self): """Test creation of qemux-86-directdisk image""" - image = "qemux86-directdisk" - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + cmd = "wic create qemux86-directdisk -e core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) @testcase(1349) def test_mkgummidisk(self): """Test creation of mkgummidisk image""" - image = "mkgummidisk" - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + cmd = "wic create mkgummidisk --image-name core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "mkgummidisk-*direct"))) @testcase(1350) def test_mkefidisk(self): """Test creation of mkefidisk image""" - image = "mkefidisk" - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + cmd = "wic create mkefidisk -e core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) @testcase(1385) def test_directdisk_bootloader_config(self): """Test creation of directdisk-bootloader-config image""" - image = "directdisk-bootloader-config" - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + cmd = "wic create directdisk-bootloader-config -e core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) @testcase(1422) def test_qemu(self): @@ -273,33 +264,31 @@ class Wic(oeSelfTest): self.assertEqual(0, bitbake('wic-image-minimal').status) with runqemu('wic-image-minimal', ssh=False) as qemu: - command = "mount |grep '^/dev/' | cut -f1,3 -d ' '" - status, output = qemu.run_serial(command) - self.assertEqual(1, status, 'Failed to run command "%s": %s' % (command, output)) + cmd = "mount |grep '^/dev/' | cut -f1,3 -d ' '" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt') @testcase(1496) def test_bmap(self): """Test generation of .bmap file""" - image = "directdisk" - status = runCmd("wic create %s -e core-image-minimal --bmap" % image).status + cmd = "wic create directdisk -e core-image-minimal --bmap" + status = runCmd(cmd).status self.assertEqual(0, status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct.bmap" % image))) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct"))) + self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap"))) @testcase(1560) def test_systemd_bootdisk(self): """Test creation of systemd-bootdisk image""" - image = "systemd-bootdisk" - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + cmd = "wic create systemd-bootdisk -e core-image-minimal" + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "systemd-bootdisk-*direct"))) @testcase(1561) def test_sdimage_bootpart(self): """Test creation of sdimage-bootpart image""" - image = "sdimage-bootpart" + cmd = "wic create sdimage-bootpart -e core-image-minimal" self.write_config('IMAGE_BOOT_FILES = "bzImage"\n') - self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ - % image).status) - self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + self.assertEqual(0, runCmd(cmd).status) + self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) |