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

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-ktest

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-ktest:
ktest: Allow options to be used by other options
ktest: Create variables for the ktest config files
ktest: Reboot after each patchcheck run
ktest: Reboot to good kernel after every bisect run
ktest: If test failed due to timeout, print that
ktest: Fix post install command

+242 -7
+149 -7
tools/testing/ktest/ktest.pl
··· 36 36 $default{"POWEROFF_ON_SUCCESS"} = 0; 37 37 $default{"BUILD_OPTIONS"} = ""; 38 38 $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects 39 + $default{"PATCHCHECK_SLEEP_TIME"} = 60; # sleep time between patch checks 39 40 $default{"CLEAR_LOG"} = 0; 40 41 $default{"BISECT_MANUAL"} = 0; 41 42 $default{"BISECT_SKIP"} = 1; ··· 97 96 my $monitor_cnt = 0; 98 97 my $sleep_time; 99 98 my $bisect_sleep_time; 99 + my $patchcheck_sleep_time; 100 100 my $store_failures; 101 101 my $timeout; 102 102 my $booted_timeout; ··· 114 112 115 113 my %entered_configs; 116 114 my %config_help; 115 + my %variable; 117 116 118 117 $config_help{"MACHINE"} = << "EOF" 119 118 The machine hostname that you will test. ··· 263 260 } 264 261 } 265 262 263 + sub process_variables { 264 + my ($value) = @_; 265 + my $retval = ""; 266 + 267 + # We want to check for '\', and it is just easier 268 + # to check the previous characet of '$' and not need 269 + # to worry if '$' is the first character. By adding 270 + # a space to $value, we can just check [^\\]\$ and 271 + # it will still work. 272 + $value = " $value"; 273 + 274 + while ($value =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) { 275 + my $begin = $1; 276 + my $var = $2; 277 + my $end = $3; 278 + # append beginning of value to retval 279 + $retval = "$retval$begin"; 280 + if (defined($variable{$var})) { 281 + $retval = "$retval$variable{$var}"; 282 + } else { 283 + # put back the origin piece. 284 + $retval = "$retval\$\{$var\}"; 285 + } 286 + $value = $end; 287 + } 288 + $retval = "$retval$value"; 289 + 290 + # remove the space added in the beginning 291 + $retval =~ s/ //; 292 + 293 + return "$retval" 294 + } 295 + 266 296 sub set_value { 267 297 my ($lvalue, $rvalue) = @_; 268 298 ··· 305 269 if ($rvalue =~ /^\s*$/) { 306 270 delete $opt{$lvalue}; 307 271 } else { 272 + $rvalue = process_variables($rvalue); 308 273 $opt{$lvalue} = $rvalue; 274 + } 275 + } 276 + 277 + sub set_variable { 278 + my ($lvalue, $rvalue) = @_; 279 + 280 + if ($rvalue =~ /^\s*$/) { 281 + delete $variable{$lvalue}; 282 + } else { 283 + $rvalue = process_variables($rvalue); 284 + $variable{$lvalue} = $rvalue; 309 285 } 310 286 } 311 287 ··· 433 385 $repeats{$val} = $repeat; 434 386 } 435 387 } 388 + } elsif (/^\s*([A-Z_\[\]\d]+)\s*:=\s*(.*?)\s*$/) { 389 + next if ($skip); 390 + 391 + my $lvalue = $1; 392 + my $rvalue = $2; 393 + 394 + # process config variables. 395 + # Config variables are only active while reading the 396 + # config and can be defined anywhere. They also ignore 397 + # TEST_START and DEFAULTS, but are skipped if they are in 398 + # on of these sections that have SKIP defined. 399 + # The save variable can be 400 + # defined multiple times and the new one simply overrides 401 + # the prevous one. 402 + set_variable($lvalue, $rvalue); 403 + 436 404 } else { 437 405 die "$name: $.: Garbage found in config\n$_"; 438 406 } ··· 902 838 903 839 if ($stop_test_after > 0 && !$booted && !$bug) { 904 840 if (time - $monitor_start > $stop_test_after) { 841 + doprint "STOP_TEST_AFTER ($stop_test_after seconds) timed out\n"; 905 842 $done = 1; 906 843 } 907 844 } ··· 972 907 return if (!defined($post_install)); 973 908 974 909 my $cp_post_install = $post_install; 975 - $cp_post_install = s/\$KERNEL_VERSION/$version/g; 910 + $cp_post_install =~ s/\$KERNEL_VERSION/$version/g; 976 911 run_command "$cp_post_install" or 977 912 dodie "Failed to run post install"; 978 913 } ··· 1312 1247 1313 1248 if ($failed) { 1314 1249 $result = 0; 1315 - 1316 - # reboot the box to a good kernel 1317 - if ($type ne "build") { 1318 - bisect_reboot; 1319 - } 1320 1250 } else { 1321 1251 $result = 1; 1252 + } 1253 + 1254 + # reboot the box to a kernel we can ssh to 1255 + if ($type ne "build") { 1256 + bisect_reboot; 1322 1257 } 1323 1258 $in_bisect = 0; 1324 1259 ··· 1828 1763 success $i; 1829 1764 } 1830 1765 1766 + sub patchcheck_reboot { 1767 + doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; 1768 + reboot; 1769 + start_monitor; 1770 + wait_for_monitor $patchcheck_sleep_time; 1771 + end_monitor; 1772 + } 1773 + 1831 1774 sub patchcheck { 1832 1775 my ($i) = @_; 1833 1776 ··· 1927 1854 end_monitor; 1928 1855 return 0 if ($failed); 1929 1856 1857 + patchcheck_reboot; 1858 + 1930 1859 } 1931 1860 $in_patchcheck = 0; 1932 1861 success $i; ··· 2019 1944 } 2020 1945 } 2021 1946 2022 - sub set_test_option { 1947 + sub __set_test_option { 2023 1948 my ($name, $i) = @_; 2024 1949 2025 1950 my $option = "$name\[$i\]"; ··· 2043 1968 } 2044 1969 2045 1970 return undef; 1971 + } 1972 + 1973 + sub eval_option { 1974 + my ($option, $i) = @_; 1975 + 1976 + # Add space to evaluate the character before $ 1977 + $option = " $option"; 1978 + my $retval = ""; 1979 + 1980 + while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) { 1981 + my $start = $1; 1982 + my $var = $2; 1983 + my $end = $3; 1984 + 1985 + # Append beginning of line 1986 + $retval = "$retval$start"; 1987 + 1988 + # If the iteration option OPT[$i] exists, then use that. 1989 + # otherwise see if the default OPT (without [$i]) exists. 1990 + 1991 + my $o = "$var\[$i\]"; 1992 + 1993 + if (defined($opt{$o})) { 1994 + $o = $opt{$o}; 1995 + $retval = "$retval$o"; 1996 + } elsif (defined($opt{$var})) { 1997 + $o = $opt{$var}; 1998 + $retval = "$retval$o"; 1999 + } else { 2000 + $retval = "$retval\$\{$var\}"; 2001 + } 2002 + 2003 + $option = $end; 2004 + } 2005 + 2006 + $retval = "$retval$option"; 2007 + 2008 + $retval =~ s/^ //; 2009 + 2010 + return $retval; 2011 + } 2012 + 2013 + sub set_test_option { 2014 + my ($name, $i) = @_; 2015 + 2016 + my $option = __set_test_option($name, $i); 2017 + return $option if (!defined($option)); 2018 + 2019 + my $prev = ""; 2020 + 2021 + # Since an option can evaluate to another option, 2022 + # keep iterating until we do not evaluate any more 2023 + # options. 2024 + my $r = 0; 2025 + while ($prev ne $option) { 2026 + # Check for recursive evaluations. 2027 + # 100 deep should be more than enough. 2028 + if ($r++ > 100) { 2029 + die "Over 100 evaluations accurred with $name\n" . 2030 + "Check for recursive variables\n"; 2031 + } 2032 + $prev = $option; 2033 + $option = eval_option($option, $i); 2034 + } 2035 + 2036 + return $option; 2046 2037 } 2047 2038 2048 2039 # First we need to do is the builds ··· 2144 2003 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i); 2145 2004 $sleep_time = set_test_option("SLEEP_TIME", $i); 2146 2005 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); 2006 + $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i); 2147 2007 $bisect_manual = set_test_option("BISECT_MANUAL", $i); 2148 2008 $bisect_skip = set_test_option("BISECT_SKIP", $i); 2149 2009 $store_failures = set_test_option("STORE_FAILURES", $i);
+93
tools/testing/ktest/sample.conf
··· 73 73 # ktest will fail to execute, and no tests will run. 74 74 # 75 75 76 + #### Config variables #### 77 + # 78 + # This config file can also contain "config variables". 79 + # These are assigned with ":=" instead of the ktest option 80 + # assigment "=". 81 + # 82 + # The difference between ktest options and config variables 83 + # is that config variables can be used multiple times, 84 + # where each instance will override the previous instance. 85 + # And that they only live at time of processing this config. 86 + # 87 + # The advantage to config variables are that they can be used 88 + # by any option or any other config variables to define thing 89 + # that you may use over and over again in the options. 90 + # 91 + # For example: 92 + # 93 + # USER := root 94 + # TARGET := mybox 95 + # TEST_CASE := ssh ${USER}@${TARGET} /path/to/my/test 96 + # 97 + # TEST_START 98 + # MIN_CONFIG = config1 99 + # TEST = ${TEST_CASE} 100 + # 101 + # TEST_START 102 + # MIN_CONFIG = config2 103 + # TEST = ${TEST_CASE} 104 + # 105 + # TEST_CASE := ssh ${USER}@${TARGET} /path/to/my/test2 106 + # 107 + # TEST_START 108 + # MIN_CONFIG = config1 109 + # TEST = ${TEST_CASE} 110 + # 111 + # TEST_START 112 + # MIN_CONFIG = config2 113 + # TEST = ${TEST_CASE} 114 + # 115 + # TEST_DIR := /home/me/test 116 + # 117 + # BUILD_DIR = ${TEST_DIR}/linux.git 118 + # OUTPUT_DIR = ${TEST_DIR}/test 119 + # 120 + # Note, the config variables are evaluated immediately, thus 121 + # updating TARGET after TEST_CASE has been assigned does nothing 122 + # to TEST_CASE. 123 + # 124 + # As shown in the example, to evaluate a config variable, you 125 + # use the ${X} convention. Simple $X will not work. 126 + # 127 + # If the config variable does not exist, the ${X} will not 128 + # be evaluated. Thus: 129 + # 130 + # MAKE_CMD = PATH=/mypath:${PATH} make 131 + # 132 + # If PATH is not a config variable, then the ${PATH} in 133 + # the MAKE_CMD option will be evaluated by the shell when 134 + # the MAKE_CMD option is passed into shell processing. 135 + 136 + #### Using options in other options #### 137 + # 138 + # Options that are defined in the config file may also be used 139 + # by other options. All options are evaulated at time of 140 + # use (except that config variables are evaluated at config 141 + # processing time). 142 + # 143 + # If an ktest option is used within another option, instead of 144 + # typing it again in that option you can simply use the option 145 + # just like you can config variables. 146 + # 147 + # MACHINE = mybox 148 + # 149 + # TEST = ssh root@${MACHINE} /path/to/test 150 + # 151 + # The option will be used per test case. Thus: 152 + # 153 + # TEST_TYPE = test 154 + # TEST = ssh root@{MACHINE} 155 + # 156 + # TEST_START 157 + # MACHINE = box1 158 + # 159 + # TEST_START 160 + # MACHINE = box2 161 + # 162 + # For both test cases, MACHINE will be evaluated at the time 163 + # of the test case. The first test will run ssh root@box1 164 + # and the second will run ssh root@box2. 76 165 77 166 #### Mandatory Default Options #### 78 167 ··· 454 365 # The time in between bisects to sleep (in seconds) 455 366 # (default 60) 456 367 #BISECT_SLEEP_TIME = 60 368 + 369 + # The time in between patch checks to sleep (in seconds) 370 + # (default 60) 371 + #PATCHCHECK_SLEEP_TIME = 60 457 372 458 373 # Reboot the target box on error (default 0) 459 374 #REBOOT_ON_ERROR = 0