diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-09-30 21:00:00 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-10-17 11:54:11 -0400 |
commit | 2ed3b16128e93309758e62937e7f137ac9844227 (patch) | |
tree | 60d7b1ecf43121c662ffceac558232161a1e5f20 /tools/testing/ktest/ktest.pl | |
parent | ab7a3f52cef5ff1c784de7adfbda3421b10754a4 (diff) |
ktest: Add INCLUDE keyword to include other config files
Have the reading of the config file allow reading of other config
files using the INCLUDE keyword. This allows multiple config files
to share config options.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index ed20d6881ec9..62de47de2b04 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -412,15 +412,16 @@ sub process_if { | |||
412 | return 1; | 412 | return 1; |
413 | } | 413 | } |
414 | 414 | ||
415 | sub read_config { | 415 | sub __read_config { |
416 | my ($config) = @_; | 416 | my ($config, $current_test_num) = @_; |
417 | 417 | ||
418 | open(IN, $config) || die "can't read file $config"; | 418 | my $in; |
419 | open($in, $config) || die "can't read file $config"; | ||
419 | 420 | ||
420 | my $name = $config; | 421 | my $name = $config; |
421 | $name =~ s,.*/(.*),$1,; | 422 | $name =~ s,.*/(.*),$1,; |
422 | 423 | ||
423 | my $test_num = 0; | 424 | my $test_num = $$current_test_num; |
424 | my $default = 1; | 425 | my $default = 1; |
425 | my $repeat = 1; | 426 | my $repeat = 1; |
426 | my $num_tests_set = 0; | 427 | my $num_tests_set = 0; |
@@ -430,7 +431,7 @@ sub read_config { | |||
430 | my $if = 0; | 431 | my $if = 0; |
431 | my $if_set = 0; | 432 | my $if_set = 0; |
432 | 433 | ||
433 | while (<IN>) { | 434 | while (<$in>) { |
434 | 435 | ||
435 | # ignore blank lines and comments | 436 | # ignore blank lines and comments |
436 | next if (/^\s*$/ || /\s*\#/); | 437 | next if (/^\s*$/ || /\s*\#/); |
@@ -539,6 +540,33 @@ sub read_config { | |||
539 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; | 540 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; |
540 | } | 541 | } |
541 | 542 | ||
543 | } elsif (/^\s*INCLUDE\s+(\S+)/) { | ||
544 | |||
545 | next if ($skip); | ||
546 | |||
547 | if (!$default) { | ||
548 | die "$name: $.: INCLUDE can only be done in default sections\n$_"; | ||
549 | } | ||
550 | |||
551 | my $file = process_variables($1); | ||
552 | |||
553 | if ($file !~ m,^/,) { | ||
554 | # check the path of the config file first | ||
555 | if ($config =~ m,(.*)/,) { | ||
556 | if (-f "$1/$file") { | ||
557 | $file = "$1/$file"; | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | |||
562 | if ( ! -r $file ) { | ||
563 | die "$name: $.: Can't read file $file\n$_"; | ||
564 | } | ||
565 | |||
566 | if (__read_config($file, \$test_num)) { | ||
567 | $test_case = 1; | ||
568 | } | ||
569 | |||
542 | } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { | 570 | } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { |
543 | 571 | ||
544 | next if ($skip); | 572 | next if ($skip); |
@@ -594,13 +622,26 @@ sub read_config { | |||
594 | } | 622 | } |
595 | } | 623 | } |
596 | 624 | ||
597 | close(IN); | ||
598 | |||
599 | if ($test_num) { | 625 | if ($test_num) { |
600 | $test_num += $repeat - 1; | 626 | $test_num += $repeat - 1; |
601 | $opt{"NUM_TESTS"} = $test_num; | 627 | $opt{"NUM_TESTS"} = $test_num; |
602 | } | 628 | } |
603 | 629 | ||
630 | close($in); | ||
631 | |||
632 | $$current_test_num = $test_num; | ||
633 | |||
634 | return $test_case; | ||
635 | } | ||
636 | |||
637 | sub read_config { | ||
638 | my ($config) = @_; | ||
639 | |||
640 | my $test_case; | ||
641 | my $test_num = 0; | ||
642 | |||
643 | $test_case = __read_config $config, \$test_num; | ||
644 | |||
604 | # make sure we have all mandatory configs | 645 | # make sure we have all mandatory configs |
605 | get_ktest_configs; | 646 | get_ktest_configs; |
606 | 647 | ||