Blame SOURCES/0067-Add-multi-entry-removal-test-1285601.patch

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