aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds2012-12-13 20:03:21 -0600
committerLinus Torvalds2012-12-13 20:03:21 -0600
commite05a1c6397a73d09389e033b6b2c25c954d2177c (patch)
tree699490e0c4f9f130361f4cd0dccc9a730e55dc75 /tools
parent66cdd0ceaf65a18996f561b770eedde1d123b019 (diff)
parente1a6c3d748ef0ee093e764af3fdd0c1a5cd2b664 (diff)
downloadkernel-omap-e05a1c6397a73d09389e033b6b2c25c954d2177c.tar.gz
kernel-omap-e05a1c6397a73d09389e033b6b2c25c954d2177c.tar.xz
kernel-omap-e05a1c6397a73d09389e033b6b2c25c954d2177c.zip
Merge tag 'ktest-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest
Pull ktest update from Steven Rostedt: "fixes and updated for new boot loaders" * tag 'ktest-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest: ktest: Test if target machine is up before install ktest: Fix breakage from change of oldnoconfig to olddefconfig ktest: Add native support for syslinux boot loader ktest: Sync before reboot ktest: Add support for grub2
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl120
-rw-r--r--tools/testing/ktest/sample.conf46
2 files changed, 158 insertions, 8 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index c7ba7614061b..35fc584a4ffe 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -53,6 +53,9 @@ my %default = (
53 "STOP_AFTER_FAILURE" => 60, 53 "STOP_AFTER_FAILURE" => 60,
54 "STOP_TEST_AFTER" => 600, 54 "STOP_TEST_AFTER" => 600,
55 "MAX_MONITOR_WAIT" => 1800, 55 "MAX_MONITOR_WAIT" => 1800,
56 "GRUB_REBOOT" => "grub2-reboot",
57 "SYSLINUX" => "extlinux",
58 "SYSLINUX_PATH" => "/boot/extlinux",
56 59
57# required, and we will ask users if they don't have them but we keep the default 60# required, and we will ask users if they don't have them but we keep the default
58# value something that is common. 61# value something that is common.
@@ -105,7 +108,12 @@ my $scp_to_target;
105my $scp_to_target_install; 108my $scp_to_target_install;
106my $power_off; 109my $power_off;
107my $grub_menu; 110my $grub_menu;
111my $grub_file;
108my $grub_number; 112my $grub_number;
113my $grub_reboot;
114my $syslinux;
115my $syslinux_path;
116my $syslinux_label;
109my $target; 117my $target;
110my $make; 118my $make;
111my $pre_install; 119my $pre_install;
@@ -232,6 +240,11 @@ my %option_map = (
232 "ADD_CONFIG" => \$addconfig, 240 "ADD_CONFIG" => \$addconfig,
233 "REBOOT_TYPE" => \$reboot_type, 241 "REBOOT_TYPE" => \$reboot_type,
234 "GRUB_MENU" => \$grub_menu, 242 "GRUB_MENU" => \$grub_menu,
243 "GRUB_FILE" => \$grub_file,
244 "GRUB_REBOOT" => \$grub_reboot,
245 "SYSLINUX" => \$syslinux,
246 "SYSLINUX_PATH" => \$syslinux_path,
247 "SYSLINUX_LABEL" => \$syslinux_label,
235 "PRE_INSTALL" => \$pre_install, 248 "PRE_INSTALL" => \$pre_install,
236 "POST_INSTALL" => \$post_install, 249 "POST_INSTALL" => \$post_install,
237 "NO_INSTALL" => \$no_install, 250 "NO_INSTALL" => \$no_install,
@@ -368,7 +381,7 @@ EOF
368 ; 381 ;
369$config_help{"REBOOT_TYPE"} = << "EOF" 382$config_help{"REBOOT_TYPE"} = << "EOF"
370 Way to reboot the box to the test kernel. 383 Way to reboot the box to the test kernel.
371 Only valid options so far are "grub" and "script". 384 Only valid options so far are "grub", "grub2", "syslinux", and "script".
372 385
373 If you specify grub, it will assume grub version 1 386 If you specify grub, it will assume grub version 1
374 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU 387 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
@@ -378,11 +391,19 @@ $config_help{"REBOOT_TYPE"} = << "EOF"
378 391
379 The entry in /boot/grub/menu.lst must be entered in manually. 392 The entry in /boot/grub/menu.lst must be entered in manually.
380 The test will not modify that file. 393 The test will not modify that file.
394
395 If you specify grub2, then you also need to specify both \$GRUB_MENU
396 and \$GRUB_FILE.
397
398 If you specify syslinux, then you may use SYSLINUX to define the syslinux
399 command (defaults to extlinux), and SYSLINUX_PATH to specify the path to
400 the syslinux install (defaults to /boot/extlinux). But you have to specify
401 SYSLINUX_LABEL to define the label to boot to for the test kernel.
381EOF 402EOF
382 ; 403 ;
383$config_help{"GRUB_MENU"} = << "EOF" 404$config_help{"GRUB_MENU"} = << "EOF"
384 The grub title name for the test kernel to boot 405 The grub title name for the test kernel to boot
385 (Only mandatory if REBOOT_TYPE = grub) 406 (Only mandatory if REBOOT_TYPE = grub or grub2)
386 407
387 Note, ktest.pl will not update the grub menu.lst, you need to 408 Note, ktest.pl will not update the grub menu.lst, you need to
388 manually add an option for the test. ktest.pl will search 409 manually add an option for the test. ktest.pl will search
@@ -393,6 +414,22 @@ $config_help{"GRUB_MENU"} = << "EOF"
393 title Test Kernel 414 title Test Kernel
394 kernel vmlinuz-test 415 kernel vmlinuz-test
395 GRUB_MENU = Test Kernel 416 GRUB_MENU = Test Kernel
417
418 For grub2, a search of \$GRUB_FILE is performed for the lines
419 that begin with "menuentry". It will not detect submenus. The
420 menu must be a non-nested menu. Add the quotes used in the menu
421 to guarantee your selection, as the first menuentry with the content
422 of \$GRUB_MENU that is found will be used.
423EOF
424 ;
425$config_help{"GRUB_FILE"} = << "EOF"
426 If grub2 is used, the full path for the grub.cfg file is placed
427 here. Use something like /boot/grub2/grub.cfg to search.
428EOF
429 ;
430$config_help{"SYSLINUX_LABEL"} = << "EOF"
431 If syslinux is used, the label that boots the target kernel must
432 be specified with SYSLINUX_LABEL.
396EOF 433EOF
397 ; 434 ;
398$config_help{"REBOOT_SCRIPT"} = << "EOF" 435$config_help{"REBOOT_SCRIPT"} = << "EOF"
@@ -521,6 +558,15 @@ sub get_ktest_configs {
521 if ($rtype eq "grub") { 558 if ($rtype eq "grub") {
522 get_ktest_config("GRUB_MENU"); 559 get_ktest_config("GRUB_MENU");
523 } 560 }
561
562 if ($rtype eq "grub2") {
563 get_ktest_config("GRUB_MENU");
564 get_ktest_config("GRUB_FILE");
565 }
566
567 if ($rtype eq "syslinux") {
568 get_ktest_config("SYSLINUX_LABEL");
569 }
524} 570}
525 571
526sub process_variables { 572sub process_variables {
@@ -1123,6 +1169,9 @@ sub wait_for_monitor;
1123sub reboot { 1169sub reboot {
1124 my ($time) = @_; 1170 my ($time) = @_;
1125 1171
1172 # Make sure everything has been written to disk
1173 run_ssh("sync");
1174
1126 if (defined($time)) { 1175 if (defined($time)) {
1127 start_monitor; 1176 start_monitor;
1128 # flush out current monitor 1177 # flush out current monitor
@@ -1452,8 +1501,44 @@ sub run_scp_mod {
1452 return run_scp($src, $dst, $cp_scp); 1501 return run_scp($src, $dst, $cp_scp);
1453} 1502}
1454 1503
1504sub get_grub2_index {
1505
1506 return if (defined($grub_number));
1507
1508 doprint "Find grub2 menu ... ";
1509 $grub_number = -1;
1510
1511 my $ssh_grub = $ssh_exec;
1512 $ssh_grub =~ s,\$SSH_COMMAND,cat $grub_file,g;
1513
1514 open(IN, "$ssh_grub |")
1515 or die "unable to get $grub_file";
1516
1517 my $found = 0;
1518
1519 while (<IN>) {
1520 if (/^menuentry.*$grub_menu/) {
1521 $grub_number++;
1522 $found = 1;
1523 last;
1524 } elsif (/^menuentry\s/) {
1525 $grub_number++;
1526 }
1527 }
1528 close(IN);
1529
1530 die "Could not find '$grub_menu' in $grub_file on $machine"
1531 if (!$found);
1532 doprint "$grub_number\n";
1533}
1534
1455sub get_grub_index { 1535sub get_grub_index {
1456 1536
1537 if ($reboot_type eq "grub2") {
1538 get_grub2_index;
1539 return;
1540 }
1541
1457 if ($reboot_type ne "grub") { 1542 if ($reboot_type ne "grub") {
1458 return; 1543 return;
1459 } 1544 }
@@ -1524,6 +1609,10 @@ sub reboot_to {
1524 1609
1525 if ($reboot_type eq "grub") { 1610 if ($reboot_type eq "grub") {
1526 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; 1611 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'";
1612 } elsif ($reboot_type eq "grub2") {
1613 run_ssh "$grub_reboot $grub_number";
1614 } elsif ($reboot_type eq "syslinux") {
1615 run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path";
1527 } elsif (defined $reboot_script) { 1616 } elsif (defined $reboot_script) {
1528 run_command "$reboot_script"; 1617 run_command "$reboot_script";
1529 } 1618 }
@@ -1718,6 +1807,14 @@ sub do_post_install {
1718 dodie "Failed to run post install"; 1807 dodie "Failed to run post install";
1719} 1808}
1720 1809
1810# Sometimes the reboot fails, and will hang. We try to ssh to the box
1811# and if we fail, we force another reboot, that should powercycle it.
1812sub test_booted {
1813 if (!run_ssh "echo testing connection") {
1814 reboot $sleep_time;
1815 }
1816}
1817
1721sub install { 1818sub install {
1722 1819
1723 return if ($no_install); 1820 return if ($no_install);
@@ -1730,6 +1827,8 @@ sub install {
1730 1827
1731 my $cp_target = eval_kernel_version $target_image; 1828 my $cp_target = eval_kernel_version $target_image;
1732 1829
1830 test_booted;
1831
1733 run_scp_install "$outputdir/$build_target", "$cp_target" or 1832 run_scp_install "$outputdir/$build_target", "$cp_target" or
1734 dodie "failed to copy image"; 1833 dodie "failed to copy image";
1735 1834
@@ -1877,10 +1976,14 @@ sub make_oldconfig {
1877 1976
1878 if (!run_command "$make olddefconfig") { 1977 if (!run_command "$make olddefconfig") {
1879 # Perhaps olddefconfig doesn't exist in this version of the kernel 1978 # Perhaps olddefconfig doesn't exist in this version of the kernel
1880 # try a yes '' | oldconfig 1979 # try oldnoconfig
1881 doprint "olddefconfig failed, trying yes '' | make oldconfig\n"; 1980 doprint "olddefconfig failed, trying make oldnoconfig\n";
1882 run_command "yes '' | $make oldconfig" or 1981 if (!run_command "$make oldnoconfig") {
1883 dodie "failed make config oldconfig"; 1982 doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
1983 # try a yes '' | oldconfig
1984 run_command "yes '' | $make oldconfig" or
1985 dodie "failed make config oldconfig";
1986 }
1884 } 1987 }
1885} 1988}
1886 1989
@@ -3700,6 +3803,11 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3700 $target = "$ssh_user\@$machine"; 3803 $target = "$ssh_user\@$machine";
3701 if ($reboot_type eq "grub") { 3804 if ($reboot_type eq "grub") {
3702 dodie "GRUB_MENU not defined" if (!defined($grub_menu)); 3805 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
3806 } elsif ($reboot_type eq "grub2") {
3807 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
3808 dodie "GRUB_FILE not defined" if (!defined($grub_file));
3809 } elsif ($reboot_type eq "syslinux") {
3810 dodie "SYSLINUX_LABEL not defined" if (!defined($syslinux_label));
3703 } 3811 }
3704 } 3812 }
3705 3813
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index de28a0a3b8fc..4012e9330344 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -332,8 +332,18 @@
332# from other linux builds on the system. 332# from other linux builds on the system.
333#LOCALVERSION = -test 333#LOCALVERSION = -test
334 334
335# For REBOOT_TYPE = grub2, you must specify where the grub.cfg
336# file is. This is the file that is searched to find the menu
337# option to boot to with GRUB_REBOOT
338#GRUB_FILE = /boot/grub2/grub.cfg
339
340# The tool for REBOOT_TYPE = grub2 to set the next reboot kernel
341# to boot into (one shot mode).
342# (default grub2_reboot)
343#GRUB_REBOOT = grub2_reboot
344
335# The grub title name for the test kernel to boot 345# The grub title name for the test kernel to boot
336# (Only mandatory if REBOOT_TYPE = grub) 346# (Only mandatory if REBOOT_TYPE = grub or grub2)
337# 347#
338# Note, ktest.pl will not update the grub menu.lst, you need to 348# Note, ktest.pl will not update the grub menu.lst, you need to
339# manually add an option for the test. ktest.pl will search 349# manually add an option for the test. ktest.pl will search
@@ -343,8 +353,33 @@
343# For example, if in the /boot/grub/menu.lst the test kernel title has: 353# For example, if in the /boot/grub/menu.lst the test kernel title has:
344# title Test Kernel 354# title Test Kernel
345# kernel vmlinuz-test 355# kernel vmlinuz-test
356#
357# For grub2, a search of top level "menuentry"s are done. No
358# submenu is searched. The menu is found by searching for the
359# contents of GRUB_MENU in the line that starts with "menuentry".
360# You may want to include the quotes around the option. For example:
361# for: menuentry 'Test Kernel'
362# do a: GRUB_MENU = 'Test Kernel'
363# For customizing, add your entry in /etc/grub.d/40_custom.
364#
346#GRUB_MENU = Test Kernel 365#GRUB_MENU = Test Kernel
347 366
367# For REBOOT_TYPE = syslinux, the name of the syslinux executable
368# (on the target) to use to set up the next reboot to boot the
369# test kernel.
370# (default extlinux)
371#SYSLINUX = syslinux
372
373# For REBOOT_TYPE = syslinux, the path that is passed to to the
374# syslinux command where syslinux is installed.
375# (default /boot/extlinux)
376#SYSLINUX_PATH = /boot/syslinux
377
378# For REBOOT_TYPE = syslinux, the syslinux label that references the
379# test kernel in the syslinux config file.
380# (default undefined)
381#SYSLINUX_LABEL = "test-kernel"
382
348# A script to reboot the target into the test kernel 383# A script to reboot the target into the test kernel
349# This and SWITCH_TO_TEST are about the same, except 384# This and SWITCH_TO_TEST are about the same, except
350# SWITCH_TO_TEST is run even for REBOOT_TYPE = grub. 385# SWITCH_TO_TEST is run even for REBOOT_TYPE = grub.
@@ -497,7 +532,7 @@
497#POST_BUILD_DIE = 1 532#POST_BUILD_DIE = 1
498 533
499# Way to reboot the box to the test kernel. 534# Way to reboot the box to the test kernel.
500# Only valid options so far are "grub" and "script" 535# Only valid options so far are "grub", "grub2", "syslinux" and "script"
501# (default grub) 536# (default grub)
502# If you specify grub, it will assume grub version 1 537# If you specify grub, it will assume grub version 1
503# and will search in /boot/grub/menu.lst for the title $GRUB_MENU 538# and will search in /boot/grub/menu.lst for the title $GRUB_MENU
@@ -505,6 +540,13 @@
505# your setup, then specify "script" and have a command or script 540# your setup, then specify "script" and have a command or script
506# specified in REBOOT_SCRIPT to boot to the target. 541# specified in REBOOT_SCRIPT to boot to the target.
507# 542#
543# For REBOOT_TYPE = grub2, you must define both GRUB_MENU and
544# GRUB_FILE.
545#
546# For REBOOT_TYPE = syslinux, you must define SYSLINUX_LABEL, and
547# perhaps modify SYSLINUX (default extlinux) and SYSLINUX_PATH
548# (default /boot/extlinux)
549#
508# The entry in /boot/grub/menu.lst must be entered in manually. 550# The entry in /boot/grub/menu.lst must be entered in manually.
509# The test will not modify that file. 551# The test will not modify that file.
510#REBOOT_TYPE = grub 552#REBOOT_TYPE = grub