3636$default {" POWEROFF_ON_SUCCESS" } = 0;
3737$default {" BUILD_OPTIONS" } = " " ;
3838$default {" BISECT_SLEEP_TIME" } = 60; # sleep time between bisects
39+ $default {" PATCHCHECK_SLEEP_TIME" } = 60; # sleep time between patch checks
3940$default {" CLEAR_LOG" } = 0;
4041$default {" BISECT_MANUAL" } = 0;
4142$default {" BISECT_SKIP" } = 1;
9697my $monitor_cnt = 0;
9798my $sleep_time ;
9899my $bisect_sleep_time ;
100+ my $patchcheck_sleep_time ;
99101my $store_failures ;
100102my $timeout ;
101103my $booted_timeout ;
112114
113115my %entered_configs ;
114116my %config_help ;
117+ my %variable ;
115118
116119$config_help {" MACHINE" } = << "EOF"
117120 The machine hostname that you will test.
@@ -260,6 +263,39 @@ sub get_ktest_configs {
260263 }
261264}
262265
266+ sub process_variables {
267+ my ($value ) = @_ ;
268+ my $retval = " " ;
269+
270+ # We want to check for '\', and it is just easier
271+ # to check the previous characet of '$' and not need
272+ # to worry if '$' is the first character. By adding
273+ # a space to $value, we can just check [^\\]\$ and
274+ # it will still work.
275+ $value = " $value " ;
276+
277+ while ($value =~ / (.*?[^\\ ])\$\{ (.*?)\} (.*)/ ) {
278+ my $begin = $1 ;
279+ my $var = $2 ;
280+ my $end = $3 ;
281+ # append beginning of value to retval
282+ $retval = " $retval$begin " ;
283+ if (defined ($variable {$var })) {
284+ $retval = " $retval$variable {$var }" ;
285+ } else {
286+ # put back the origin piece.
287+ $retval = " $retval \$\{ $var \} " ;
288+ }
289+ $value = $end ;
290+ }
291+ $retval = " $retval$value " ;
292+
293+ # remove the space added in the beginning
294+ $retval =~ s / // ;
295+
296+ return " $retval "
297+ }
298+
263299sub set_value {
264300 my ($lvalue , $rvalue ) = @_ ;
265301
@@ -269,10 +305,22 @@ sub set_value {
269305 if ($rvalue =~ / ^\s *$ / ) {
270306 delete $opt {$lvalue };
271307 } else {
308+ $rvalue = process_variables($rvalue );
272309 $opt {$lvalue } = $rvalue ;
273310 }
274311}
275312
313+ sub set_variable {
314+ my ($lvalue , $rvalue ) = @_ ;
315+
316+ if ($rvalue =~ / ^\s *$ / ) {
317+ delete $variable {$lvalue };
318+ } else {
319+ $rvalue = process_variables($rvalue );
320+ $variable {$lvalue } = $rvalue ;
321+ }
322+ }
323+
276324sub read_config {
277325 my ($config ) = @_ ;
278326
@@ -385,6 +433,22 @@ sub read_config {
385433 $repeats {$val } = $repeat ;
386434 }
387435 }
436+ } elsif (/ ^\s *([A-Z_\[\]\d ]+)\s *:=\s *(.*?)\s *$ / ) {
437+ next if ($skip );
438+
439+ my $lvalue = $1 ;
440+ my $rvalue = $2 ;
441+
442+ # process config variables.
443+ # Config variables are only active while reading the
444+ # config and can be defined anywhere. They also ignore
445+ # TEST_START and DEFAULTS, but are skipped if they are in
446+ # on of these sections that have SKIP defined.
447+ # The save variable can be
448+ # defined multiple times and the new one simply overrides
449+ # the prevous one.
450+ set_variable($lvalue , $rvalue );
451+
388452 } else {
389453 die " $name : $. : Garbage found in config\n $_ " ;
390454 }
@@ -838,6 +902,7 @@ sub monitor {
838902
839903 if ($stop_test_after > 0 && !$booted && !$bug ) {
840904 if (time - $monitor_start > $stop_test_after ) {
905+ doprint " STOP_TEST_AFTER ($stop_test_after seconds) timed out\n " ;
841906 $done = 1;
842907 }
843908 }
@@ -907,7 +972,7 @@ sub install {
907972 return if (!defined ($post_install ));
908973
909974 my $cp_post_install = $post_install ;
910- $cp_post_install = s /\$ KERNEL_VERSION/ $version / g ;
975+ $cp_post_install =~ s /\$ KERNEL_VERSION/ $version / g ;
911976 run_command " $cp_post_install " or
912977 dodie " Failed to run post install" ;
913978}
@@ -1247,14 +1312,14 @@ sub run_bisect_test {
12471312
12481313 if ($failed ) {
12491314 $result = 0;
1250-
1251- # reboot the box to a good kernel
1252- if ($type ne " build" ) {
1253- bisect_reboot;
1254- }
12551315 } else {
12561316 $result = 1;
12571317 }
1318+
1319+ # reboot the box to a kernel we can ssh to
1320+ if ($type ne " build" ) {
1321+ bisect_reboot;
1322+ }
12581323 $in_bisect = 0;
12591324
12601325 return $result ;
@@ -1763,6 +1828,14 @@ sub config_bisect {
17631828 success $i ;
17641829}
17651830
1831+ sub patchcheck_reboot {
1832+ doprint " Reboot and sleep $patchcheck_sleep_time seconds\n " ;
1833+ reboot;
1834+ start_monitor;
1835+ wait_for_monitor $patchcheck_sleep_time ;
1836+ end_monitor;
1837+ }
1838+
17661839sub patchcheck {
17671840 my ($i ) = @_ ;
17681841
@@ -1854,6 +1927,8 @@ sub patchcheck {
18541927 end_monitor;
18551928 return 0 if ($failed );
18561929
1930+ patchcheck_reboot;
1931+
18571932 }
18581933 $in_patchcheck = 0;
18591934 success $i ;
@@ -1944,7 +2019,7 @@ sub patchcheck {
19442019 }
19452020}
19462021
1947- sub set_test_option {
2022+ sub __set_test_option {
19482023 my ($name , $i ) = @_ ;
19492024
19502025 my $option = " $name \[ $i \] " ;
@@ -1970,6 +2045,72 @@ sub set_test_option {
19702045 return undef ;
19712046}
19722047
2048+ sub eval_option {
2049+ my ($option , $i ) = @_ ;
2050+
2051+ # Add space to evaluate the character before $
2052+ $option = " $option " ;
2053+ my $retval = " " ;
2054+
2055+ while ($option =~ / (.*?[^\\ ])\$\{ (.*?)\} (.*)/ ) {
2056+ my $start = $1 ;
2057+ my $var = $2 ;
2058+ my $end = $3 ;
2059+
2060+ # Append beginning of line
2061+ $retval = " $retval$start " ;
2062+
2063+ # If the iteration option OPT[$i] exists, then use that.
2064+ # otherwise see if the default OPT (without [$i]) exists.
2065+
2066+ my $o = " $var \[ $i \] " ;
2067+
2068+ if (defined ($opt {$o })) {
2069+ $o = $opt {$o };
2070+ $retval = " $retval$o " ;
2071+ } elsif (defined ($opt {$var })) {
2072+ $o = $opt {$var };
2073+ $retval = " $retval$o " ;
2074+ } else {
2075+ $retval = " $retval \$\{ $var \} " ;
2076+ }
2077+
2078+ $option = $end ;
2079+ }
2080+
2081+ $retval = " $retval$option " ;
2082+
2083+ $retval =~ s / ^ // ;
2084+
2085+ return $retval ;
2086+ }
2087+
2088+ sub set_test_option {
2089+ my ($name , $i ) = @_ ;
2090+
2091+ my $option = __set_test_option($name , $i );
2092+ return $option if (!defined ($option ));
2093+
2094+ my $prev = " " ;
2095+
2096+ # Since an option can evaluate to another option,
2097+ # keep iterating until we do not evaluate any more
2098+ # options.
2099+ my $r = 0;
2100+ while ($prev ne $option ) {
2101+ # Check for recursive evaluations.
2102+ # 100 deep should be more than enough.
2103+ if ($r ++ > 100) {
2104+ die " Over 100 evaluations accurred with $name \n " .
2105+ " Check for recursive variables\n " ;
2106+ }
2107+ $prev = $option ;
2108+ $option = eval_option($option , $i );
2109+ }
2110+
2111+ return $option ;
2112+ }
2113+
19732114# First we need to do is the builds
19742115for (my $i = 1; $i <= $opt {" NUM_TESTS" }; $i ++) {
19752116
@@ -2003,6 +2144,7 @@ sub set_test_option {
20032144 $poweroff_after_halt = set_test_option(" POWEROFF_AFTER_HALT" , $i );
20042145 $sleep_time = set_test_option(" SLEEP_TIME" , $i );
20052146 $bisect_sleep_time = set_test_option(" BISECT_SLEEP_TIME" , $i );
2147+ $patchcheck_sleep_time = set_test_option(" PATCHCHECK_SLEEP_TIME" , $i );
20062148 $bisect_manual = set_test_option(" BISECT_MANUAL" , $i );
20072149 $bisect_skip = set_test_option(" BISECT_SKIP" , $i );
20082150 $store_failures = set_test_option(" STORE_FAILURES" , $i );
0 commit comments