Skip to content

Commit 0050b6b

Browse files
Steven Rostedtrostedt
authored andcommitted
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>
1 parent 2ed3b16 commit 0050b6b

1 file changed

Lines changed: 21 additions & 40 deletions

File tree

‎tools/testing/ktest/ktest.pl‎

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -436,20 +436,29 @@ sub __read_config {
436436
# ignore blank lines and comments
437437
next if (/^\s*$/ || /\s*\#/);
438438

439-
if (/^\s*TEST_START(.*)/) {
439+
if (/^\s*(TEST_START|DEFAULTS)\b(.*)/) {
440440

441-
$rest = $1;
441+
my $type = $1;
442+
$rest = $2;
442443

443-
if ($num_tests_set) {
444-
die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
445-
}
444+
my $old_test_num;
445+
my $old_repeat;
446+
447+
if ($type eq "TEST_START") {
446448

447-
my $old_test_num = $test_num;
448-
my $old_repeat = $repeat;
449+
if ($num_tests_set) {
450+
die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
451+
}
449452

450-
$test_num += $repeat;
451-
$default = 0;
452-
$repeat = 1;
453+
$old_test_num = $test_num;
454+
$old_repeat = $repeat;
455+
456+
$test_num += $repeat;
457+
$default = 0;
458+
$repeat = 1;
459+
} else {
460+
$default = 1;
461+
}
453462

454463
if ($rest =~ /\s+SKIP\b(.*)/) {
455464
$rest = $1;
@@ -478,42 +487,14 @@ sub __read_config {
478487
}
479488

480489
if ($rest !~ /^\s*$/) {
481-
die "$name: $.: Gargbage found after TEST_START\n$_";
490+
die "$name: $.: Gargbage found after $type\n$_";
482491
}
483492

484-
if ($skip) {
493+
if ($skip && $type eq "TEST_START") {
485494
$test_num = $old_test_num;
486495
$repeat = $old_repeat;
487496
}
488497

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-
517498
} elsif (/^\s*ELSE\b(.*)$/) {
518499
if (!$if) {
519500
die "$name: $.: ELSE found with out matching IF section\n$_";

0 commit comments

Comments
 (0)