aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-10-17 11:06:29 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-10-17 11:58:15 -0400
commita9f84424be8d12e8a84b9eac112cd1152587d437 (patch)
treed387036bbfb7cda150a3e0e1e7a778cbe1eb1364 /tools
parentac6974c76e66c2f9b8b8a23b974c5f3d94302e81 (diff)
ktest: Fix parsing of config section lines
The order for some of the keywords on a section line (TEST_START or DEFAULTS) does not really matter. Simply need to remove the keyword from the line as we process it and evaluate the next keyword in the line. By removing the keywords as we find them, we do not need to keep track of where on the line they were found. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl49
1 files changed, 31 insertions, 18 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 2a9d04207174..d292c2d8dfe9 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -449,6 +449,7 @@ sub __read_config {
449 my $num_tests_set = 0; 449 my $num_tests_set = 0;
450 my $skip = 0; 450 my $skip = 0;
451 my $rest; 451 my $rest;
452 my $line;
452 my $test_case = 0; 453 my $test_case = 0;
453 my $if = 0; 454 my $if = 0;
454 my $if_set = 0; 455 my $if_set = 0;
@@ -465,6 +466,7 @@ sub __read_config {
465 466
466 my $type = $1; 467 my $type = $1;
467 $rest = $2; 468 $rest = $2;
469 $line = $2;
468 470
469 my $old_test_num; 471 my $old_test_num;
470 my $old_repeat; 472 my $old_repeat;
@@ -486,32 +488,28 @@ sub __read_config {
486 $default = 1; 488 $default = 1;
487 } 489 }
488 490
489 if ($rest =~ /\s+SKIP\b(.*)/) { 491 # If SKIP is anywhere in the line, the command will be skipped
490 $rest = $1; 492 if ($rest =~ s/\s+SKIP\b//) {
491 $skip = 1; 493 $skip = 1;
492 } else { 494 } else {
493 $test_case = 1; 495 $test_case = 1;
494 $skip = 0; 496 $skip = 0;
495 } 497 }
496 498
497 if (!$skip) { 499 if ($rest =~ s/\sELSE\b//) {
498 if ($type eq "TEST_START") { 500 if (!$if) {
499 if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) { 501 die "$name: $.: ELSE found with out matching IF section\n$_";
500 $repeat = $1; 502 }
501 $rest = $2; 503 $if = 0;
502 $repeat_tests{"$test_num"} = $repeat; 504
503 } 505 if ($if_set) {
504 } elsif ($rest =~ /\sOVERRIDE\b(.*)/) { 506 $skip = 1;
505 # DEFAULT only 507 } else {
506 $rest = $1; 508 $skip = 0;
507 $override = 1;
508 # Clear previous overrides
509 %overrides = ();
510 } 509 }
511 } 510 }
512 511
513 if ($rest =~ /\sIF\s+(.*)/) { 512 if ($rest =~ s/\sIF\s+(.*)//) {
514 $rest = "";
515 if (process_if($name, $1)) { 513 if (process_if($name, $1)) {
516 $if_set = 1; 514 $if_set = 1;
517 } else { 515 } else {
@@ -520,9 +518,24 @@ sub __read_config {
520 $if = 1; 518 $if = 1;
521 } else { 519 } else {
522 $if = 0; 520 $if = 0;
521 $if_set = 0;
523 } 522 }
524 523
525 if ($rest !~ /^\s*$/) { 524 if (!$skip) {
525 if ($type eq "TEST_START") {
526 if ($rest =~ s/\s+ITERATE\s+(\d+)//) {
527 $repeat = $1;
528 $repeat_tests{"$test_num"} = $repeat;
529 }
530 } elsif ($rest =~ s/\sOVERRIDE\b//) {
531 # DEFAULT only
532 $override = 1;
533 # Clear previous overrides
534 %overrides = ();
535 }
536 }
537
538 if (!$skip && $rest !~ /^\s*$/) {
526 die "$name: $.: Gargbage found after $type\n$_"; 539 die "$name: $.: Gargbage found after $type\n$_";
527 } 540 }
528 541