aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-06-13 11:03:34 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-06-13 11:03:34 -0400
commit23715c3c9a31dd34c8c2f27086a9562e35da423b (patch)
treecd7eb1c28f484e7507ffef7249e7cabdf70e829c /tools/testing
parentecaf8e521324d5a7f85976bb8689e248b8d3a2f6 (diff)
ktest: Have LOG_FILE evaluate options as well
The LOG_FILE variable needs to evaluate the $ options as well. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/ktest/ktest.pl126
1 files changed, 68 insertions, 58 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 1e1fe835df48..83dcfaf0cac4 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -478,6 +478,69 @@ sub read_config {
478 } 478 }
479} 479}
480 480
481sub __eval_option {
482 my ($option, $i) = @_;
483
484 # Add space to evaluate the character before $
485 $option = " $option";
486 my $retval = "";
487
488 while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
489 my $start = $1;
490 my $var = $2;
491 my $end = $3;
492
493 # Append beginning of line
494 $retval = "$retval$start";
495
496 # If the iteration option OPT[$i] exists, then use that.
497 # otherwise see if the default OPT (without [$i]) exists.
498
499 my $o = "$var\[$i\]";
500
501 if (defined($opt{$o})) {
502 $o = $opt{$o};
503 $retval = "$retval$o";
504 } elsif (defined($opt{$var})) {
505 $o = $opt{$var};
506 $retval = "$retval$o";
507 } else {
508 $retval = "$retval\$\{$var\}";
509 }
510
511 $option = $end;
512 }
513
514 $retval = "$retval$option";
515
516 $retval =~ s/^ //;
517
518 return $retval;
519}
520
521sub eval_option {
522 my ($option, $i) = @_;
523
524 my $prev = "";
525
526 # Since an option can evaluate to another option,
527 # keep iterating until we do not evaluate any more
528 # options.
529 my $r = 0;
530 while ($prev ne $option) {
531 # Check for recursive evaluations.
532 # 100 deep should be more than enough.
533 if ($r++ > 100) {
534 die "Over 100 evaluations accurred with $option\n" .
535 "Check for recursive variables\n";
536 }
537 $prev = $option;
538 $option = __eval_option($option, $i);
539 }
540
541 return $option;
542}
543
481sub _logit { 544sub _logit {
482 if (defined($opt{"LOG_FILE"})) { 545 if (defined($opt{"LOG_FILE"})) {
483 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; 546 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
@@ -2079,6 +2142,10 @@ EOF
2079} 2142}
2080read_config $ktest_config; 2143read_config $ktest_config;
2081 2144
2145if (defined($opt{"LOG_FILE"})) {
2146 $opt{"LOG_FILE"} = eval_option($opt{"LOG_FILE"}, -1);
2147}
2148
2082# Append any configs entered in manually to the config file. 2149# Append any configs entered in manually to the config file.
2083my @new_configs = keys %entered_configs; 2150my @new_configs = keys %entered_configs;
2084if ($#new_configs >= 0) { 2151if ($#new_configs >= 0) {
@@ -2147,70 +2214,13 @@ sub __set_test_option {
2147 return undef; 2214 return undef;
2148} 2215}
2149 2216
2150sub eval_option {
2151 my ($option, $i) = @_;
2152
2153 # Add space to evaluate the character before $
2154 $option = " $option";
2155 my $retval = "";
2156
2157 while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
2158 my $start = $1;
2159 my $var = $2;
2160 my $end = $3;
2161
2162 # Append beginning of line
2163 $retval = "$retval$start";
2164
2165 # If the iteration option OPT[$i] exists, then use that.
2166 # otherwise see if the default OPT (without [$i]) exists.
2167
2168 my $o = "$var\[$i\]";
2169
2170 if (defined($opt{$o})) {
2171 $o = $opt{$o};
2172 $retval = "$retval$o";
2173 } elsif (defined($opt{$var})) {
2174 $o = $opt{$var};
2175 $retval = "$retval$o";
2176 } else {
2177 $retval = "$retval\$\{$var\}";
2178 }
2179
2180 $option = $end;
2181 }
2182
2183 $retval = "$retval$option";
2184
2185 $retval =~ s/^ //;
2186
2187 return $retval;
2188}
2189
2190sub set_test_option { 2217sub set_test_option {
2191 my ($name, $i) = @_; 2218 my ($name, $i) = @_;
2192 2219
2193 my $option = __set_test_option($name, $i); 2220 my $option = __set_test_option($name, $i);
2194 return $option if (!defined($option)); 2221 return $option if (!defined($option));
2195 2222
2196 my $prev = ""; 2223 return eval_option($option, $i);
2197
2198 # Since an option can evaluate to another option,
2199 # keep iterating until we do not evaluate any more
2200 # options.
2201 my $r = 0;
2202 while ($prev ne $option) {
2203 # Check for recursive evaluations.
2204 # 100 deep should be more than enough.
2205 if ($r++ > 100) {
2206 die "Over 100 evaluations accurred with $name\n" .
2207 "Check for recursive variables\n";
2208 }
2209 $prev = $option;
2210 $option = eval_option($option, $i);
2211 }
2212
2213 return $option;
2214} 2224}
2215 2225
2216# First we need to do is the builds 2226# First we need to do is the builds