Skip to content

Commit 057dce2

Browse files
committed
test/parser: Add RHEL8 grub config test
Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 1ef95c2 commit 057dce2

File tree

3 files changed

+212
-0
lines changed

3 files changed

+212
-0
lines changed

test/parser/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ parser_TESTS = \
4343
test/parser/test-grub2-f20-ppc64 \
4444
test/parser/test-grub2-ubuntu-13_04-x86 \
4545
test/parser/test-grub2-sles-btrfs-snapshot \
46+
test/parser/test-grub2-rhel8 \
4647
test/parser/test-grub2-rhcos-ootpa \
4748
test/parser/test-grub2-lexer-error \
4849
test/parser/test-grub2-parser-error \

test/parser/data/grub2-rhel8.conf

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#
2+
# DO NOT EDIT THIS FILE
3+
#
4+
# It is automatically generated by grub2-mkconfig using templates
5+
# from /etc/grub.d and settings from /etc/default/grub
6+
#
7+
8+
### BEGIN /etc/grub.d/00_header ###
9+
set pager=1
10+
11+
if [ -f ${config_directory}/grubenv ]; then
12+
load_env -f ${config_directory}/grubenv
13+
elif [ -s $prefix/grubenv ]; then
14+
load_env
15+
fi
16+
if [ "${next_entry}" ] ; then
17+
set default="${next_entry}"
18+
set next_entry=
19+
save_env next_entry
20+
set boot_once=true
21+
else
22+
set default="${saved_entry}"
23+
fi
24+
25+
if [ x"${feature_menuentry_id}" = xy ]; then
26+
menuentry_id_option="--id"
27+
else
28+
menuentry_id_option=""
29+
fi
30+
31+
export menuentry_id_option
32+
33+
if [ "${prev_saved_entry}" ]; then
34+
set saved_entry="${prev_saved_entry}"
35+
save_env saved_entry
36+
set prev_saved_entry=
37+
save_env prev_saved_entry
38+
set boot_once=true
39+
fi
40+
41+
function savedefault {
42+
if [ -z "${boot_once}" ]; then
43+
saved_entry="${chosen}"
44+
save_env saved_entry
45+
fi
46+
}
47+
48+
function load_video {
49+
if [ x$feature_all_video_module = xy ]; then
50+
insmod all_video
51+
else
52+
insmod efi_gop
53+
insmod efi_uga
54+
insmod ieee1275_fb
55+
insmod vbe
56+
insmod vga
57+
insmod video_bochs
58+
insmod video_cirrus
59+
fi
60+
}
61+
62+
terminal_output ofconsole
63+
if [ x$feature_timeout_style = xy ] ; then
64+
set timeout_style=menu
65+
set timeout=5
66+
# Fallback normal timeout code in case the timeout_style feature is
67+
# unavailable.
68+
else
69+
set timeout=5
70+
fi
71+
### END /etc/grub.d/00_header ###
72+
73+
### BEGIN /etc/grub.d/00_tuned ###
74+
set tuned_params=""
75+
set tuned_initrd=""
76+
### END /etc/grub.d/00_tuned ###
77+
78+
### BEGIN /etc/grub.d/01_menu_auto_hide ###
79+
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
80+
set last_boot_ok=1
81+
else
82+
set last_boot_ok=0
83+
fi
84+
85+
# Reset boot_indeterminate after a successful boot
86+
if [ "${boot_success}" = "1" ] ; then
87+
set boot_indeterminate=0
88+
# Avoid boot_indeterminate causing the menu to be hidden more then once
89+
elif [ "${boot_indeterminate}" = "1" ]; then
90+
set boot_indeterminate=2
91+
fi
92+
set boot_success=0
93+
save_env boot_success boot_indeterminate
94+
95+
if [ x$feature_timeout_style = xy ] ; then
96+
if [ "${menu_show_once}" ]; then
97+
unset menu_show_once
98+
save_env menu_show_once
99+
set timeout_style=menu
100+
set timeout=60
101+
elif [ "${menu_auto_hide}" -a "${last_boot_ok}" = "1" ]; then
102+
set orig_timeout_style=${timeout_style}
103+
set orig_timeout=${timeout}
104+
if [ "${fastboot}" = "1" ]; then
105+
# timeout_style=menu + timeout=0 avoids the countdown code keypress check
106+
set timeout_style=menu
107+
set timeout=0
108+
else
109+
set timeout_style=hidden
110+
set timeout=1
111+
fi
112+
fi
113+
fi
114+
### END /etc/grub.d/01_menu_auto_hide ###
115+
116+
### BEGIN /etc/grub.d/01_users ###
117+
if [ -f ${prefix}/user.cfg ]; then
118+
source ${prefix}/user.cfg
119+
if [ -n "${GRUB2_PASSWORD}" ]; then
120+
set superusers="root"
121+
export superusers
122+
password_pbkdf2 root ${GRUB2_PASSWORD}
123+
fi
124+
fi
125+
### END /etc/grub.d/01_users ###
126+
127+
### BEGIN /etc/grub.d/10_linux_bls ###
128+
insmod part_msdos
129+
insmod xfs
130+
set root='hd0,msdos2'
131+
if [ x$feature_platform_search_hint = xy ]; then
132+
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
133+
else
134+
search --no-floppy --fs-uuid --set=root 9a8ea027-4829-45b9-829b-18ed6cc1f33b
135+
fi
136+
insmod part_msdos
137+
insmod xfs
138+
set boot='hd0,msdos2'
139+
if [ x$feature_platform_search_hint = xy ]; then
140+
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
141+
else
142+
search --no-floppy --fs-uuid --set=boot 9a8ea027-4829-45b9-829b-18ed6cc1f33b
143+
fi
144+
145+
# This section was generated by a script. Do not modify the generated file - all changes
146+
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
147+
148+
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 {
149+
linux /vmlinuz-4.18.0-80.11.2.el8_0.ppc64le $kernelopts $tuned_params
150+
initrd /initramfs-4.18.0-80.11.2.el8_0.ppc64le.img $tuned_initrd
151+
}
152+
153+
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 {
154+
linux /vmlinuz-4.18.0-80.el8.ppc64le $kernelopts $tuned_params
155+
initrd /initramfs-4.18.0-80.el8.ppc64le.img $tuned_initrd
156+
}
157+
158+
menuentry 'Red Hat Enterprise Linux (0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc) 8.0 (Ootpa)' --class kernel --unrestricted --users $grub_users --id 8e15296c9cc14deb9e3f8548d49fd6fc-0-rescue {
159+
linux /vmlinuz-0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc $kernelopts
160+
initrd /initramfs-0-rescue-8e15296c9cc14deb9e3f8548d49fd6fc.img
161+
}
162+
163+
### END /etc/grub.d/10_linux_bls ###
164+
165+
### BEGIN /etc/grub.d/20_linux_xen ###
166+
### END /etc/grub.d/20_linux_xen ###
167+
168+
### BEGIN /etc/grub.d/20_ppc_terminfo ###
169+
terminfo -g 80x24 ofconsole
170+
### END /etc/grub.d/20_ppc_terminfo ###
171+
172+
### BEGIN /etc/grub.d/30_os-prober ###
173+
### END /etc/grub.d/30_os-prober ###
174+
175+
### BEGIN /etc/grub.d/30_uefi-firmware ###
176+
### END /etc/grub.d/30_uefi-firmware ###
177+
178+
### BEGIN /etc/grub.d/40_custom ###
179+
# This file provides an easy way to add custom menu entries. Simply type the
180+
# menu entries you want to add after this comment. Be careful not to change
181+
# the 'exec tail' line above.
182+
### END /etc/grub.d/40_custom ###
183+
184+
### BEGIN /etc/grub.d/41_custom ###
185+
if [ -f ${config_directory}/custom.cfg ]; then
186+
source ${config_directory}/custom.cfg
187+
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
188+
source $prefix/custom.cfg;
189+
fi
190+
### END /etc/grub.d/41_custom ###

test/parser/test-grub2-rhel8.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#include "parser-test.h"
3+
4+
void run_test(struct parser_test *test)
5+
{
6+
struct discover_context *ctx;
7+
struct discover_device *dev;
8+
9+
ctx = test->ctx;
10+
11+
dev = test_create_device(test, "boot");
12+
dev->uuid = "9a8ea027-4829-45b9-829b-18ed6cc1f33b";
13+
device_handler_add_device(test->handler, dev);
14+
15+
test_read_conf_file(test, "grub2-rhel8.conf",
16+
"/grub/grub.cfg");
17+
18+
test_run_parser(test, "grub2");
19+
20+
check_boot_option_count(ctx, 3);
21+
}

0 commit comments

Comments
 (0)