aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt2011-12-22 20:37:22 -0600
committerSteven Rostedt2011-12-22 21:02:35 -0600
commit9cc9e091ed4c70535309dd9336a5ea5c2c5920aa (patch)
tree514c7d65b55f5cc3df3487bbc89a79dc35d1fd24 /tools/testing/ktest
parentb5f4aea687797bf9ab24f59643f88f82443b01fa (diff)
downloadkernel-omap-9cc9e091ed4c70535309dd9336a5ea5c2c5920aa.tar.gz
kernel-omap-9cc9e091ed4c70535309dd9336a5ea5c2c5920aa.tar.xz
kernel-omap-9cc9e091ed4c70535309dd9336a5ea5c2c5920aa.zip
ktest: Detect typos in option names
It becomes quite annoying when you go to run a test and then realize that you typed an option name wrong, and the test starts doing the default action and not what you expected it to do. It is even more annoying when you wake up the next day after running the test over night when you discover this. By testing if all options specified in a config file are used by either ktest or were used in one of the option's values we can see if there are any dangling options that were not used. In such a case, show the user the options that were not used and ask them if they want to continue or not. The option IGNORE_UNUSED was also added to allow the user to override this feature. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest')
-rwxr-xr-xtools/testing/ktest/ktest.pl208
-rw-r--r--tools/testing/ktest/sample.conf11
2 files changed, 139 insertions, 80 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 5ba9ad4248d7..f360cbdbf00f 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -58,6 +58,9 @@ my %default = (
58 "SSH_USER" => "root", 58 "SSH_USER" => "root",
59 "BUILD_TARGET" => "arch/x86/boot/bzImage", 59 "BUILD_TARGET" => "arch/x86/boot/bzImage",
60 "TARGET_IMAGE" => "/boot/vmlinuz-test", 60 "TARGET_IMAGE" => "/boot/vmlinuz-test",
61
62 "LOG_FILE" => undef,
63 "IGNORE_UNUSED" => 0,
61); 64);
62 65
63my $ktest_config; 66my $ktest_config;
@@ -176,6 +179,92 @@ my %force_config;
176# do not force reboots on config problems 179# do not force reboots on config problems
177my $no_reboot = 1; 180my $no_reboot = 1;
178 181
182my %option_map = (
183 "MACHINE" => \$machine,
184 "SSH_USER" => \$ssh_user,
185 "TMP_DIR" => \$tmpdir,
186 "OUTPUT_DIR" => \$outputdir,
187 "BUILD_DIR" => \$builddir,
188 "TEST_TYPE" => \$test_type,
189 "BUILD_TYPE" => \$build_type,
190 "BUILD_OPTIONS" => \$build_options,
191 "PRE_BUILD" => \$pre_build,
192 "POST_BUILD" => \$post_build,
193 "PRE_BUILD_DIE" => \$pre_build_die,
194 "POST_BUILD_DIE" => \$post_build_die,
195 "POWER_CYCLE" => \$power_cycle,
196 "REBOOT" => \$reboot,
197 "BUILD_NOCLEAN" => \$noclean,
198 "MIN_CONFIG" => \$minconfig,
199 "OUTPUT_MIN_CONFIG" => \$output_minconfig,
200 "START_MIN_CONFIG" => \$start_minconfig,
201 "IGNORE_CONFIG" => \$ignore_config,
202 "TEST" => \$run_test,
203 "ADD_CONFIG" => \$addconfig,
204 "REBOOT_TYPE" => \$reboot_type,
205 "GRUB_MENU" => \$grub_menu,
206 "POST_INSTALL" => \$post_install,
207 "NO_INSTALL" => \$no_install,
208 "REBOOT_SCRIPT" => \$reboot_script,
209 "REBOOT_ON_ERROR" => \$reboot_on_error,
210 "SWITCH_TO_GOOD" => \$switch_to_good,
211 "SWITCH_TO_TEST" => \$switch_to_test,
212 "POWEROFF_ON_ERROR" => \$poweroff_on_error,
213 "DIE_ON_FAILURE" => \$die_on_failure,
214 "POWER_OFF" => \$power_off,
215 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot,
216 "POWEROFF_AFTER_HALT" => \$poweroff_after_halt,
217 "SLEEP_TIME" => \$sleep_time,
218 "BISECT_SLEEP_TIME" => \$bisect_sleep_time,
219 "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time,
220 "IGNORE_WARNINGS" => \$ignore_warnings,
221 "BISECT_MANUAL" => \$bisect_manual,
222 "BISECT_SKIP" => \$bisect_skip,
223 "CONFIG_BISECT_GOOD" => \$config_bisect_good,
224 "BISECT_RET_GOOD" => \$bisect_ret_good,
225 "BISECT_RET_BAD" => \$bisect_ret_bad,
226 "BISECT_RET_SKIP" => \$bisect_ret_skip,
227 "BISECT_RET_ABORT" => \$bisect_ret_abort,
228 "BISECT_RET_DEFAULT" => \$bisect_ret_default,
229 "STORE_FAILURES" => \$store_failures,
230 "STORE_SUCCESSES" => \$store_successes,
231 "TEST_NAME" => \$test_name,
232 "TIMEOUT" => \$timeout,
233 "BOOTED_TIMEOUT" => \$booted_timeout,
234 "CONSOLE" => \$console,
235 "DETECT_TRIPLE_FAULT" => \$detect_triplefault,
236 "SUCCESS_LINE" => \$success_line,
237 "REBOOT_SUCCESS_LINE" => \$reboot_success_line,
238 "STOP_AFTER_SUCCESS" => \$stop_after_success,
239 "STOP_AFTER_FAILURE" => \$stop_after_failure,
240 "STOP_TEST_AFTER" => \$stop_test_after,
241 "BUILD_TARGET" => \$build_target,
242 "SSH_EXEC" => \$ssh_exec,
243 "SCP_TO_TARGET" => \$scp_to_target,
244 "CHECKOUT" => \$checkout,
245 "TARGET_IMAGE" => \$target_image,
246 "LOCALVERSION" => \$localversion,
247
248 "BISECT_GOOD" => \$bisect_good,
249 "BISECT_BAD" => \$bisect_bad,
250 "BISECT_TYPE" => \$bisect_type,
251 "BISECT_START" => \$bisect_start,
252 "BISECT_REPLAY" => \$bisect_replay,
253 "BISECT_FILES" => \$bisect_files,
254 "BISECT_REVERSE" => \$bisect_reverse,
255 "BISECT_CHECK" => \$bisect_check,
256
257 "CONFIG_BISECT" => \$config_bisect,
258 "CONFIG_BISECT_TYPE" => \$config_bisect_type,
259
260 "PATCHCHECK_TYPE" => \$patchcheck_type,
261 "PATCHCHECK_START" => \$patchcheck_start,
262 "PATCHCHECK_END" => \$patchcheck_end,
263);
264
265# Options may be used by other options, record them.
266my %used_options;
267
179# default variables that can be used 268# default variables that can be used
180chomp ($variable{"PWD"} = `pwd`); 269chomp ($variable{"PWD"} = `pwd`);
181 270
@@ -427,6 +516,10 @@ sub process_variables {
427 } else { 516 } else {
428 # put back the origin piece. 517 # put back the origin piece.
429 $retval = "$retval\$\{$var\}"; 518 $retval = "$retval\$\{$var\}";
519 # This could be an option that is used later, save
520 # it so we don't warn if this option is not one of
521 # ktests options.
522 $used_options{$var} = 1;
430 } 523 }
431 $value = $end; 524 $value = $end;
432 } 525 }
@@ -850,6 +943,37 @@ sub read_config {
850 $opt{$default} = $default{$default}; 943 $opt{$default} = $default{$default};
851 } 944 }
852 } 945 }
946
947 if ($opt{"IGNORE_UNUSED"} == 1) {
948 return;
949 }
950
951 my %not_used;
952
953 # check if there are any stragglers (typos?)
954 foreach my $option (keys %opt) {
955 my $op = $option;
956 # remove per test labels.
957 $op =~ s/\[.*\]//;
958 if (!exists($option_map{$op}) &&
959 !exists($default{$op}) &&
960 !exists($used_options{$op})) {
961 $not_used{$op} = 1;
962 }
963 }
964
965 if (%not_used) {
966 my $s = "s are";
967 $s = " is" if (keys %not_used == 1);
968 print "The following option$s not used; could be a typo:\n";
969 foreach my $option (keys %not_used) {
970 print "$option\n";
971 }
972 print "Set IGRNORE_UNUSED = 1 to have ktest ignore unused variables\n";
973 if (!read_yn "Do you want to continue?") {
974 exit -1;
975 }
976 }
853} 977}
854 978
855sub __eval_option { 979sub __eval_option {
@@ -3321,86 +3445,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3321 3445
3322 my $makecmd = set_test_option("MAKE_CMD", $i); 3446 my $makecmd = set_test_option("MAKE_CMD", $i);
3323 3447
3324 $machine = set_test_option("MACHINE", $i); 3448 # Load all the options into their mapped variable names
3325 $ssh_user = set_test_option("SSH_USER", $i); 3449 foreach my $opt (keys %option_map) {
3326 $tmpdir = set_test_option("TMP_DIR", $i); 3450 ${$option_map{$opt}} = set_test_option($opt, $i);
3327 $outputdir = set_test_option("OUTPUT_DIR", $i); 3451 }
3328 $builddir = set_test_option("BUILD_DIR", $i);
3329 $test_type = set_test_option("TEST_TYPE", $i);
3330 $build_type = set_test_option("BUILD_TYPE", $i);
3331 $build_options = set_test_option("BUILD_OPTIONS", $i);
3332 $pre_build = set_test_option("PRE_BUILD", $i);
3333 $post_build = set_test_option("POST_BUILD", $i);
3334 $pre_build_die = set_test_option("PRE_BUILD_DIE", $i);
3335 $post_build_die = set_test_option("POST_BUILD_DIE", $i);
3336 $power_cycle = set_test_option("POWER_CYCLE", $i);
3337 $reboot = set_test_option("REBOOT", $i);
3338 $noclean = set_test_option("BUILD_NOCLEAN", $i);
3339 $minconfig = set_test_option("MIN_CONFIG", $i);
3340 $output_minconfig = set_test_option("OUTPUT_MIN_CONFIG", $i);
3341 $start_minconfig = set_test_option("START_MIN_CONFIG", $i);
3342 $ignore_config = set_test_option("IGNORE_CONFIG", $i);
3343 $run_test = set_test_option("TEST", $i);
3344 $addconfig = set_test_option("ADD_CONFIG", $i);
3345 $reboot_type = set_test_option("REBOOT_TYPE", $i);
3346 $grub_menu = set_test_option("GRUB_MENU", $i);
3347 $post_install = set_test_option("POST_INSTALL", $i);
3348 $no_install = set_test_option("NO_INSTALL", $i);
3349 $reboot_script = set_test_option("REBOOT_SCRIPT", $i);
3350 $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i);
3351 $switch_to_good = set_test_option("SWITCH_TO_GOOD", $i);
3352 $switch_to_test = set_test_option("SWITCH_TO_TEST", $i);
3353 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i);
3354 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i);
3355 $power_off = set_test_option("POWER_OFF", $i);
3356 $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i);
3357 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i);
3358 $sleep_time = set_test_option("SLEEP_TIME", $i);
3359 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i);
3360 $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i);
3361 $ignore_warnings = set_test_option("IGNORE_WARNINGS", $i);
3362 $bisect_manual = set_test_option("BISECT_MANUAL", $i);
3363 $bisect_skip = set_test_option("BISECT_SKIP", $i);
3364 $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i);
3365 $bisect_ret_good = set_test_option("BISECT_RET_GOOD", $i);
3366 $bisect_ret_bad = set_test_option("BISECT_RET_BAD", $i);
3367 $bisect_ret_skip = set_test_option("BISECT_RET_SKIP", $i);
3368 $bisect_ret_abort = set_test_option("BISECT_RET_ABORT", $i);
3369 $bisect_ret_default = set_test_option("BISECT_RET_DEFAULT", $i);
3370 $store_failures = set_test_option("STORE_FAILURES", $i);
3371 $store_successes = set_test_option("STORE_SUCCESSES", $i);
3372 $test_name = set_test_option("TEST_NAME", $i);
3373 $timeout = set_test_option("TIMEOUT", $i);
3374 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
3375 $console = set_test_option("CONSOLE", $i);
3376 $detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i);
3377 $success_line = set_test_option("SUCCESS_LINE", $i);
3378 $reboot_success_line = set_test_option("REBOOT_SUCCESS_LINE", $i);
3379 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
3380 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
3381 $stop_test_after = set_test_option("STOP_TEST_AFTER", $i);
3382 $build_target = set_test_option("BUILD_TARGET", $i);
3383 $ssh_exec = set_test_option("SSH_EXEC", $i);
3384 $scp_to_target = set_test_option("SCP_TO_TARGET", $i);
3385 $checkout = set_test_option("CHECKOUT", $i);
3386 $target_image = set_test_option("TARGET_IMAGE", $i);
3387 $localversion = set_test_option("LOCALVERSION", $i);
3388
3389 $bisect_good = set_test_option("BISECT_GOOD", $i);
3390 $bisect_bad = set_test_option("BISECT_BAD", $i);
3391 $bisect_type = set_test_option("BISECT_TYPE", $i);
3392 $bisect_start = set_test_option("BISECT_START", $i);
3393 $bisect_replay = set_test_option("BISECT_REPLAY", $i);
3394 $bisect_files = set_test_option("BISECT_FILES", $i);
3395 $bisect_reverse = set_test_option("BISECT_REVERSE", $i);
3396 $bisect_check = set_test_option("BISECT_CHECK", $i);
3397
3398 $config_bisect = set_test_option("CONFIG_BISECT", $i);
3399 $config_bisect_type = set_test_option("CONFIG_BISECT_TYPE", $i);
3400
3401 $patchcheck_type = set_test_option("PATCHCHECK_TYPE", $i);
3402 $patchcheck_start = set_test_option("PATCHCHECK_START", $i);
3403 $patchcheck_end = set_test_option("PATCHCHECK_END", $i);
3404 3452
3405 $start_minconfig_defined = 1; 3453 $start_minconfig_defined = 1;
3406 3454
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index c8dc7575c2f5..86ce62c3fdca 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -727,6 +727,17 @@
727# (default 1) 727# (default 1)
728#DETECT_TRIPLE_FAULT = 0 728#DETECT_TRIPLE_FAULT = 0
729 729
730# All options in the config file should be either used by ktest
731# or could be used within a value of another option. If an option
732# in the config file is not used, ktest will warn about it and ask
733# if you want to continue.
734#
735# If you don't care if there are non-used options, enable this
736# option. Be careful though, a non-used option is usually a sign
737# of an option name being typed incorrectly.
738# (default 0)
739#IGNORE_UNUSED = 1
740
730#### Per test run options #### 741#### Per test run options ####
731# The following options are only allowed in TEST_START sections. 742# The following options are only allowed in TEST_START sections.
732# They are ignored in the DEFAULTS sections. 743# They are ignored in the DEFAULTS sections.