diff options
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index ab248c5898..4ebcb76cc4 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
| @@ -16,6 +16,7 @@ import hashlib | |||
| 16 | from glob import glob | 16 | from glob import glob |
| 17 | from shutil import rmtree, copy | 17 | from shutil import rmtree, copy |
| 18 | from tempfile import NamedTemporaryFile | 18 | from tempfile import NamedTemporaryFile |
| 19 | from tempfile import TemporaryDirectory | ||
| 19 | 20 | ||
| 20 | from oeqa.selftest.case import OESelftestTestCase | 21 | from oeqa.selftest.case import OESelftestTestCase |
| 21 | from oeqa.core.decorator import OETestTag | 22 | from oeqa.core.decorator import OETestTag |
| @@ -146,6 +147,73 @@ class CLITests(OESelftestTestCase): | |||
| 146 | self.assertEqual(1, runCmd('wic', ignore_status=True).status) | 147 | self.assertEqual(1, runCmd('wic', ignore_status=True).status) |
| 147 | 148 | ||
| 148 | class Wic(WicTestCase): | 149 | class Wic(WicTestCase): |
| 150 | def test_skip_kernel_install(self): | ||
| 151 | """Test the functionality of not installing the kernel in the boot directory using the wic plugin""" | ||
| 152 | # create a temporary file for the WKS content | ||
| 153 | with NamedTemporaryFile("w", suffix=".wks") as wks: | ||
| 154 | wks.write( | ||
| 155 | 'part --source bootimg-efi ' | ||
| 156 | '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" ' | ||
| 157 | '--label boot --active\n' | ||
| 158 | ) | ||
| 159 | wks.flush() | ||
| 160 | # create a temporary directory to extract the disk image to | ||
| 161 | with TemporaryDirectory() as tmpdir: | ||
| 162 | img = 'core-image-minimal' | ||
| 163 | # build the image using the WKS file | ||
| 164 | cmd = "wic create %s -e %s -o %s" % ( | ||
| 165 | wks.name, img, self.resultdir) | ||
| 166 | runCmd(cmd) | ||
| 167 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | ||
| 168 | out = glob(os.path.join( | ||
| 169 | self.resultdir, "%s-*.direct" % wksname)) | ||
| 170 | self.assertEqual(1, len(out)) | ||
| 171 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | ||
| 172 | # extract the content of the disk image to the temporary directory | ||
| 173 | cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot) | ||
| 174 | runCmd(cmd) | ||
| 175 | # check if the kernel is installed or not | ||
| 176 | kimgtype = get_bb_var('KERNEL_IMAGETYPE', img) | ||
| 177 | for file in os.listdir(tmpdir): | ||
| 178 | if file == kimgtype: | ||
| 179 | raise AssertionError( | ||
| 180 | "The kernel image '{}' was found in the partition".format(kimgtype) | ||
| 181 | ) | ||
| 182 | |||
| 183 | def test_kernel_install(self): | ||
| 184 | """Test the installation of the kernel to the boot directory in the wic plugin""" | ||
| 185 | # create a temporary file for the WKS content | ||
| 186 | with NamedTemporaryFile("w", suffix=".wks") as wks: | ||
| 187 | wks.write( | ||
| 188 | 'part --source bootimg-efi ' | ||
| 189 | '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" ' | ||
| 190 | '--label boot --active\n' | ||
| 191 | ) | ||
| 192 | wks.flush() | ||
| 193 | # create a temporary directory to extract the disk image to | ||
| 194 | with TemporaryDirectory() as tmpdir: | ||
| 195 | img = 'core-image-minimal' | ||
| 196 | # build the image using the WKS file | ||
| 197 | cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) | ||
| 198 | runCmd(cmd) | ||
| 199 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | ||
| 200 | out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) | ||
| 201 | self.assertEqual(1, len(out)) | ||
| 202 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | ||
| 203 | # extract the content of the disk image to the temporary directory | ||
| 204 | cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot) | ||
| 205 | runCmd(cmd) | ||
| 206 | # check if the kernel is installed or not | ||
| 207 | kimgtype = get_bb_var('KERNEL_IMAGETYPE', img) | ||
| 208 | found = False | ||
| 209 | for file in os.listdir(tmpdir): | ||
| 210 | if file == kimgtype: | ||
| 211 | found = True | ||
| 212 | break | ||
| 213 | self.assertTrue( | ||
| 214 | found, "The kernel image '{}' was not found in the boot partition".format(kimgtype) | ||
| 215 | ) | ||
| 216 | |||
| 149 | def test_build_image_name(self): | 217 | def test_build_image_name(self): |
| 150 | """Test wic create wictestdisk --image-name=core-image-minimal""" | 218 | """Test wic create wictestdisk --image-name=core-image-minimal""" |
| 151 | cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir | 219 | cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir |
