aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 21:03:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 21:03:21 -0500
commite05a1c6397a73d09389e033b6b2c25c954d2177c (patch)
tree699490e0c4f9f130361f4cd0dccc9a730e55dc75 /tools
parent66cdd0ceaf65a18996f561b770eedde1d123b019 (diff)
parente1a6c3d748ef0ee093e764af3fdd0c1a5cd2b664 (diff)
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 c7ba7614061..35fc584a4ff 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.
1812s