OSDN Git Service

kest.pl: Fix grub2 menu handling for rebooting
authorSteven Rostedt <rostedt@goodmis.org>
Wed, 30 Nov 2022 22:54:34 +0000 (17:54 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 8 Dec 2022 01:37:43 +0000 (20:37 -0500)
commit26df05a8c1420ad3de314fdd407e7fc2058cc7aa
treec9afb18605d5d51f72c9a4b905a58113d119522d
parentef784eebb56425eed6e9b16e7d47e5c00dcf9c38
kest.pl: Fix grub2 menu handling for rebooting

grub2 has submenus where to use grub-reboot, it requires:

  grub-reboot X>Y

where X is the main index and Y is the submenu. Thus if you have:

menuentry 'Debian GNU/Linux' --class debian --class gnu-linux ...
[...]
}
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option ...
        menuentry 'Debian GNU/Linux, with Linux 6.0.0-4-amd64' --class debian --class gnu-linux ...
                [...]
        }
        menuentry 'Debian GNU/Linux, with Linux 6.0.0-4-amd64 (recovery mode)' --class debian --class gnu-linux ...
[...]
        }
        menuentry 'Debian GNU/Linux, with Linux test' --class debian --class gnu-linux ...
                [...]
        }

And wanted to boot to the "Linux test" kernel, you need to run:

 # grub-reboot 1>2

As 1 is the second top menu (the submenu) and 2 is the third of the sub
menu entries.

Have the grub.cfg parsing for grub2 handle such cases.

Cc: stable@vger.kernel.org
Fixes: a15ba91361d46 ("ktest: Add support for grub2")
Reviewed-by: John 'Warthog9' Hawley (VMware) <warthog9@eaglescrag.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
tools/testing/ktest/ktest.pl