blob: 51bcb74b3fdda4db3e69bc612b587191347c36b0 [file] [log] [blame]
Klaus Heinrich Kiwid1cd8c52020-02-27 12:43:47 -03001From 1e8fc53f15c4703a76911e75d906965e3d967e8f Mon Sep 17 00:00:00 2001
2From: Jeremy Kerr <jk@ozlabs.org>
3Date: Thu, 14 Nov 2019 15:22:35 +0800
4Subject: [PATCH 17/18] test/parser: Add RHEL8 grub config test
5
6Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
7(cherry picked from commit 057dce2dadee2e2fca370d4497c8c792b001c2d3)
8Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
9---
10 test/parser/Makefile.am | 1 +
11 test/parser/data/grub2-rhel8.conf | 190 ++++++++++++++++++++++++++++++
12 test/parser/test-grub2-rhel8.c | 21 ++++
13 3 files changed, 212 insertions(+)
14 create mode 100644 test/parser/data/grub2-rhel8.conf
15 create mode 100644 test/parser/test-grub2-rhel8.c
16
17diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
18index 5f7922c..9d1141c 100644
19--- a/test/parser/Makefile.am
20+++ b/test/parser/Makefile.am
21@@ -43,6 +43,7 @@ parser_TESTS = \
22 test/parser/test-grub2-f20-ppc64 \
23 test/parser/test-grub2-ubuntu-13_04-x86 \
24 test/parser/test-grub2-sles-btrfs-snapshot \
25+ test/parser/test-grub2-rhel8 \
26 test/parser/test-grub2-rhcos-ootpa \
27 test/parser/test-grub2-lexer-error \
28 test/parser/test-grub2-parser-error \
29diff --git a/test/parser/data/grub2-rhel8.conf b/test/parser/data/grub2-rhel8.conf
30new file mode 100644
31index 0000000..563b3e5
32--- /dev/null
33+++ b/test/parser/data/grub2-rhel8.conf
34@@ -0,0 +1,190 @@
35+#
36+# DO NOT EDIT THIS FILE
37+#
38+# It is automatically generated by grub2-mkconfig using templates
39+# from /etc/grub.d and settings from /etc/default/grub
40+#
41+
42+### BEGIN /etc/grub.d/00_header ###
43+set pager=1
44+
45+if [ -f ${config_directory}/grubenv ]; then
46+ load_env -f ${config_directory}/grubenv
47+elif [ -s $prefix/grubenv ]; then
48+ load_env
49+fi
50+if [ "${next_entry}" ] ; then
51+ set default="${next_entry}"
52+ set next_entry=
53+ save_env next_entry
54+ set boot_once=true
55+else
56+ set default="${saved_entry}"
57+fi
58+
59+if [ x"${feature_menuentry_id}" = xy ]; then
60+ menuentry_id_option="--id"
61+else
62+ menuentry_id_option=""
63+fi
64+
65+export menuentry_id_option
66+
67+if [ "${prev_saved_entry}" ]; then
68+ set saved_entry="${prev_saved_entry}"
69+ save_env saved_entry
70+ set prev_saved_entry=
71+ save_env prev_saved_entry
72+ set boot_once=true
73+fi
74+
75+function savedefault {
76+ if [ -z "${boot_once}" ]; then
77+ saved_entry="${chosen}"
78+ save_env saved_entry
79+ fi
80+}
81+
82+function load_video {
83+ if [ x$feature_all_video_module = xy ]; then
84+ insmod all_video
85+ else
86+ insmod efi_gop
87+ insmod efi_uga
88+ insmod ieee1275_fb
89+ insmod vbe
90+ insmod vga
91+ insmod video_bochs
92+ insmod video_cirrus
93+ fi
94+}
95+
96+terminal_output ofconsole
97+if [ x$feature_timeout_style = xy ] ; then
98+ set timeout_style=menu
99+ set timeout=5
100+# Fallback normal timeout code in case the timeout_style feature is
101+# unavailable.
102+else
103+ set timeout=5
104+fi
105+### END /etc/grub.d/00_header ###
106+
107+### BEGIN /etc/grub.d/00_tuned ###
108+set tuned_params=""
109+set tuned_initrd=""
110+### END /etc/grub.d/00_tuned ###
111+
112+### BEGIN /etc/grub.d/01_menu_auto_hide ###
113+if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
114+ set last_boot_ok=1
115+else
116+ set last_boot_ok=0
117+fi
118+
119+# Reset boot_indeterminate after a successful boot
120+if [ "${boot_success}" = "1" ] ; then
121+ set boot_indeterminate=0
122+# Avoid boot_indeterminate causing the menu to be hidden more then once
123+elif [ "${boot_indeterminate}" = "1" ]; then
124+ set boot_indeterminate=2
125+fi
126+set boot_success=0
127+save_env boot_success boot_indeterminate
128+
129+if [ x$feature_timeout_style = xy ] ; then
130+ if [ "${menu_show_once}" ]; then
131+ unset menu_show_once
132+ save_env menu_show_once
133+ set timeout_style=menu
134+ set timeout=60
135+ elif [ "${menu_auto_hide}" -a "${last_boot_ok}" = "1" ]; then
136+ set orig_timeout_style=${timeout_style}
137+ set orig_timeout=${timeout}
138+ if [ "${fastboot}" = "1" ]; then
139+ # timeout_style=menu + timeout=0 avoids the countdown code keypress check
140+ set timeout_style=menu
141+ set timeout=0
142+ else
143+ set timeout_style=hidden
144+ set timeout=1
145+ fi
146+ fi
147+fi
148+### END /etc/grub.d/01_menu_auto_hide ###
149+
150+### BEGIN /etc/grub.d/01_users ###
151+if [ -f ${prefix}/user.cfg ]; then
152+ source ${prefix}/user.cfg
153+ if [ -n "${GRUB2_PASSWORD}" ]; then
154+ set superusers="root"
155+ export superusers
156+ password_pbkdf2 root ${GRUB2_PASSWORD}
157+ fi
158+fi
159+### END /etc/grub.d/01_users ###
160+
161+### BEGIN /etc/grub.d/10_linux_bls ###
162+insmod part_msdos
163+insmod xfs
164+set root='hd0,msdos2'
165+if [ x$feature_platform_search_hint = xy ]; then
166+ search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//pciex@600c3c0100000/pci@0/pci@0/pci@9/raid@0/disk@8,msdos2' --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 9a8ea027-4829-45b9-829b-18ed6cc1f33b
167+else
168+ search --no-floppy --fs-uuid --set=root 9a8ea027-4829-45b9-829b-18ed6cc1f33b
169+fi
170+insmod part_msdos
171+insmod xfs
172+set boot='hd0,msdos2'
173+if [ x$feature_platform_search_hint = xy ]; then
174+ search --no-floppy --fs-uuid --set=boot --hint-ieee1275='ieee1275//pciex@600c3c0100000/pci@0/pci@0/pci@9/raid@0/disk@8,msdos2' --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 9a8ea027-4829-45b9-829b-18ed6cc1f33b
175+else
176+ search --no-floppy --fs-uuid --set=boot 9a8ea027-4829-45b9-829b-18ed6cc1f33b
177+fi
178+
179+# This section was generated by a script. Do not modify the generated file - all changes
180+# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
181+
182+menuentry 'Red Hat Enterprise Linux (4.18.0-80.11.2.el8_0.ppc64le) 8.0 (Ootpa)' --class kernel --unrestricted --users $grub_users --id 8e15296c9cc14deb9e3f8548d49fd6fc-4.18.0-80.11.2.el8_0.ppc64le {
183+ linux /vmlinuz-4.18.0-80.11.2.el8_0.ppc64le $kernelopts $tuned_params
184+ initrd /initramfs-4.18.0-80.11.2.el8_0.ppc64le.img $tuned_initrd
185+}
186+
187+menuentry 'Red Hat Enterprise Linux (4.18.0-80.el8.ppc64le) 8.0 (Ootpa)' --class kernel --unrestricted --users $grub_users --id 8e15296c9cc14deb9e3f8548d49fd6fc-4.18.0-80.el8.ppc64le {
188+ linux /vmlinuz-4.18.0-80.el8.ppc64le $kernelopts $tuned_params
189+ initrd /initramfs-4.18.0-80.el8.ppc64le.img $tuned_initrd
190+}
191+
192+menuentry 'Red Hat Enterprise Linux (0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc) 8.0 (Ootpa)' --class kernel --unrestricted --users $grub_users --id 8e15296c9cc14deb9e3f8548d49fd6fc-0-rescue {
193+ linux /vmlinuz-0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc $kernelopts
194+ initrd /initramfs-0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc.img
195+}
196+
197+### END /etc/grub.d/10_linux_bls ###
198+
199+### BEGIN /etc/grub.d/20_linux_xen ###
200+### END /etc/grub.d/20_linux_xen ###
201+
202+### BEGIN /etc/grub.d/20_ppc_terminfo ###
203+ terminfo -g 80x24 ofconsole
204+### END /etc/grub.d/20_ppc_terminfo ###
205+
206+### BEGIN /etc/grub.d/30_os-prober ###
207+### END /etc/grub.d/30_os-prober ###
208+
209+### BEGIN /etc/grub.d/30_uefi-firmware ###
210+### END /etc/grub.d/30_uefi-firmware ###
211+
212+### BEGIN /etc/grub.d/40_custom ###
213+# This file provides an easy way to add custom menu entries. Simply type the
214+# menu entries you want to add after this comment. Be careful not to change
215+# the 'exec tail' line above.
216+### END /etc/grub.d/40_custom ###
217+
218+### BEGIN /etc/grub.d/41_custom ###
219+if [ -f ${config_directory}/custom.cfg ]; then
220+ source ${config_directory}/custom.cfg
221+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
222+ source $prefix/custom.cfg;
223+fi
224+### END /etc/grub.d/41_custom ###
225diff --git a/test/parser/test-grub2-rhel8.c b/test/parser/test-grub2-rhel8.c
226new file mode 100644
227index 0000000..3e208bc
228--- /dev/null
229+++ b/test/parser/test-grub2-rhel8.c
230@@ -0,0 +1,21 @@
231+
232+#include "parser-test.h"
233+
234+void run_test(struct parser_test *test)
235+{
236+ struct discover_context *ctx;
237+ struct discover_device *dev;
238+
239+ ctx = test->ctx;
240+
241+ dev = test_create_device(test, "boot");
242+ dev->uuid = "9a8ea027-4829-45b9-829b-18ed6cc1f33b";
243+ device_handler_add_device(test->handler, dev);
244+
245+ test_read_conf_file(test, "grub2-rhel8.conf",
246+ "/grub/grub.cfg");
247+
248+ test_run_parser(test, "grub2");
249+
250+ check_boot_option_count(ctx, 3);
251+}
252--
2532.17.1
254