ktest: fixes and updated for new boot loaders
Steven Rostedt
maintainerLinus,
Please pull the latest ktest-v3.8 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git
ktest-v3.8
Head SHA1: a7c85ac16cf29aa0fec5fef2fe26bb09a9e3ee19
Steven Rostedt (5):
ktest: Add support for grub2
ktest: Sync before reboot
ktest: Add native support for syslinux boot loader
ktest: Fix breakage from change of oldnoconfig to olddefconfig
ktest: Test if target machine is up before install
----
tools/testing/ktest/ktest.pl | 120 +++++++++++++++++++++++++++++++++++++-- tools/testing/ktest/sample.conf | 46 ++++++++++++++- 2 files changed, 158 insertions(+), 8 deletions(-)
Steven Rostedt
maintainerPATCH 5/5 ktest: Test if target machine is up before install
From: Steven Rostedt <[email protected]>
Sometimes a test kernel will crash or hang on reboot (this is even more apparent when testing a config without CGROUPS on a box running systemd). When this happens, on the next iteration of installing a kernel, ktest will fail when it tries to install.
Have ktest do a check to see if the target can be connected to via ssh before it tries to install. If it can't connect, then reboot again. This time the reboot will fail because it can't connect and will force a power cycle.
--- tools/testing/ktest/ktest.pl | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/testing/ktest/ktest.pl +10 -0
@@ -1807,6 +1807,14 @@ sub do_post_install { dodie "Failed to run post install"; } +# Sometimes the reboot fails, and will hang. We try to ssh to the box +# and if we fail, we force another reboot, that should powercycle it. +sub test_booted { + if (!run_ssh "echo testing connection") { + reboot $sleep_time; + } +} + sub install { return if ($no_install);
@@ -1819,6 +1827,8 @@ sub install { my $cp_target = eval_kernel_version $target_image; + test_booted; + run_scp_install "$outputdir/$build_target", "$cp_target" or dodie "failed to copy image";
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 4/5 ktest: Fix breakage from change of oldnoconfig to olddefconfig
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Commit fb16d891 "kconfig: replace 'oldnoconfig' with 'olddefconfig', and keep the old name", changed ktest's default config update from oldnoconfig to olddefconfig without adding oldnoconfig as a backup. The make oldnoconfig works much better than its backup of:
yes '' | make oldconfig
But due to this change, and the fact that ktest is used to build lots of older kernels (and for bisects), it forgoes the oldnoconfig completely.
--- tools/testing/ktest/ktest.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/ktest/ktest.pl +8 -4
@@ -1966,10 +1966,14 @@ sub make_oldconfig { if (!run_command "$make olddefconfig") { # Perhaps olddefconfig doesn't exist in this version of the kernel - # try a yes '' | oldconfig - doprint "olddefconfig failed, trying yes '' | make oldconfig\n"; - run_command "yes '' | $make oldconfig" or - dodie "failed make config oldconfig"; + # try oldnoconfig + doprint "olddefconfig failed, trying make oldnoconfig\n"; + if (!run_command "$make oldnoconfig") { + doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; + # try a yes '' | oldconfig + run_command "yes '' | $make oldconfig" or + dodie "failed make config oldconfig"; + } } }
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 3/5 ktest: Add native support for syslinux boot loader
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
I installed Fedora 17 which no longer supports grub v1. I worked with grub2 for a while, but there's so many issues with it and automated rebooting, that I decided to switch to syslinux. Instead of using the REBOOT_SCRIPT and add customized changes to get syslinux booted, I thought it better to make ktest aware of syslinux and add options to simplify the use of syslinux on a target test box.
--- tools/testing/ktest/ktest.pl | 28 +++++++++++++++++++++++++++- tools/testing/ktest/sample.conf | 22 +++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-)
tools/testing/ktest/ktest.pl +27 -1
@@ -54,6 +54,8 @@ my %default = ( "STOP_TEST_AFTER" => 600, "MAX_MONITOR_WAIT" => 1800, "GRUB_REBOOT" => "grub2-reboot", + "SYSLINUX" => "extlinux", + "SYSLINUX_PATH" => "/boot/extlinux", # required, and we will ask users if they don't have them but we keep the default # value something that is common.
@@ -109,6 +111,9 @@ my $grub_menu; my $grub_file; my $grub_number; my $grub_reboot; +my $syslinux; +my $syslinux_path; +my $syslinux_label; my $target; my $make; my $pre_install;
@@ -237,6 +242,9 @@ my %option_map = ( "GRUB_MENU" => \$grub_menu, "GRUB_FILE" => \$grub_file, "GRUB_REBOOT" => \$grub_reboot, + "SYSLINUX" => \$syslinux, + "SYSLINUX_PATH" => \$syslinux_path, + "SYSLINUX_LABEL" => \$syslinux_label, "PRE_INSTALL" => \$pre_install, "POST_INSTALL" => \$post_install, "NO_INSTALL" => \$no_install,
@@ -373,7 +381,7 @@ EOF ; $config_help{"REBOOT_TYPE"} = << "EOF" Way to reboot the box to the test kernel. - Only valid options so far are "grub", "grub2", and "script". + Only valid options so far are "grub", "grub2", "syslinux", and "script". If you specify grub, it will assume grub version 1 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
@@ -386,6 +394,11 @@ $config_help{"REBOOT_TYPE"} = << "EOF" If you specify grub2, then you also need to specify both \$GRUB_MENU and \$GRUB_FILE. + + If you specify syslinux, then you may use SYSLINUX to define the syslinux + command (defaults to extlinux), and SYSLINUX_PATH to specify the path to + the syslinux install (defaults to /boot/extlinux). But you have to specify + SYSLINUX_LABEL to define the label to boot to for the test kernel. EOF ; $config_help{"GRUB_MENU"} = << "EOF"
@@ -414,6 +427,11 @@ $config_help{"GRUB_FILE"} = << "EOF" here. Use something like /boot/grub2/grub.cfg to search. EOF ; +$config_help{"SYSLINUX_LABEL"} = << "EOF" + If syslinux is used, the label that boots the target kernel must + be specified with SYSLINUX_LABEL. +EOF + ; $config_help{"REBOOT_SCRIPT"} = << "EOF" A script to reboot the target into the test kernel (Only mandatory if REBOOT_TYPE = script)
@@ -545,6 +563,10 @@ sub get_ktest_configs { get_ktest_config("GRUB_MENU"); get_ktest_config("GRUB_FILE"); } + + if ($rtype eq "syslinux") { + get_ktest_config("SYSLINUX_LABEL"); + } } sub process_variables {
@@ -1589,6 +1611,8 @@ sub reboot_to { run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; } elsif ($reboot_type eq "grub2") { run_ssh "$grub_reboot $grub_number"; + } elsif ($reboot_type eq "syslinux") { + run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path"; } elsif (defined $reboot_script) { run_command "$reboot_script"; }
@@ -3768,6 +3792,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { } elsif ($reboot_type eq "grub2") { dodie "GRUB_MENU not defined" if (!defined($grub_menu)); dodie "GRUB_FILE not defined" if (!defined($grub_file)); + } elsif ($reboot_type eq "syslinux") { + dodie "SYSLINUX_LABEL not defined" if (!defined($syslinux_label)); } }
tools/testing/ktest/sample.conf +21 -1
@@ -364,6 +364,22 @@ # #GRUB_MENU = Test Kernel +# For REBOOT_TYPE = syslinux, the name of the syslinux executable +# (on the target) to use to set up the next reboot to boot the +# test kernel. +# (default extlinux) +#SYSLINUX = syslinux + +# For REBOOT_TYPE = syslinux, the path that is passed to to the +# syslinux command where syslinux is installed. +# (default /boot/extlinux) +#SYSLINUX_PATH = /boot/syslinux + +# For REBOOT_TYPE = syslinux, the syslinux label that references the +# test kernel in the syslinux config file. +# (default undefined) +#SYSLINUX_LABEL = "test-kernel" + # A script to reboot the target into the test kernel # This and SWITCH_TO_TEST are about the same, except # SWITCH_TO_TEST is run even for REBOOT_TYPE = grub.
@@ -516,7 +532,7 @@ #POST_BUILD_DIE = 1 # Way to reboot the box to the test kernel. -# Only valid options so far are "grub", "grub2" and "script" +# Only valid options so far are "grub", "grub2", "syslinux" and "script" # (default grub) # If you specify grub, it will assume grub version 1 # and will search in /boot/grub/menu.lst for the title $GRUB_MENU
@@ -527,6 +543,10 @@ # For REBOOT_TYPE = grub2, you must define both GRUB_MENU and # GRUB_FILE. # +# For REBOOT_TYPE = syslinux, you must define SYSLINUX_LABEL, and +# perhaps modify SYSLINUX (default extlinux) and SYSLINUX_PATH +# (default /boot/extlinux) +# # The entry in /boot/grub/menu.lst must be entered in manually. # The test will not modify that file. #REBOOT_TYPE = grub
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 2/5 ktest: Sync before reboot
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Before rebooting the target, run the sync command, as it seems that either Grub2 or systemd gets screwed up if you update to reboot a kernel once and do a reboot without doing a sync.
--- tools/testing/ktest/ktest.pl | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/ktest/ktest.pl +3 -0
@@ -1147,6 +1147,9 @@ sub wait_for_monitor; sub reboot { my ($time) = @_; + # Make sure everything has been written to disk + run_ssh("sync"); + if (defined($time)) { start_monitor; # flush out current monitor
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 1/5 ktest: Add support for grub2
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
As only grub or 'script' is supported for rebooting to a new kernel, and Fedora 17 has dropped support for grub, I decided to add grub2 support as well (I also plan on adding syslinux/extlinux support too).
The options GRUB_FILE and GRUB_REBOOT were added to allow the user to specify where to find the grub.cfg and what tool to use to reboot into the next kernel respectively.
--- tools/testing/ktest/ktest.pl | 69 +++++++++++++++++++++++++++++++++++++-- tools/testing/ktest/sample.conf | 26 +++++++++++++-- 2 files changed, 91 insertions(+), 4 deletions(-)
tools/testing/ktest/ktest.pl +67 -2
@@ -53,6 +53,7 @@ my %default = ( "STOP_AFTER_FAILURE" => 60, "STOP_TEST_AFTER" => 600, "MAX_MONITOR_WAIT" => 1800, + "GRUB_REBOOT" => "grub2-reboot", # required, and we will ask users if they don't have them but we keep the default # value something that is common.
@@ -105,7 +106,9 @@ my $scp_to_target; my $scp_to_target_install; my $power_off; my $grub_menu; +my $grub_file; my $grub_number; +my $grub_reboot; my $target; my $make; my $pre_install;
@@ -232,6 +235,8 @@ my %option_map = ( "ADD_CONFIG" => \$addconfig, "REBOOT_TYPE" => \$reboot_type, "GRUB_MENU" => \$grub_menu, + "GRUB_FILE" => \$grub_file, + "GRUB_REBOOT" => \$grub_reboot, "PRE_INSTALL" => \$pre_install, "POST_INSTALL" => \$post_install, "NO_INSTALL" => \$no_install,
@@ -368,7 +373,7 @@ EOF ; $config_help{"REBOOT_TYPE"} = << "EOF" Way to reboot the box to the test kernel. - Only valid options so far are "grub" and "script". + Only valid options so far are "grub", "grub2", and "script". If you specify grub, it will assume grub version 1 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
@@ -378,11 +383,14 @@ $config_help{"REBOOT_TYPE"} = << "EOF" The entry in /boot/grub/menu.lst must be entered in manually. The test will not modify that file. + + If you specify grub2, then you also need to specify both \$GRUB_MENU + and \$GRUB_FILE. EOF ; $config_help{"GRUB_MENU"} = << "EOF" The grub title name for the test kernel to boot - (Only mandatory if REBOOT_TYPE = grub) + (Only mandatory if REBOOT_TYPE = grub or grub2) Note, ktest.pl will not update the grub menu.lst, you need to manually add an option for the test. ktest.pl will search
@@ -393,6 +401,17 @@ $config_help{"GRUB_MENU"} = << "EOF" title Test Kernel kernel vmlinuz-test GRUB_MENU = Test Kernel + + For grub2, a search of \$GRUB_FILE is performed for the lines + that begin with "menuentry". It will not detect submenus. The + menu must be a non-nested menu. Add the quotes used in the menu + to guarantee your selection, as the first menuentry with the content + of \$GRUB_MENU that is found will be used. +EOF + ; +$config_help{"GRUB_FILE"} = << "EOF" + If grub2 is used, the full path for the grub.cfg file is placed + here. Use something like /boot/grub2/grub.cfg to search. EOF ; $config_help{"REBOOT_SCRIPT"} = << "EOF"
@@ -521,6 +540,11 @@ sub get_ktest_configs { if ($rtype eq "grub") { get_ktest_config("GRUB_MENU"); } + + if ($rtype eq "grub2") { + get_ktest_config("GRUB_MENU"); + get_ktest_config("GRUB_FILE"); + } } sub process_variables {
@@ -1452,8 +1476,44 @@ sub run_scp_mod { return run_scp($src, $dst, $cp_scp); } +sub get_grub2_index { + + return if (defined($grub_number)); + + doprint "Find grub2 menu ... "; + $grub_number = -1; + + my $ssh_grub = $ssh_exec; + $ssh_grub =~ s,\$SSH_COMMAND,cat $grub_file,g; + + open(IN, "$ssh_grub |") + or die "unable to get $grub_file"; + + my $found = 0; + + while (<IN>) { + if (/^menuentry.*$grub_menu/) { + $grub_number++; + $found = 1; + last; + } elsif (/^menuentry\s/) { + $grub_number++; + } + } + close(IN); + + die "Could not find '$grub_menu' in $grub_file on $machine" + if (!$found); + doprint "$grub_number\n"; +} + sub get_grub_index { + if ($reboot_type eq "grub2") { + get_grub2_index; + return; + } + if ($reboot_type ne "grub") { return; }
@@ -1524,6 +1584,8 @@ sub reboot_to { if ($reboot_type eq "grub") { run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; + } elsif ($reboot_type eq "grub2") { + run_ssh "$grub_reboot $grub_number"; } elsif (defined $reboot_script) { run_command "$reboot_script"; }
@@ -3700,6 +3762,9 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { $target = "$ssh_user\@$machine"; if ($reboot_type eq "grub") { dodie "GRUB_MENU not defined" if (!defined($grub_menu)); + } elsif ($reboot_type eq "grub2") { + dodie "GRUB_MENU not defined" if (!defined($grub_menu)); + dodie "GRUB_FILE not defined" if (!defined($grub_file)); } }
tools/testing/ktest/sample.conf +24 -2
@@ -332,8 +332,18 @@ # from other linux builds on the system. #LOCALVERSION = -test +# For REBOOT_TYPE = grub2, you must specify where the grub.cfg +# file is. This is the file that is searched to find the menu +# option to boot to with GRUB_REBOOT +#GRUB_FILE = /boot/grub2/grub.cfg + +# The tool for REBOOT_TYPE = grub2 to set the next reboot kernel +# to boot into (one shot mode). +# (default grub2_reboot) +#GRUB_REBOOT = grub2_reboot + # The grub title name for the test kernel to boot -# (Only mandatory if REBOOT_TYPE = grub) +# (Only mandatory if REBOOT_TYPE = grub or grub2) # # Note, ktest.pl will not update the grub menu.lst, you need to # manually add an option for the test. ktest.pl will search
@@ -343,6 +353,15 @@ # For example, if in the /boot/grub/menu.lst the test kernel title has: # title Test Kernel # kernel vmlinuz-test +# +# For grub2, a search of top level "menuentry"s are done. No +# submenu is searched. The menu is found by searching for the +# contents of GRUB_MENU in the line that starts with "menuentry". +# You may want to include the quotes around the option. For example: +# for: menuentry 'Test Kernel' +# do a: GRUB_MENU = 'Test Kernel' +# For customizing, add your entry in /etc/grub.d/40_custom. +# #GRUB_MENU = Test Kernel # A script to reboot the target into the test kernel
@@ -497,7 +516,7 @@ #POST_BUILD_DIE = 1 # Way to reboot the box to the test kernel. -# Only valid options so far are "grub" and "script" +# Only valid options so far are "grub", "grub2" and "script" # (default grub) # If you specify grub, it will assume grub version 1 # and will search in /boot/grub/menu.lst for the title $GRUB_MENU
@@ -505,6 +524,9 @@ # your setup, then specify "script" and have a command or script # specified in REBOOT_SCRIPT to boot to the target. # +# For REBOOT_TYPE = grub2, you must define both GRUB_MENU and +# GRUB_FILE. +# # The entry in /boot/grub/menu.lst must be entered in manually. # The test will not modify that file. #REBOOT_TYPE = grub
Signature · 1 line
1.7.10.4
Hi Steve,
Quoted 9 lines · On Wed, 12 Dec 2012 17:14:37 -0500 Steven Rostedt <[email protected]> wrote:
Please pull the latest ktest-v3.8 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git
ktest-v3.8Head SHA1:
a7c85ac16cf29aa0fec5fef2fe26bb09a9e3ee19
Quoted 6 lines
Steven Rostedt (5):
ktest: Add support for grub2
ktest: Sync before reboot
ktest: Add native support for syslinux boot loader
ktest: Fix breakage from change of oldnoconfig to olddefconfig
ktest: Test if target machine is up before install
Just a bit disappointed that none of this made ever it into your for-next branch (and hence linux-next) ...
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Steven Rostedt
maintainerQuoted 19 lines · Stephen Rothwell
Hi Steve,
Quoted 9 lines · On Wed, 12 Dec 2012 17:14:37 -0500 Steven Rostedt <[email protected]> wrote:
Please pull the latest ktest-v3.8 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git
ktest-v3.8Head SHA1:
a7c85ac16cf29aa0fec5fef2fe26bb09a9e3ee19Quoted 6 lines
Steven Rostedt (5):
ktest: Add support for grub2
ktest: Sync before reboot
ktest: Add native support for syslinux boot loader
ktest: Fix breakage from change of oldnoconfig to olddefconfig
ktest: Test if target machine is up before install
Quoted 3 lines
Just a bit disappointed that none of this made ever it into your for-next branch (and hence linux-next) ...
Yeah, I know. That's because most of it stays in a quilt queue and I commit it to git when the merge window opens. I use ktest every day, and hammer it more than anyone else. I usually shake out all the bugs before I post.
As this sits in the tools/testing/ktest/ directory and is just a single perl script, it doesn't interact with other parts of the kernel tree. I've been trying to remember to add it to linux-next, but sometimes I forget :-(
My work flow with ktest is basically this:
1) Something about ktest bothers me
2) I write up a new feature
3) Test it a bit, and then make it into a quilt patch
4) After using it for a while, I'll do the git commit and push it off to linux-next
5) Merge window opens, I look at both my commits and my quilt queue and commit any missing patches that I feel is good enough
6) Push the entire thing off to Linus
ktest is very low on my priority list of things to maintain, and I sometimes forget step 4. But I don't worry too much because it may miss out on some testing, but if it breaks, it will only break ktest. It shouldn't break anything else in the kernel.
And actually, I admit the last 3 patches of the series was written in the last week and the other 2 a couple of weeks before that, as I was adding a new machine to my test suite and added a Fedora 17 image for the first time (first one without grub1 and with systemd), that it caused me a lot of pain with my automated testing. I struggled with grub2, got it mostly working, but then decided recently to just use syslinux. I also just noticed the breakage that was there from the last release, where the make oldnoconfig was changed. Hmm, maybe I should look at linux-next more often, to see if anyone is touching ktest without telling me.
I'll try to be better next time :-) (no pun intended)
-- Steve
Re: [PATCH 4/5] ktest: Fix breakage from change of oldnoconfig to olddefconfig
In reply to Steven RostedtQuoted 8 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Commit
fb16d891"kconfig: replace 'oldnoconfig' with 'olddefconfig', and keep the old name", changed ktest's default config update from oldnoconfig to olddefconfig without adding oldnoconfig as a backup. The make oldnoconfig works much better than its backup of:
yes '' | make oldconfig
Quoted 6 lines
But due to this change, and the fact that ktest is used to build lots of older kernels (and for bisects), it forgoes the oldnoconfig completely.
Cc Adam Lee <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Steven Rostedt <[email protected]>
This makes sense, we should provide a backup for older kernels. Sorry for not noticing the breakage.
Signature · 3 lines
Regards, Adam Lee http://adam8157.info
Michal Marek
Acked-byRe: [PATCH 4/5] ktest: Fix breakage from change of oldnoconfig to olddefconfig
Quoted 12 lines · Adam Lee
Quoted 11 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Commit
fb16d891"kconfig: replace 'oldnoconfig' with 'olddefconfig', and keep the old name", changed ktest's default config update from oldnoconfig to olddefconfig without adding oldnoconfig as a backup. The make oldnoconfig works much better than its backup of:
yes '' | make oldconfigBut due to this change, and the fact that ktest is used to build lots of older kernels (and for bisects), it forgoes the oldnoconfig completely.
Quoted 8 lines
Quoted 3 lines
Cc Adam Lee <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Steven Rostedt <[email protected]>This makes sense, we should provide a backup for older kernels. Sorry for not noticing the breakage.
Acked-by Adam Lee <[email protected]>
Michal