diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-09-30 21:10:30 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-10-17 11:54:11 -0400 |
commit | 0050b6bbef01d871a34a77685047190aa428b210 (patch) | |
tree | ad29cc14fd37a7aa9dd08737020a604a1cae6fd6 /tools | |
parent | 2ed3b16128e93309758e62937e7f137ac9844227 (diff) |
ktest: Consolidate TEST_TYPE and DEFAULT code
The code that handles parsing the TEST_TYPE and DEFAULT code share
a lot of common functionality. Combine the two and add a if statement
that does what is different between them.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 61 |
1 files changed, 21 insertions, 40 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 62de47de2b04..b4f32e734745 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -436,20 +436,29 @@ sub __read_config { | |||
436 | # ignore blank lines and comments | 436 | # ignore blank lines and comments |
437 | next if (/^\s*$/ || /\s*\#/); | 437 | next if (/^\s*$/ || /\s*\#/); |
438 | 438 | ||
439 | if (/^\s*TEST_START(.*)/) { | 439 | if (/^\s*(TEST_START|DEFAULTS)\b(.*)/) { |
440 | 440 | ||
441 | $rest = $1; | 441 | my $type = $1; |
442 | $rest = $2; | ||
442 | 443 | ||
443 | if ($num_tests_set) { | 444 | my $old_test_num; |
444 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; | 445 | my $old_repeat; |
445 | } | 446 | |
447 | if ($type eq "TEST_START") { | ||
446 | 448 | ||
447 | my $old_test_num = $test_num; | 449 | if ($num_tests_set) { |
448 | my $old_repeat = $repeat; | 450 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; |
451 | } | ||
449 | 452 | ||
450 | $test_num += $repeat; | 453 | $old_test_num = $test_num; |
451 | $default = 0; | 454 | $old_repeat = $repeat; |
452 | $repeat = 1; | 455 | |
456 | $test_num += $repeat; | ||
457 | $default = 0; | ||
458 | $repeat = 1; | ||
459 | } else { | ||
460 | $default = 1; | ||
461 | } | ||
453 | 462 | ||
454 | if ($rest =~ /\s+SKIP\b(.*)/) { | 463 | if ($rest =~ /\s+SKIP\b(.*)/) { |
455 | $rest = $1; | 464 | $rest = $1; |
@@ -478,42 +487,14 @@ sub __read_config { | |||
478 | } | 487 | } |
479 | 488 | ||
480 | if ($rest !~ /^\s*$/) { | 489 | if ($rest !~ /^\s*$/) { |
481 | die "$name: $.: Gargbage found after TEST_START\n$_"; | 490 | die "$name: $.: Gargbage found after $type\n$_"; |
482 | } | 491 | } |
483 | 492 | ||
484 | if ($skip) { | 493 | if ($skip && $type eq "TEST_START") { |
485 | $test_num = $old_test_num; | 494 | $test_num = $old_test_num; |
486 | $repeat = $old_repeat; | 495 | $repeat = $old_repeat; |
487 | } | 496 | } |
488 | 497 | ||
489 | } elsif (/^\s*DEFAULTS(.*)$/) { | ||
490 | $default = 1; | ||
491 | |||
492 | $rest = $1; | ||
493 | |||
494 | if ($rest =~ /\s+SKIP(.*)/) { | ||
495 | $rest = $1; | ||
496 | $skip = 1; | ||
497 | } else { | ||
498 | $skip = 0; | ||
499 | } | ||
500 | |||
501 | if ($rest =~ /\sIF\s+(.*)/) { | ||
502 | $if = 1; | ||
503 | if (process_if($name, $1)) { | ||
504 | $if_set = 1; | ||
505 | } else { | ||
506 | $skip = 1; | ||
507 | } | ||
508 | $rest = ""; | ||
509 | } else { | ||
510 | $if = 0; | ||
511 | } | ||
512 | |||
513 | if ($rest !~ /^\s*$/) { | ||
514 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; | ||
515 | } | ||
516 | |||
517 | } elsif (/^\s*ELSE\b(.*)$/) { | 498 | } elsif (/^\s*ELSE\b(.*)$/) { |
518 | if (!$if) { | 499 | if (!$if) { |
519 | die "$name: $.: ELSE found with out matching IF section\n$_"; | 500 | die "$name: $.: ELSE found with out matching IF section\n$_"; |