Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'ktest-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest

Pull more ktest updates from Steven Rostedt:

- Add support for grub2bls boot loader

- Show name and test iteration number in error message sent in mail

- Minor fixes and clean ups

* tag 'ktest-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
ktest: update sample.conf for grub2bls
ktest: remove get_grub2_index
ktest: pass KERNEL_VERSION to POST_KTEST
ktest: introduce grub2bls REBOOT_TYPE option
ktest: cleanup get_grub_index
ktest: introduce _get_grub_index

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