Skip to content

Commit a9f8442

Browse files
Steven Rostedtrostedt
authored andcommitted
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>
1 parent ac6974c commit a9f8442

1 file changed

Lines changed: 31 additions & 18 deletions

File tree

‎tools/testing/ktest/ktest.pl‎

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ sub __read_config {
449449
my $num_tests_set = 0;
450450
my $skip = 0;
451451
my $rest;
452+
my $line;
452453
my $test_case = 0;
453454
my $if = 0;
454455
my $if_set = 0;
@@ -465,6 +466,7 @@ sub __read_config {
465466

466467
my $type = $1;
467468
$rest = $2;
469+
$line = $2;
468470

469471
my $old_test_num;
470472
my $old_repeat;
@@ -486,32 +488,28 @@ sub __read_config {
486488
$default = 1;
487489
}
488490

489-
if ($rest =~ /\s+SKIP\b(.*)/) {
490-
$rest = $1;
491+
# If SKIP is anywhere in the line, the command will be skipped
492+
if ($rest =~ s/\s+SKIP\b//) {
491493
$skip = 1;
492494
} else {
493495
$test_case = 1;
494496
$skip = 0;
495497
}
496498

497-
if (!$skip) {
498-
if ($type eq "TEST_START") {
499-
if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
500-
$repeat = $1;
501-
$rest = $2;
502-
$repeat_tests{"$test_num"} = $repeat;
503-
}
504-
} elsif ($rest =~ /\sOVERRIDE\b(.*)/) {
505-
# DEFAULT only
506-
$rest = $1;
507-
$override = 1;
508-
# Clear previous overrides
509-
%overrides = ();
499+
if ($rest =~ s/\sELSE\b//) {
500+
if (!$if) {
501+
die "$name: $.: ELSE found with out matching IF section\n$_";
502+
}
503+
$if = 0;
504+
505+
if ($if_set) {
506+
$skip = 1;
507+
} else {
508+
$skip = 0;
510509
}
511510
}
512511

513-
if ($rest =~ /\sIF\s+(.*)/) {
514-
$rest = "";
512+
if ($rest =~ s/\sIF\s+(.*)//) {
515513
if (process_if($name, $1)) {
516514
$if_set = 1;
517515
} else {
@@ -520,9 +518,24 @@ sub __read_config {
520518
$if = 1;
521519
} else {
522520
$if = 0;
521+
$if_set = 0;
523522
}
524523

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*$/) {
526539
die "$name: $.: Gargbage found after $type\n$_";
527540
}
528541

0 commit comments

Comments
 (0)