summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Bourque <wbourque@gmail.com>2019-07-22 20:13:54 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-23 21:26:28 (GMT)
commit835f7eac0610325e906591cd81890bebe8627580 (patch)
tree2a8a3d4fc62dac07f345cd247d1896bc65df6966
parentdef9b64e27974e3bcf0356e76a8d0aa8f01cdc5c (diff)
downloadpoky-2.8_M2.tar.gz
meta/lib/oeqa: Test for bootimg-biosplusefi Source2.8_M2
Add unittests for bootimg-biosplusefi SourcePlugin in wic module. First test check wic creation works correctly. Second test uses qemu to boot image and checks that it has both EFI and BIOS files in a single partition. (From OE-Core rev: e0c3436241afca93f107e325d1b9ffcdebf706cd) Signed-off-by: William Bourque <wbourque@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/wic/test_biosplusefi_plugin.wks6
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py59
2 files changed, 65 insertions, 0 deletions
diff --git a/meta-selftest/wic/test_biosplusefi_plugin.wks b/meta-selftest/wic/test_biosplusefi_plugin.wks
new file mode 100644
index 0000000..5a56c84
--- /dev/null
+++ b/meta-selftest/wic/test_biosplusefi_plugin.wks
@@ -0,0 +1,6 @@
1# short-description: This file is used in oe-selftest wic module to test biosplusefi plugin
2
3part /boot --source bootimg-biosplusefi --sourceparams="loader=grub-efi" --active --align 1024 --use-uuid
4part / --source rootfs --fstype=ext4 --align 1024 --use-uuid
5
6bootloader --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 c390749..928c476 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -681,6 +681,65 @@ class Wic2(WicTestCase):
681 out = glob(self.resultdir + "%s-*direct" % wksname) 681 out = glob(self.resultdir + "%s-*direct" % wksname)
682 self.assertEqual(1, len(out)) 682 self.assertEqual(1, len(out))
683 683
684 @only_for_arch(['i586', 'i686', 'x86_64'])
685 def test_biosplusefi_plugin_qemu(self):
686 """Test biosplusefi plugin in qemu"""
687 for fstype in ("ext4", "wic"):
688 config = 'IMAGE_FSTYPES = "%s"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' % fstype
689 self.append_config(config)
690 self.assertEqual(0, bitbake('core-image-minimal').status)
691 self.remove_config(config)
692
693 with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu:
694 # Check that we have ONLY two /dev/sda* partitions (/boot and /)
695 cmd = "grep sda. /proc/partitions | wc -l"
696 status, output = qemu.run_serial(cmd)
697 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
698 self.assertEqual(output, '2')
699 # Check that /dev/sda1 is /boot and that either /dev/root OR /dev/sda2 is /
700 cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' -e '/dev/root /|/dev/sda2 /'"
701 status, output = qemu.run_serial(cmd)
702 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
703 self.assertEqual(output, '2')
704 # Check that /boot has EFI bootx64.efi (required for EFI)
705 cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l"
706 status, output = qemu.run_serial(cmd)
707 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
708 self.assertEqual(output, '1')
709 # Check that "BOOTABLE" flag is set on boot partition (required for PC-Bios)
710 # Trailing "cat" seems to be required; otherwise run_serial() sends back echo of the input command
711 cmd = "fdisk -l /dev/sda | grep /dev/sda1 | awk {print'$2'} | cat"
712 status, output = qemu.run_serial(cmd)
713 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
714 self.assertEqual(output, '*')
715
716 @only_for_arch(['i586', 'i686', 'x86_64'])
717 def test_biosplusefi_plugin(self):
718 """Test biosplusefi plugin"""
719 # Wic generation below may fail depending on the order of the unittests
720 # This is because bootimg-pcbios (that bootimg-biosplusefi uses) generate its MBR inside STAGING_DATADIR directory
721 # which may or may not exists depending on what was built already
722 # If an image hasn't been built yet, directory ${STAGING_DATADIR}/syslinux won't exists and _get_bootimg_dir()
723 # will raise with "Couldn't find correct bootimg_dir"
724 # The easiest way to work-around this issue is to make sure we already built an image here, hence the bitbake call
725 for fstype in ("ext4", "wic"):
726 config = 'IMAGE_FSTYPES = "%s"\nWKS_FILE = "test_biosplusefi_plugin.wks"\nMACHINE_FEATURES_append = " efi"\n' % fstype
727 self.append_config(config)
728 self.assertEqual(0, bitbake('core-image-minimal').status)
729 self.remove_config(config)
730
731 img = 'core-image-minimal'
732 with NamedTemporaryFile("w", suffix=".wks") as wks:
733 wks.writelines(['part /boot --active --source bootimg-biosplusefi --sourceparams="loader=grub-efi"\n',
734 'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\
735 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n'])
736 wks.flush()
737 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
738 runCmd(cmd)
739 wksname = os.path.splitext(os.path.basename(wks.name))[0]
740 out = glob(self.resultdir + "%s-*.direct" % wksname)
741 self.assertEqual(1, len(out))
742
684 def test_fs_types(self): 743 def test_fs_types(self):
685 """Test filesystem types for empty and not empty partitions""" 744 """Test filesystem types for empty and not empty partitions"""
686 img = 'core-image-minimal' 745 img = 'core-image-minimal'