ktest: Ignore errors it tests if IGNORE_ERRORS is set
[deliverable/linux.git] / tools / testing / ktest / ktest.pl
index 8ce58d715aef9cce3a5d2334f88515ae0d58caf2..a022fb7d113db840d72f3a8a6f8891d119b16c84 100755 (executable)
@@ -52,6 +52,7 @@ my %default = (
     "STOP_AFTER_SUCCESS"       => 10,
     "STOP_AFTER_FAILURE"       => 60,
     "STOP_TEST_AFTER"          => 600,
+    "MAX_MONITOR_WAIT"         => 1800,
 
 # required, and we will ask users if they don't have them but we keep the default
 # value something that is common.
@@ -98,6 +99,7 @@ my $reboot_on_success;
 my $die_on_failure;
 my $powercycle_after_reboot;
 my $poweroff_after_halt;
+my $max_monitor_wait;
 my $ssh_exec;
 my $scp_to_target;
 my $scp_to_target_install;
@@ -189,6 +191,9 @@ my $newconfig = 0;
 my %entered_configs;
 my %config_help;
 my %variable;
+
+# force_config is the list of configs that we force enabled (or disabled)
+# in a .config file. The MIN_CONFIG and ADD_CONFIG configs.
 my %force_config;
 
 # do not force reboots on config problems
@@ -240,6 +245,7 @@ my %option_map = (
     "POWER_OFF"                        => \$power_off,
     "POWERCYCLE_AFTER_REBOOT"  => \$powercycle_after_reboot,
     "POWEROFF_AFTER_HALT"      => \$poweroff_after_halt,
+    "MAX_MONITOR_WAIT"         => \$max_monitor_wait,
     "SLEEP_TIME"               => \$sleep_time,
     "BISECT_SLEEP_TIME"                => \$bisect_sleep_time,
     "PATCHCHECK_SLEEP_TIME"    => \$patchcheck_sleep_time,
@@ -1130,7 +1136,11 @@ sub reboot {
     }
 
     if (defined($time)) {
-       wait_for_monitor($time, $reboot_success_line);
+       if (wait_for_monitor($time, $reboot_success_line)) {
+           # reboot got stuck?
+           doprint "Reboot did not finish. Forcing power cycle\n";
+           run_command "$power_cycle";
+       }
        end_monitor;
     }
 }
@@ -1225,6 +1235,11 @@ sub wait_for_monitor {
     my $full_line = "";
     my $line;
     my $booted = 0;
+    my $start_time = time;
+    my $skip_call_trace = 0;
+    my $bug = 0;
+    my $bug_ignored = 0;
+    my $now;
 
     doprint "** Wait for monitor to settle down **\n";
 
@@ -1240,11 +1255,39 @@ sub wait_for_monitor {
            $booted = 1;
        }
 
+       if ($full_line =~ /\[ backtrace testing \]/) {
+           $skip_call_trace = 1;
+       }
+
+       if ($full_line =~ /call trace:/i) {
+           if (!$bug && !$skip_call_trace) {
+               if ($ignore_errors) {
+                   $bug_ignored = 1;
+               } else {
+                   $bug = 1;
+               }
+           }
+       }
+
+       if ($full_line =~ /\[ end of backtrace testing \]/) {
+           $skip_call_trace = 0;
+       }
+
+       if ($full_line =~ /Kernel panic -/) {
+           $bug = 1;
+       }
+
        if ($line =~ /\n/) {
            $full_line = "";
        }
+       $now = time;
+       if ($now - $start_time >= $max_monitor_wait) {
+           doprint "Exiting monitor flush due to hitting MAX_MONITOR_WAIT\n";
+           return 1;
+       }
     }
     print "** Monitor flushed **\n";
+    return $bug;
 }
 
 sub save_logs {
@@ -1837,6 +1880,7 @@ sub make_oldconfig {
 sub load_force_config {
     my ($config) = @_;
 
+    doprint "Loading force configs from $config\n";
     open(IN, $config) or
        dodie "failed to read $config";
     while (<IN>) {
@@ -2030,6 +2074,7 @@ sub do_run_test {
     my $line;
     my $full_line;
     my $bug = 0;
+    my $bug_ignored = 0;
 
     wait_for_monitor 1;
 
@@ -2054,7 +2099,11 @@ sub do_run_test {
            doprint $line;
 
            if ($full_line =~ /call trace:/i) {
-               $bug = 1;
+               if ($ignore_errors) {
+                   $bug_ignored = 1;
+               } else {
+                   $bug = 1;
+               }
            }
 
            if ($full_line =~ /Kernel panic -/) {
@@ -2067,6 +2116,10 @@ sub do_run_test {
        }
     } while (!$child_done && !$bug);
 
+    if (!$bug && $bug_ignored) {
+       doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
+    }
+
     if ($bug) {
        my $failure_start = time;
        my $now;
@@ -2389,9 +2442,24 @@ sub bisect {
     success $i;
 }
 
+# config_ignore holds the configs that were set (or unset) for
+# a good config and we will ignore these configs for the rest
+# of a config bisect. These configs stay as they were.
 my %config_ignore;
+
+# config_set holds what all configs were set as.
 my %config_set;
 
+# config_off holds the set of configs that the bad config had disabled.
+# We need to record them and set them in the .config when running
+# oldnoconfig, because oldnoconfig does not turn off new symbols, but
+# instead just keeps the defaults.
+my %config_off;
+
+# config_off_tmp holds a set of configs to turn off for now
+my @config_off_tmp;
+
+# config_list is the set of configs that are being tested
 my %config_list;
 my %null_config;
 
@@ -2470,6 +2538,16 @@ sub create_config {
        }
     }
 
+    # turn off configs to keep off
+    foreach my $config (keys %config_off) {
+       print OUT "# $config is not set\n";
+    }
+
+    # turn off configs that should be off for now
+    foreach my $config (@config_off_tmp) {
+       print OUT "# $config is not set\n";
+    }
+
     foreach my $config (keys %config_ignore) {
        print OUT "$config_ignore{$config}\n";
     }
@@ -2551,6 +2629,13 @@ sub run_config_bisect {
     do {
        my @tophalf = @start_list[0 .. $half];
 
+       # keep the bottom half off
+       if ($half < $#start_list) {
+           @config_off_tmp = @start_list[$half + 1 .. $#start_list];
+       } else {
+           @config_off_tmp = ();
+       }
+
        create_config @tophalf;
        read_current_config \%current_config;
 
@@ -2567,7 +2652,11 @@ sub run_config_bisect {
        if (!$found) {
            # try the other half
            doprint "Top half produced no set configs, trying bottom half\n";
+
+           # keep the top half off
+           @config_off_tmp = @tophalf;
            @tophalf = @start_list[$half + 1 .. $#start_list];
+
            create_config @tophalf;
            read_current_config \%current_config;
            foreach my $config (@tophalf) {
@@ -2705,6 +2794,10 @@ sub config_bisect {
                $added_configs{$2} = $1;
                $config_list{$2} = $1;
            }
+       } elsif (/^# ((CONFIG\S*).*)/) {
+           # Keep these configs disabled
+           $config_set{$2} = $1;
+           $config_off{$2} = $1;
        }
     }
     close(IN);
@@ -2727,6 +2820,8 @@ sub config_bisect {
     my %config_test;
     my $once = 0;
 
+    @config_off_tmp = ();
+
     # Sometimes kconfig does weird things. We must make sure
     # that the config we autocreate has everything we need
     # to test, otherwise we may miss testing configs, or
@@ -3548,6 +3643,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
 
     $iteration = $i;
 
+    undef %force_config;
+
     my $makecmd = set_test_option("MAKE_CMD", $i);
 
     # Load all the options into their mapped variable names
This page took 0.029508 seconds and 5 git commands to generate.