diff options
| -rwxr-xr-x | tools/testing/ktest/ktest.pl | 89 | ||||
| -rw-r--r-- | tools/testing/ktest/sample.conf | 20 |
2 files changed, 62 insertions, 47 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 275ad8ac8872..4711f57e809a 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -64,6 +64,7 @@ my %default = ( | |||
| 64 | "STOP_TEST_AFTER" => 600, | 64 | "STOP_TEST_AFTER" => 600, |
| 65 | "MAX_MONITOR_WAIT" => 1800, | 65 | "MAX_MONITOR_WAIT" => 1800, |
| 66 | "GRUB_REBOOT" => "grub2-reboot", | 66 | "GRUB_REBOOT" => "grub2-reboot", |
| 67 | "GRUB_BLS_GET" => "grubby --info=ALL", | ||
| 67 | "SYSLINUX" => "extlinux", | 68 | "SYSLINUX" => "extlinux", |
| 68 | "SYSLINUX_PATH" => "/boot/extlinux", | 69 | "SYSLINUX_PATH" => "/boot/extlinux", |
| 69 | "CONNECT_TIMEOUT" => 25, | 70 | "CONNECT_TIMEOUT" => 25, |
| @@ -125,6 +126,7 @@ my $last_grub_menu; | |||
| 125 | my $grub_file; | 126 | my $grub_file; |
| 126 | my $grub_number; | 127 | my $grub_number; |
| 127 | my $grub_reboot; | 128 | my $grub_reboot; |
| 129 | my $grub_bls_get; | ||
| 128 | my $syslinux; | 130 | my $syslinux; |
| 129 | my $syslinux_path; | 131 | my $syslinux_path; |
| 130 | my $syslinux_label; | 132 | my $syslinux_label; |
| @@ -295,6 +297,7 @@ my %option_map = ( | |||
| 295 | "GRUB_MENU" => \$grub_menu, | 297 | "GRUB_MENU" => \$grub_menu, |
| 296 | "GRUB_FILE" => \$grub_file, | 298 | "GRUB_FILE" => \$grub_file, |
| 297 | "GRUB_REBOOT" => \$grub_reboot, | 299 | "GRUB_REBOOT" => \$grub_reboot, |
| 300 | "GRUB_BLS_GET" => \$grub_bls_get, | ||
| 298 | "SYSLINUX" => \$syslinux, | 301 | "SYSLINUX" => \$syslinux, |
| 299 | "SYSLINUX_PATH" => \$syslinux_path, | 302 | "SYSLINUX_PATH" => \$syslinux_path, |
| 300 | "SYSLINUX_LABEL" => \$syslinux_label, | 303 | "SYSLINUX_LABEL" => \$syslinux_label, |
| @@ -440,7 +443,7 @@ EOF | |||
| 440 | ; | 443 | ; |
| 441 | $config_help{"REBOOT_TYPE"} = << "EOF" | 444 | $config_help{"REBOOT_TYPE"} = << "EOF" |
| 442 | Way to reboot the box to the test kernel. | 445 | Way to reboot the box to the test kernel. |
| 443 | Only valid options so far are "grub", "grub2", "syslinux", and "script". | 446 | Only valid options so far are "grub", "grub2", "grub2bls", "syslinux", and "script". |
| 444 | 447 | ||
| 445 | If you specify grub, it will assume grub version 1 | 448 | If you specify grub, it will assume grub version 1 |
| 446 | and will search in /boot/grub/menu.lst for the title \$GRUB_MENU | 449 | and will search in /boot/grub/menu.lst for the title \$GRUB_MENU |
| @@ -454,6 +457,8 @@ $config_help{"REBOOT_TYPE"} = << "EOF" | |||
| 454 | If you specify grub2, then you also need to specify both \$GRUB_MENU | 457 | If you specify grub2, then you also need to specify both \$GRUB_MENU |
| 455 | and \$GRUB_FILE. | 458 | and \$GRUB_FILE. |
| 456 | 459 | ||
| 460 | If you specify grub2bls, then you also need to specify \$GRUB_MENU. | ||
| 461 | |||
| 457 | If you specify syslinux, then you may use SYSLINUX to define the syslinux | 462 | If you specify syslinux, then you may use SYSLINUX to define the syslinux |
| 458 | command (defaults to extlinux), and SYSLINUX_PATH to specify the path to | 463 | command (defaults to extlinux), and SYSLINUX_PATH to specify the path to |
| 459 | the syslinux install (defaults to /boot/extlinux). But you have to specify | 464 | the syslinux install (defaults to /boot/extlinux). But you have to specify |
| @@ -479,6 +484,9 @@ $config_help{"GRUB_MENU"} = << "EOF" | |||
| 479 | menu must be a non-nested menu. Add the quotes used in the menu | 484 | menu must be a non-nested menu. Add the quotes used in the menu |
| 480 | to guarantee your selection, as the first menuentry with the content | 485 | to guarantee your selection, as the first menuentry with the content |
| 481 | of \$GRUB_MENU that is found will be used. | 486 | of \$GRUB_MENU that is found will be used. |
| 487 | |||
| 488 | For grub2bls, \$GRUB_MENU is searched on the result of \$GRUB_BLS_GET | ||
| 489 | command for the lines that begin with "title". | ||
| 482 | EOF | 490 | EOF |
| 483 | ; | 491 | ; |
| 484 | $config_help{"GRUB_FILE"} = << "EOF" | 492 | $config_help{"GRUB_FILE"} = << "EOF" |
| @@ -695,7 +703,7 @@ sub get_mandatory_configs { | |||
| 695 | } | 703 | } |
| 696 | } | 704 | } |
| 697 | 705 | ||
| 698 | if ($rtype eq "grub") { | 706 | if (($rtype eq "grub") or ($rtype eq "grub2bls")) { |
| 699 | get_mandatory_config("GRUB_MENU"); | 707 | get_mandatory_config("GRUB_MENU"); |
| 700 | } | 708 | } |
| 701 | 709 | ||
| @@ -1871,36 +1879,37 @@ sub run_scp_mod { | |||
| 1871 | return run_scp($src, $dst, $cp_scp); | 1879 | return run_scp($src, $dst, $cp_scp); |
| 1872 | } | 1880 | } |
| 1873 | 1881 | ||
| 1874 | sub get_grub2_index { | 1882 | sub _get_grub_index { |
| 1883 | |||
| 1884 | my ($command, $target, $skip) = @_; | ||
| 1875 | 1885 | ||
| 1876 | return if (defined($grub_number) && defined($last_grub_menu) && | 1886 | return if (defined($grub_number) && defined($last_grub_menu) && |
| 1877 | $last_grub_menu eq $grub_menu && defined($last_machine) && | 1887 | $last_grub_menu eq $grub_menu && defined($last_machine) && |
| 1878 | $last_machine eq $machine); | 1888 | $last_machine eq $machine); |
| 1879 | 1889 | ||
| 1880 | doprint "Find grub2 menu ... "; | 1890 | doprint "Find $reboot_type menu ... "; |
| 1881 | $grub_number = -1; | 1891 | $grub_number = -1; |
| 1882 | 1892 | ||
| 1883 | my $ssh_grub = $ssh_exec; | 1893 | my $ssh_grub = $ssh_exec; |
| 1884 | $ssh_grub =~ s,\$SSH_COMMAND,cat $grub_file,g; | 1894 | $ssh_grub =~ s,\$SSH_COMMAND,$command,g; |
| 1885 | 1895 | ||
| 1886 | open(IN, "$ssh_grub |") | 1896 | open(IN, "$ssh_grub |") |
| 1887 | or dodie "unable to get $grub_file"; | 1897 | or dodie "unable to execute $command"; |
| 1888 | 1898 | ||
| 1889 | my $found = 0; | 1899 | my $found = 0; |
| 1890 | my $grub_menu_qt = quotemeta($grub_menu); | ||
| 1891 | 1900 | ||
| 1892 | while (<IN>) { | 1901 | while (<IN>) { |
| 1893 | if (/^menuentry.*$grub_menu_qt/) { | 1902 | if (/$target/) { |
| 1894 | $grub_number++; | 1903 | $grub_number++; |
| 1895 | $found = 1; | 1904 | $found = 1; |
| 1896 | last; | 1905 | last; |
| 1897 | } elsif (/^menuentry\s|^submenu\s/) { | 1906 | } elsif (/$skip/) { |
| 1898 | $grub_number++; | 1907 | $grub_number++; |
| 1899 | } | 1908 | } |
| 1900 | } | 1909 | } |
| 1901 | close(IN); | 1910 | close(IN); |
| 1902 | 1911 | ||
| 1903 | dodie "Could not find '$grub_menu' in $grub_file on $machine" | 1912 | dodie "Could not find '$grub_menu' through $command on $machine" |
| 1904 | if (!$found); | 1913 | if (!$found); |
| 1905 | doprint "$grub_number\n"; | 1914 | doprint "$grub_number\n"; |
| 1906 | $last_grub_menu = $grub_menu; | 1915 | $last_grub_menu = $grub_menu; |
| @@ -1909,46 +1918,34 @@ sub get_grub2_index { | |||
| 1909 | 1918 | ||
| 1910 | sub get_grub_index { | 1919 | sub get_grub_index { |
| 1911 | 1920 | ||
| 1912 | if ($reboot_type eq "grub2") { | 1921 | my $command; |
| 1913 | get_grub2_index; | 1922 | my $target; |
| 1914 | return; | 1923 | my $skip; |
| 1915 | } | 1924 | my $grub_menu_qt; |
| 1916 | 1925 | ||
| 1917 | if ($reboot_type ne "grub") { | 1926 | if ($reboot_type !~ /^grub/) { |
| 1918 | return; | 1927 | return; |
| 1919 | } | 1928 | } |
| 1920 | return if (defined($grub_number) && defined($last_grub_menu) && | ||
| 1921 | $last_grub_menu eq $grub_menu && defined($last_machine) && | ||
| 1922 | $last_machine eq $machine); | ||
| 1923 | 1929 | ||
| 1924 | doprint "Find grub menu ... "; | 1930 | $grub_menu_qt = quotemeta($grub_menu); |
| 1925 | $grub_number = -1; | ||
| 1926 | |||
| 1927 | my $ssh_grub = $ssh_exec; | ||
| 1928 | $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g; | ||
| 1929 | |||
| 1930 | open(IN, "$ssh_grub |") | ||
| 1931 | or dodie "unable to get menu.lst"; | ||
| 1932 | |||
| 1933 | my $found = 0; | ||
| 1934 | my $grub_menu_qt = quotemeta($grub_menu); | ||
| 1935 | 1931 | ||
| 1936 | while (<IN>) { | 1932 | if ($reboot_type eq "grub") { |
| 1937 | if (/^\s*title\s+$grub_menu_qt\s*$/) { | 1933 | $command = "cat /boot/grub/menu.lst"; |
| 1938 | $grub_number++; | 1934 | $target = '^\s*title\s+' . $grub_menu_qt . '\s*$'; |
| 1939 | $found = 1; | 1935 | $skip = '^\s*title\s'; |
| 1940 | last; | 1936 | } elsif ($reboot_type eq "grub2") { |
| 1941 | } elsif (/^\s*title\s/) { | 1937 | $command = "cat $grub_file"; |
| 1942 | $grub_number++; | 1938 | $target = '^menuentry.*' . $grub_menu_qt; |
| 1943 | } | 1939 | $skip = '^menuentry\s|^submenu\s'; |
| 1940 | } elsif ($reboot_type eq "grub2bls") { | ||
| 1941 | $command = $grub_bls_get; | ||
| 1942 | $target = '^title=.*' . $grub_menu_qt; | ||
| 1943 | $skip = '^title='; | ||
| 1944 | } else { | ||
| 1945 | return; | ||
| 1944 | } | 1946 | } |
| 1945 | close(IN); | ||
| 1946 | 1947 | ||
| 1947 | dodie "Could not find '$grub_menu' in /boot/grub/menu on $machine" | 1948 | _get_grub_index($command, $target, $skip); |
| 1948 | if (!$found); | ||
| 1949 | doprint "$grub_number\n"; | ||
| 1950 | $last_grub_menu = $grub_menu; | ||
| 1951 | $last_machine = $machine; | ||
| 1952 | } | 1949 | } |
| 1953 | 1950 | ||
| 1954 | sub wait_for_input | 1951 | sub wait_for_input |
| @@ -4303,7 +4300,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
| 4303 | 4300 | ||
| 4304 | if (!$buildonly) { | 4301 | if (!$buildonly) { |
| 4305 | $target = "$ssh_user\@$machine"; | 4302 | $target = "$ssh_user\@$machine"; |
| 4306 | if ($reboot_type eq "grub") { | 4303 | if (($reboot_type eq "grub") or ($reboot_type eq "grub2bls")) { |
| 4307 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); | 4304 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); |
| 4308 | } elsif ($reboot_type eq "grub2") { | 4305 | } elsif ($reboot_type eq "grub2") { |
| 4309 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); | 4306 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); |
| @@ -4423,7 +4420,9 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
| 4423 | } | 4420 | } |
| 4424 | 4421 | ||
| 4425 | if (defined($final_post_ktest)) { | 4422 | if (defined($final_post_ktest)) { |
| 4426 | run_command $final_post_ktest; | 4423 | |
| 4424 | my $cp_final_post_ktest = eval_kernel_version $final_post_ktest; | ||
| 4425 | run_command $cp_final_post_ktest; | ||
| 4427 | } | 4426 | } |
| 4428 | 4427 | ||
| 4429 | if ($opt{"POWEROFF_ON_SUCCESS"}) { | 4428 | if ($opt{"POWEROFF_ON_SUCCESS"}) { |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index 8c893a58b68e..c3bc933d437b 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
| @@ -349,13 +349,13 @@ | |||
| 349 | # option to boot to with GRUB_REBOOT | 349 | # option to boot to with GRUB_REBOOT |
| 350 | #GRUB_FILE = /boot/grub2/grub.cfg | 350 | #GRUB_FILE = /boot/grub2/grub.cfg |
| 351 | 351 | ||
| 352 | # The tool for REBOOT_TYPE = grub2 to set the next reboot kernel | 352 | # The tool for REBOOT_TYPE = grub2 or grub2bls to set the next reboot kernel |
| 353 | # to boot into (one shot mode). | 353 | # to boot into (one shot mode). |
| 354 | # (default grub2_reboot) | 354 | # (default grub2_reboot) |
| 355 | #GRUB_REBOOT = grub2_reboot | 355 | #GRUB_REBOOT = grub2_reboot |
| 356 | 356 | ||
| 357 | # The grub title name for the test kernel to boot | 357 | # The grub title name for the test kernel to boot |
| 358 | # (Only mandatory if REBOOT_TYPE = grub or grub2) | 358 | # (Only mandatory if REBOOT_TYPE = grub or grub2 or grub2bls) |
| 359 | # | 359 | # |
| 360 | # Note, ktest.pl will not update the grub menu.lst, you need to | 360 | # Note, ktest.pl will not update the grub menu.lst, you need to |
| 361 | # manually add an option for the test. ktest.pl will search | 361 | # manually add an option for the test. ktest.pl will search |
| @@ -374,6 +374,10 @@ | |||
| 374 | # do a: GRUB_MENU = 'Test Kernel' | 374 | # do a: GRUB_MENU = 'Test Kernel' |
| 375 | # For customizing, add your entry in /etc/grub.d/40_custom. | 375 | # For customizing, add your entry in /etc/grub.d/40_custom. |
| 376 | # | 376 | # |
| 377 | # For grub2bls, a search of "title"s are done. The menu is found | ||
| 378 | # by searching for the contents of GRUB_MENU in the line that starts | ||
| 379 | # with "title". | ||
| 380 | # | ||
| 377 | #GRUB_MENU = Test Kernel | 381 | #GRUB_MENU = Test Kernel |
| 378 | 382 | ||
| 379 | # For REBOOT_TYPE = syslinux, the name of the syslinux executable | 383 | # For REBOOT_TYPE = syslinux, the name of the syslinux executable |
| @@ -479,6 +483,11 @@ | |||
| 479 | # default (undefined) | 483 | # default (undefined) |
| 480 | #POST_KTEST = ${SSH} ~/dismantle_test | 484 | #POST_KTEST = ${SSH} ~/dismantle_test |
| 481 | 485 | ||
| 486 | # If you want to remove the kernel entry in Boot Loader Specification (BLS) | ||
| 487 | # environment, use kernel-install command. | ||
| 488 | # Here's the example: | ||
| 489 | #POST_KTEST = ssh root@Test "/usr/bin/kernel-install remove $KERNEL_VERSION" | ||
| 490 | |||
| 482 | # The default test type (default test) | 491 | # The default test type (default test) |
| 483 | # The test types may be: | 492 | # The test types may be: |
| 484 | # build - only build the kernel, do nothing else | 493 | # build - only build the kernel, do nothing else |
| @@ -530,6 +539,11 @@ | |||
| 530 | # or on some systems: | 539 | # or on some systems: |
| 531 | #POST_INSTALL = ssh user@target /sbin/dracut -f /boot/initramfs-test.img $KERNEL_VERSION | 540 | #POST_INSTALL = ssh user@target /sbin/dracut -f /boot/initramfs-test.img $KERNEL_VERSION |
| 532 | 541 | ||
| 542 | # If you want to add the kernel entry in Boot Loader Specification (BLS) | ||
| 543 | # environment, use kernel-install command. | ||
| 544 | # Here's the example: | ||
| 545 | #POST_INSTALL = ssh root@Test "/usr/bin/kernel-install add $KERNEL_VERSION /boot/vmlinuz-$KERNEL_VERSION" | ||
| 546 | |||
| 533 | # If for some reason you just want to boot the kernel and you do not | 547 | # If for some reason you just want to boot the kernel and you do not |
| 534 | # want the test to install anything new. For example, you may just want | 548 | # want the test to install anything new. For example, you may just want |
| 535 | # to boot test the same kernel over and over and do not want to go through | 549 | # to boot test the same kernel over and over and do not want to go through |
| @@ -593,6 +607,8 @@ | |||
| 593 | # For REBOOT_TYPE = grub2, you must define both GRUB_MENU and | 607 | # For REBOOT_TYPE = grub2, you must define both GRUB_MENU and |
| 594 | # GRUB_FILE. | 608 | # GRUB_FILE. |
| 595 | # | 609 | # |
| 610 | # For REBOOT_TYPE = grub2bls, you must define GRUB_MENU. | ||
| 611 | # | ||
| 596 | # For REBOOT_TYPE = syslinux, you must define SYSLINUX_LABEL, and | 612 | # For REBOOT_TYPE = syslinux, you must define SYSLINUX_LABEL, and |
| 597 | # perhaps modify SYSLINUX (default extlinux) and SYSLINUX_PATH | 613 | # perhaps modify SYSLINUX (default extlinux) and SYSLINUX_PATH |
| 598 | # (default /boot/extlinux) | 614 | # (default /boot/extlinux) |
