kexec-tools/spec
Coiby Xu 8bf11dc3f6 unit tests: fix test failures "The param /boot/boot/vmlinuz-xxx is incorrect"
Currently, some tests failed with "The param /boot/boot/vmlinuz-xxx is
incorrect", for example,

    [root@fedora kexec-tools]# shellspec spec/kdumpctl_manage_reset_spec.sh
    Examples:
      1) kdumpctl reset-crashkernel [--kernel] [--fadump] Test the kdump dump mode  --kernel=ALL kdumpctl should warn the user that crashkernel has been udpated
         When call reset_crashkernel --kernel=ALL

         1.1) The error should include Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64

                expected "The param /boot/boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect
                The param /boot/boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect
                kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-5.15.6-100.fc34.x86_64. Please reboot the system for the change to take effect.
                The param /boot/boot/vmlinuz-5.14.14-200.fc34.x86_64 is incorrect
                The param /boot/boot/vmlinuz-5.14.14-200.fc34.x86_64 is incorrect
                kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-5.14.14-200.fc34.x86_64. Please reboot the system for the change to take effect.
                The param /boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b is incorrect
                The param /boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b is incorrect
                kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b. Please reboot the system for the change to take effect." to include "Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64"

              # spec/kdumpctl_reset_crashkernel_spec.sh:69

This happens because when a system has a boot partition, grubby
automatically prefixes a path with "/boot". The current boot loader
entries used for tests already has the prefix "/boot" in the path and
prefixing a path again will cause the above problem.

grubby uses "mountpoint -q /boot" to tell if there is a boot partition.
This patch mocks mountpoint so grubby knows the boot loader entries
are for a system without a boot partition.

Note this patch also avoids another error seen in the setup phase of the
test "The param /boot/vmlinuz-xxx is incorrect". I believe this error is
a bug of "grubby --update-kernel" in testing mode because running the
grubby in normal mode actually works and "grubby --info=/boot/vmlinuz-*"
also works in testing mode,

    [root@fedora support]# grubby --no-etc-grub-update --grub2 --bad-image-okay --env=grub_env -b boot_load_entries --args crashkernel=333M --update-kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64
    The param /boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect

    [root@fedora support]# grubby --no-etc-grub-update --grub2 --bad-image-okay --env=grub_env -b boot_load_entries --info=/boot/vmlinuz-5.15.6-100.fc34.x86_64
    index=0
    kernel="/boot/boot/vmlinuz-5.15.6-100.fc34.x86_64"

    [root@fedora support]]# grubby --args crashkernel=333M --update-kernel=/boot/vmlinuz-6.0.7-301.fc37.x86_64 && echo "succeed"
    succeed

Reviewed-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
2023-10-10 08:40:26 +08:00
..
support unit tests: fix test failures "The param /boot/boot/vmlinuz-xxx is incorrect" 2023-10-10 08:40:26 +08:00
kdump-lib_spec.sh kdump-lib: Harden _crashkernel_add 2023-09-14 15:01:52 +08:00
kdump-lib-initramfs_spec.sh unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh 2022-04-14 11:45:18 +08:00
kdumpctl_general_spec.sh unit tests: Fix parse_config test case 2023-09-14 15:01:52 +08:00
kdumpctl_manage_crashkernel_spec.sh unit tests: fix test failures "The param /boot/boot/vmlinuz-xxx is incorrect" 2023-10-10 08:40:26 +08:00
kdumpctl_reset_crashkernel_spec.sh unit tests: fix test failures "The param /boot/boot/vmlinuz-xxx is incorrect" 2023-10-10 08:40:26 +08:00