.. | .. |
---|
178 | 178 | my $store_successes; |
---|
179 | 179 | my $test_name; |
---|
180 | 180 | my $timeout; |
---|
| 181 | +my $run_timeout; |
---|
181 | 182 | my $connect_timeout; |
---|
182 | 183 | my $config_bisect_exec; |
---|
183 | 184 | my $booted_timeout; |
---|
.. | .. |
---|
340 | 341 | "STORE_SUCCESSES" => \$store_successes, |
---|
341 | 342 | "TEST_NAME" => \$test_name, |
---|
342 | 343 | "TIMEOUT" => \$timeout, |
---|
| 344 | + "RUN_TIMEOUT" => \$run_timeout, |
---|
343 | 345 | "CONNECT_TIMEOUT" => \$connect_timeout, |
---|
344 | 346 | "CONFIG_BISECT_EXEC" => \$config_bisect_exec, |
---|
345 | 347 | "BOOTED_TIMEOUT" => \$booted_timeout, |
---|
.. | .. |
---|
1433 | 1435 | |
---|
1434 | 1436 | # Still need to wait for the reboot to finish |
---|
1435 | 1437 | wait_for_monitor($time, $reboot_success_line); |
---|
1436 | | - |
---|
| 1438 | + } |
---|
| 1439 | + if ($powercycle || $time) { |
---|
1437 | 1440 | end_monitor; |
---|
1438 | 1441 | } |
---|
1439 | 1442 | } |
---|
.. | .. |
---|
1799 | 1802 | $command =~ s/\$SSH_USER/$ssh_user/g; |
---|
1800 | 1803 | $command =~ s/\$MACHINE/$machine/g; |
---|
1801 | 1804 | |
---|
| 1805 | + if (!defined($timeout)) { |
---|
| 1806 | + $timeout = $run_timeout; |
---|
| 1807 | + } |
---|
| 1808 | + |
---|
| 1809 | + if (!defined($timeout)) { |
---|
| 1810 | + $timeout = -1; # tell wait_for_input to wait indefinitely |
---|
| 1811 | + } |
---|
| 1812 | + |
---|
1802 | 1813 | doprint("$command ... "); |
---|
1803 | 1814 | $start_time = time; |
---|
1804 | 1815 | |
---|
.. | .. |
---|
1825 | 1836 | |
---|
1826 | 1837 | while (1) { |
---|
1827 | 1838 | my $fp = \*CMD; |
---|
1828 | | - if (defined($timeout)) { |
---|
1829 | | - doprint "timeout = $timeout\n"; |
---|
1830 | | - } |
---|
1831 | 1839 | my $line = wait_for_input($fp, $timeout); |
---|
1832 | 1840 | if (!defined($line)) { |
---|
1833 | 1841 | my $now = time; |
---|
1834 | | - if (defined($timeout) && (($now - $start_time) >= $timeout)) { |
---|
| 1842 | + if ($timeout >= 0 && (($now - $start_time) >= $timeout)) { |
---|
1835 | 1843 | doprint "Hit timeout of $timeout, killing process\n"; |
---|
1836 | 1844 | $hit_timeout = 1; |
---|
1837 | 1845 | kill 9, $pid; |
---|
.. | .. |
---|
1912 | 1920 | |
---|
1913 | 1921 | sub _get_grub_index { |
---|
1914 | 1922 | |
---|
1915 | | - my ($command, $target, $skip) = @_; |
---|
| 1923 | + my ($command, $target, $skip, $submenu) = @_; |
---|
1916 | 1924 | |
---|
1917 | 1925 | return if (defined($grub_number) && defined($last_grub_menu) && |
---|
1918 | 1926 | $last_grub_menu eq $grub_menu && defined($last_machine) && |
---|
.. | .. |
---|
1929 | 1937 | |
---|
1930 | 1938 | my $found = 0; |
---|
1931 | 1939 | |
---|
| 1940 | + my $submenu_number = 0; |
---|
| 1941 | + |
---|
1932 | 1942 | while (<IN>) { |
---|
1933 | 1943 | if (/$target/) { |
---|
1934 | 1944 | $grub_number++; |
---|
1935 | 1945 | $found = 1; |
---|
1936 | 1946 | last; |
---|
| 1947 | + } elsif (defined($submenu) && /$submenu/) { |
---|
| 1948 | + $submenu_number++; |
---|
| 1949 | + $grub_number = -1; |
---|
1937 | 1950 | } elsif (/$skip/) { |
---|
1938 | 1951 | $grub_number++; |
---|
1939 | 1952 | } |
---|
.. | .. |
---|
1942 | 1955 | |
---|
1943 | 1956 | dodie "Could not find '$grub_menu' through $command on $machine" |
---|
1944 | 1957 | if (!$found); |
---|
| 1958 | + if ($submenu_number > 0) { |
---|
| 1959 | + $grub_number = "$submenu_number>$grub_number"; |
---|
| 1960 | + } |
---|
1945 | 1961 | doprint "$grub_number\n"; |
---|
1946 | 1962 | $last_grub_menu = $grub_menu; |
---|
1947 | 1963 | $last_machine = $machine; |
---|
.. | .. |
---|
1952 | 1968 | my $command; |
---|
1953 | 1969 | my $target; |
---|
1954 | 1970 | my $skip; |
---|
| 1971 | + my $submenu; |
---|
1955 | 1972 | my $grub_menu_qt; |
---|
1956 | 1973 | |
---|
1957 | 1974 | if ($reboot_type !~ /^grub/) { |
---|
.. | .. |
---|
1966 | 1983 | $skip = '^\s*title\s'; |
---|
1967 | 1984 | } elsif ($reboot_type eq "grub2") { |
---|
1968 | 1985 | $command = "cat $grub_file"; |
---|
1969 | | - $target = '^menuentry.*' . $grub_menu_qt; |
---|
1970 | | - $skip = '^menuentry\s|^submenu\s'; |
---|
| 1986 | + $target = '^\s*menuentry.*' . $grub_menu_qt; |
---|
| 1987 | + $skip = '^\s*menuentry'; |
---|
| 1988 | + $submenu = '^\s*submenu\s'; |
---|
1971 | 1989 | } elsif ($reboot_type eq "grub2bls") { |
---|
1972 | 1990 | $command = $grub_bls_get; |
---|
1973 | 1991 | $target = '^title=.*' . $grub_menu_qt; |
---|
.. | .. |
---|
1976 | 1994 | return; |
---|
1977 | 1995 | } |
---|
1978 | 1996 | |
---|
1979 | | - _get_grub_index($command, $target, $skip); |
---|
| 1997 | + _get_grub_index($command, $target, $skip, $submenu); |
---|
1980 | 1998 | } |
---|
1981 | 1999 | |
---|
1982 | 2000 | sub wait_for_input |
---|
.. | .. |
---|
1992 | 2010 | |
---|
1993 | 2011 | if (!defined($time)) { |
---|
1994 | 2012 | $time = $timeout; |
---|
| 2013 | + } |
---|
| 2014 | + |
---|
| 2015 | + if ($time < 0) { |
---|
| 2016 | + # Negative number means wait indefinitely |
---|
| 2017 | + undef $time; |
---|
1995 | 2018 | } |
---|
1996 | 2019 | |
---|
1997 | 2020 | $rin = ''; |
---|
.. | .. |
---|
2040 | 2063 | if ($reboot_type eq "grub") { |
---|
2041 | 2064 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; |
---|
2042 | 2065 | } elsif (($reboot_type eq "grub2") or ($reboot_type eq "grub2bls")) { |
---|
2043 | | - run_ssh "$grub_reboot $grub_number"; |
---|
| 2066 | + run_ssh "$grub_reboot \"'$grub_number'\""; |
---|
2044 | 2067 | } elsif ($reboot_type eq "syslinux") { |
---|
2045 | 2068 | run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path"; |
---|
2046 | 2069 | } elsif (defined $reboot_script) { |
---|
.. | .. |
---|
3763 | 3786 | # .config to make sure it is missing the config that |
---|
3764 | 3787 | # we had before |
---|
3765 | 3788 | my %configs = %min_configs; |
---|
3766 | | - delete $configs{$config}; |
---|
| 3789 | + $configs{$config} = "# $config is not set"; |
---|
3767 | 3790 | make_new_config ((values %configs), (values %keep_configs)); |
---|
3768 | 3791 | make_oldconfig; |
---|
| 3792 | + delete $configs{$config}; |
---|
3769 | 3793 | undef %configs; |
---|
3770 | 3794 | assign_configs \%configs, $output_config; |
---|
3771 | 3795 | |
---|
.. | .. |
---|
4272 | 4296 | } |
---|
4273 | 4297 | |
---|
4274 | 4298 | sub cancel_test { |
---|
| 4299 | + if ($monitor_cnt) { |
---|
| 4300 | + end_monitor; |
---|
| 4301 | + } |
---|
4275 | 4302 | if ($email_when_canceled) { |
---|
4276 | 4303 | my $name = get_test_name; |
---|
4277 | 4304 | send_email("KTEST: Your [$name] test was cancelled", |
---|