Commit 23715c3c authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

ktest: Have LOG_FILE evaluate options as well

The LOG_FILE variable needs to evaluate the $ options as well.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent ecaf8e52
...@@ -478,6 +478,69 @@ sub read_config { ...@@ -478,6 +478,69 @@ sub read_config {
} }
} }
sub __eval_option {
my ($option, $i) = @_;
# Add space to evaluate the character before $
$option = " $option";
my $retval = "";
while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
my $start = $1;
my $var = $2;
my $end = $3;
# Append beginning of line
$retval = "$retval$start";
# If the iteration option OPT[$i] exists, then use that.
# otherwise see if the default OPT (without [$i]) exists.
my $o = "$var\[$i\]";
if (defined($opt{$o})) {
$o = $opt{$o};
$retval = "$retval$o";
} elsif (defined($opt{$var})) {
$o = $opt{$var};
$retval = "$retval$o";
} else {
$retval = "$retval\$\{$var\}";
}
$option = $end;
}
$retval = "$retval$option";
$retval =~ s/^ //;
return $retval;
}
sub eval_option {
my ($option, $i) = @_;
my $prev = "";
# Since an option can evaluate to another option,
# keep iterating until we do not evaluate any more
# options.
my $r = 0;
while ($prev ne $option) {
# Check for recursive evaluations.
# 100 deep should be more than enough.
if ($r++ > 100) {
die "Over 100 evaluations accurred with $option\n" .
"Check for recursive variables\n";
}
$prev = $option;
$option = __eval_option($option, $i);
}
return $option;
}
sub _logit { sub _logit {
if (defined($opt{"LOG_FILE"})) { if (defined($opt{"LOG_FILE"})) {
open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
...@@ -2079,6 +2142,10 @@ EOF ...@@ -2079,6 +2142,10 @@ EOF
} }
read_config $ktest_config; read_config $ktest_config;
if (defined($opt{"LOG_FILE"})) {
$opt{"LOG_FILE"} = eval_option($opt{"LOG_FILE"}, -1);
}
# Append any configs entered in manually to the config file. # Append any configs entered in manually to the config file.
my @new_configs = keys %entered_configs; my @new_configs = keys %entered_configs;
if ($#new_configs >= 0) { if ($#new_configs >= 0) {
...@@ -2147,70 +2214,13 @@ sub __set_test_option { ...@@ -2147,70 +2214,13 @@ sub __set_test_option {
return undef; return undef;
} }
sub eval_option {
my ($option, $i) = @_;
# Add space to evaluate the character before $
$option = " $option";
my $retval = "";
while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
my $start = $1;
my $var = $2;
my $end = $3;
# Append beginning of line
$retval = "$retval$start";
# If the iteration option OPT[$i] exists, then use that.
# otherwise see if the default OPT (without [$i]) exists.
my $o = "$var\[$i\]";
if (defined($opt{$o})) {
$o = $opt{$o};
$retval = "$retval$o";
} elsif (defined($opt{$var})) {
$o = $opt{$var};
$retval = "$retval$o";
} else {
$retval = "$retval\$\{$var\}";
}
$option = $end;
}
$retval = "$retval$option";
$retval =~ s/^ //;
return $retval;
}
sub set_test_option { sub set_test_option {
my ($name, $i) = @_; my ($name, $i) = @_;
my $option = __set_test_option($name, $i); my $option = __set_test_option($name, $i);
return $option if (!defined($option)); return $option if (!defined($option));
my $prev = ""; return eval_option($option, $i);
# Since an option can evaluate to another option,
# keep iterating until we do not evaluate any more
# options.
my $r = 0;
while ($prev ne $option) {
# Check for recursive evaluations.
# 100 deep should be more than enough.
if ($r++ > 100) {
die "Over 100 evaluations accurred with $name\n" .
"Check for recursive variables\n";
}
$prev = $option;
$option = eval_option($option, $i);
}
return $option;
} }
# First we need to do is the builds # First we need to do is the builds
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment