From ef74333dffe359aa5cf9ea1313ab9ccb7ed3b192 Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Thu, 22 Dec 2016 17:40:52 -0500 Subject: [PATCH 67/69] Add multi-entry removal test (#1285601) Test what happens to the default entry set in the grub environment after removing the first two boot entries. Related: rhbz#1285601 --- test.sh | 7 +++ test/grub2-support_files/grubenv.4 | 3 + test/grub2.19 | 112 +++++++++++++++++++++++++++++++++++++ test/results/remove/g2.19 | 88 +++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 test/grub2-support_files/grubenv.4 create mode 100644 test/grub2.19 create mode 100644 test/results/remove/g2.19 diff --git a/test.sh b/test.sh index dbf7507..3631ed0 100755 --- a/test.sh +++ b/test.sh @@ -570,6 +570,13 @@ if [ "$testgrub2" == "y" ]; then --copy-default --title 'Red Hat Enterprise Linux Server' \ --args=root=/dev/mapper/foo-- + grub2Test grub2.19 remove/g2.19 --env grubenv.4 \ + --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \ + --boot-filesystem=/boot/ + commandTest "saved_default output" \ + "grub2-editenv test/grub2-support_files/env_temp list" \ + "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64" + # copy a stanza and add arguments as well, while using --set-index= testing="GRUB2 add stanza and new args with --set-index=" grub2Test grub2.18 add/g2-1.18 --env grubenv.3 \ diff --git a/test/grub2-support_files/grubenv.4 b/test/grub2-support_files/grubenv.4 new file mode 100644 index 0000000..1311638 --- /dev/null +++ b/test/grub2-support_files/grubenv.4 @@ -0,0 +1,3 @@ +# GRUB Environment Block +saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64 +################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ diff --git a/test/grub2.19 b/test/grub2.19 new file mode 100644 index 0000000..be07b3e --- /dev/null +++ b/test/grub2.19 @@ -0,0 +1,112 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'First Title To Remove' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +menuentry 'Second Title To Remove' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/test/results/remove/g2.19 b/test/results/remove/g2.19 new file mode 100644 index 0000000..f65edd5 --- /dev/null +++ b/test/results/remove/g2.19 @@ -0,0 +1,88 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### -- 2.9.3