diff options
author | Mikko Rapeli <mikko.rapeli@linaro.org> | 2024-10-23 15:08:38 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-10-25 15:12:22 +0100 |
commit | 18c123d8da59a6f8483662cb0977089d7a0736f5 (patch) | |
tree | af6732af6239356bad42aaed7a17f0e24f925412 | |
parent | a7c025cc11731e08bb23a700eabe9faf0c513c30 (diff) | |
download | poky-18c123d8da59a6f8483662cb0977089d7a0736f5.tar.gz |
oeqa selftest wic.py: support UKIs via uki.bbclass
Use label to detect rootfs since UKI with kernel command
line is generated before rootfs is generated by wic.
Adapt wic tests to build and boot uki.bbclass generated
UKIs.
Keeping one UKI test in wic.py and rest of the UKI features
are tested with dedicated uki.py test. Add plain non-UKI
systemd-boot tests to wic suite for aarch64 and x86.
(From OE-Core rev: 3f94256b977637d4276f82db7c20b8b5e57b9d86)
Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta-selftest/wic/test_efi_plugin.wks | 5 | ||||
-rw-r--r-- | meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks | 5 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 120 |
3 files changed, 115 insertions, 15 deletions
diff --git a/meta-selftest/wic/test_efi_plugin.wks b/meta-selftest/wic/test_efi_plugin.wks index 1603d6c4bb..e876a4be0e 100644 --- a/meta-selftest/wic/test_efi_plugin.wks +++ b/meta-selftest/wic/test_efi_plugin.wks | |||
@@ -1,6 +1,5 @@ | |||
1 | # short-description: This file is used in oe-selftest wic module to test efi plugin | 1 | # short-description: This file is used in oe-selftest wic module to test efi plugin |
2 | 2 | part /boot --source bootimg-efi --sourceparams="loader=systemd-boot" --active --align 1024 --use-uuid | |
3 | part /boot --source bootimg-efi --sourceparams="loader=systemd-boot,create-unified-kernel-image=true,initrd=${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES}" --active --align 1024 --use-uuid | 3 | part / --source rootfs --fstype=ext4 --align 1024 --use-uuid --label root |
4 | part / --source rootfs --fstype=ext4 --align 1024 --use-uuid | ||
5 | 4 | ||
6 | bootloader --timeout=0 --append="console=ttyS0,115200n8" | 5 | bootloader --timeout=0 --append="console=ttyS0,115200n8" |
diff --git a/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks b/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks new file mode 100644 index 0000000000..2745c19e85 --- /dev/null +++ b/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks | |||
@@ -0,0 +1,5 @@ | |||
1 | # short-description: This file is used in oe-selftest wic module to test efi plugin | ||
2 | part /boot --source bootimg-efi --sourceparams="loader=systemd-boot,initrd=${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES}" --active --align 1024 --use-uuid | ||
3 | part / --source rootfs --fstype=ext4 --align 1024 --use-uuid | ||
4 | |||
5 | bootloader --timeout=0 --append="console=ttyS0,115200n8" | ||
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index f2a46c965b..9b09be75ec 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
@@ -1292,24 +1292,46 @@ class Wic2(WicTestCase): | |||
1292 | @skipIfNotArch(['i586', 'i686', 'x86_64']) | 1292 | @skipIfNotArch(['i586', 'i686', 'x86_64']) |
1293 | @OETestTag("runqemu") | 1293 | @OETestTag("runqemu") |
1294 | def test_efi_plugin_unified_kernel_image_qemu(self): | 1294 | def test_efi_plugin_unified_kernel_image_qemu(self): |
1295 | """Test efi plugin's Unified Kernel Image feature in qemu""" | 1295 | """Test Unified Kernel Image feature in qemu without systemd in initramfs or rootfs""" |
1296 | config = 'IMAGE_FSTYPES = "wic"\n'\ | 1296 | config = """ |
1297 | 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\ | 1297 | # efi firmware must load systemd-boot, not grub |
1298 | 'WKS_FILE = "test_efi_plugin.wks"\n'\ | 1298 | EFI_PROVIDER = "systemd-boot" |
1299 | 'MACHINE_FEATURES:append = " efi"\n' | 1299 | |
1300 | # image format must be wic, needs esp partition for firmware etc | ||
1301 | IMAGE_FSTYPES:pn-core-image-base:append = " wic" | ||
1302 | WKS_FILE = "test_efi_plugin.wks" | ||
1303 | |||
1304 | # efi, uki and systemd features must be enabled | ||
1305 | MACHINE_FEATURES:append = " efi" | ||
1306 | DISTRO_FEATURES_NATIVE:append = " systemd" | ||
1307 | IMAGE_CLASSES:append:pn-core-image-base = " uki" | ||
1308 | |||
1309 | # uki embeds also an initrd, no systemd or udev | ||
1310 | INITRAMFS_IMAGE = "core-image-initramfs-boot" | ||
1311 | |||
1312 | # runqemu must not load kernel separately, it's in the uki | ||
1313 | QB_KERNEL_ROOT = "" | ||
1314 | QB_DEFAULT_KERNEL = "none" | ||
1315 | |||
1316 | # boot command line provided via uki, not via bootloader | ||
1317 | UKI_CMDLINE = "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" | ||
1318 | |||
1319 | """ | ||
1300 | self.append_config(config) | 1320 | self.append_config(config) |
1301 | bitbake('core-image-minimal core-image-minimal-initramfs ovmf') | 1321 | bitbake('core-image-base ovmf') |
1322 | runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" | ||
1323 | uki_filename = get_bb_var('UKI_FILENAME', 'core-image-base') | ||
1302 | self.remove_config(config) | 1324 | self.remove_config(config) |
1303 | 1325 | ||
1304 | with runqemu('core-image-minimal', ssh=False, | 1326 | with runqemu('core-image-base', ssh=False, |
1305 | runqemuparams='nographic ovmf', image_fstype='wic') as qemu: | 1327 | runqemuparams='%s nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: |
1306 | # Check that /boot has EFI bootx64.efi (required for EFI) | 1328 | # Check that /boot has EFI boot*.efi (required for EFI) |
1307 | cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l" | 1329 | cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" |
1308 | status, output = qemu.run_serial(cmd) | 1330 | status, output = qemu.run_serial(cmd) |
1309 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | 1331 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) |
1310 | self.assertEqual(output, '1') | 1332 | self.assertEqual(output, '1') |
1311 | # Check that /boot has EFI/Linux/linux.efi (required for Unified Kernel Images auto detection) | 1333 | # Check that /boot has EFI/Linux/${UKI_FILENAME} (required for Unified Kernel Images auto detection) |
1312 | cmd = "ls /boot/EFI/Linux/linux.efi | wc -l" | 1334 | cmd = "ls /boot/EFI/Linux/%s | wc -l" % (uki_filename) |
1313 | status, output = qemu.run_serial(cmd) | 1335 | status, output = qemu.run_serial(cmd) |
1314 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | 1336 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) |
1315 | self.assertEqual(output, '1') | 1337 | self.assertEqual(output, '1') |
@@ -1319,6 +1341,80 @@ class Wic2(WicTestCase): | |||
1319 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | 1341 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) |
1320 | self.assertEqual(output, '0') | 1342 | self.assertEqual(output, '0') |
1321 | 1343 | ||
1344 | @skipIfNotArch(['aarch64']) | ||
1345 | @OETestTag("runqemu") | ||
1346 | def test_efi_plugin_plain_systemd_boot_qemu_aarch64(self): | ||
1347 | """Test plain systemd-boot in qemu with systemd""" | ||
1348 | config = """ | ||
1349 | INIT_MANAGER = "systemd" | ||
1350 | EFI_PROVIDER = "systemd-boot" | ||
1351 | |||
1352 | # image format must be wic, needs esp partition for firmware etc | ||
1353 | IMAGE_FSTYPES:pn-core-image-base:append = " wic" | ||
1354 | WKS_FILE = "test_efi_plugin_plain_systemd-boot.wks" | ||
1355 | |||
1356 | INITRAMFS_IMAGE = "core-image-initramfs-boot" | ||
1357 | |||
1358 | # to configure runqemu | ||
1359 | IMAGE_CLASSES += "qemuboot" | ||
1360 | # u-boot efi firmware | ||
1361 | QB_DEFAULT_BIOS = "u-boot.bin" | ||
1362 | # need to use virtio, scsi not supported by u-boot by default | ||
1363 | QB_DRIVE_TYPE = "/dev/vd" | ||
1364 | |||
1365 | # disable kvm, breaks boot | ||
1366 | QEMU_USE_KVM = "" | ||
1367 | |||
1368 | IMAGE_CLASSES:remove = 'testimage' | ||
1369 | """ | ||
1370 | self.append_config(config) | ||
1371 | bitbake('core-image-base u-boot') | ||
1372 | runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" | ||
1373 | self.remove_config(config) | ||
1374 | |||
1375 | with runqemu('core-image-base', ssh=False, | ||
1376 | runqemuparams='%s nographic' % (runqemu_params), image_fstype='wic') as qemu: | ||
1377 | # Check that /boot has EFI boot*.efi (required for EFI) | ||
1378 | cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" | ||
1379 | status, output = qemu.run_serial(cmd) | ||
1380 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | ||
1381 | self.assertEqual(output, '1') | ||
1382 | # Check that boot.conf exists | ||
1383 | cmd = "cat /boot/loader/entries/boot.conf" | ||
1384 | status, output = qemu.run_serial(cmd) | ||
1385 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | ||
1386 | |||
1387 | @skipIfNotArch(['i586', 'i686', 'x86_64']) | ||
1388 | @OETestTag("runqemu") | ||
1389 | def test_efi_plugin_plain_systemd_boot_qemu_x86(self): | ||
1390 | """Test plain systemd-boot to systemd in qemu""" | ||
1391 | config = """ | ||
1392 | INIT_MANAGER = "systemd" | ||
1393 | EFI_PROVIDER = "systemd-boot" | ||
1394 | |||
1395 | # image format must be wic, needs esp partition for firmware etc | ||
1396 | IMAGE_FSTYPES:pn-core-image-base:append = " wic" | ||
1397 | WKS_FILE = "test_efi_plugin_plain_systemd-boot.wks" | ||
1398 | |||
1399 | INITRAMFS_IMAGE = "core-image-initramfs-boot" | ||
1400 | """ | ||
1401 | self.append_config(config) | ||
1402 | bitbake('core-image-base ovmf') | ||
1403 | runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" | ||
1404 | self.remove_config(config) | ||
1405 | |||
1406 | with runqemu('core-image-base', ssh=False, | ||
1407 | runqemuparams='%s nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: | ||
1408 | # Check that /boot has EFI boot*.efi (required for EFI) | ||
1409 | cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" | ||
1410 | status, output = qemu.run_serial(cmd) | ||
1411 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | ||
1412 | self.assertEqual(output, '1') | ||
1413 | # Check that boot.conf exists | ||
1414 | cmd = "cat /boot/loader/entries/boot.conf" | ||
1415 | status, output = qemu.run_serial(cmd) | ||
1416 | self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) | ||
1417 | |||
1322 | def test_fs_types(self): | 1418 | def test_fs_types(self): |
1323 | """Test filesystem types for empty and not empty partitions""" | 1419 | """Test filesystem types for empty and not empty partitions""" |
1324 | img = 'core-image-minimal' | 1420 | img = 'core-image-minimal' |