Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 275179
b: refs/heads/master
c: 8d73521
h: refs/heads/master
i:
  275177: 6be9469
  275175: 1314e4a
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Oct 17, 2011
1 parent c14d191 commit 23fba18
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9f84424be8d12e8a84b9eac112cd1152587d437
refs/heads/master: 8d735212e441af855afd28ccc402fcaf12999f8d
53 changes: 48 additions & 5 deletions trunk/tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ sub get_ktest_configs {
}

sub process_variables {
my ($value) = @_;
my ($value, $remove_undef) = @_;
my $retval = "";

# We want to check for '\', and it is just easier
Expand All @@ -322,6 +322,10 @@ sub process_variables {
$retval = "$retval$begin";
if (defined($variable{$var})) {
$retval = "$retval$variable{$var}";
} elsif (defined($remove_undef) && $remove_undef) {
# for if statements, any variable that is not defined,
# we simple convert to 0
$retval = "${retval}0";
} else {
# put back the origin piece.
$retval = "$retval\$\{$var\}";
Expand Down Expand Up @@ -403,10 +407,40 @@ sub value_defined {
defined($opt{$2});
}

sub process_if {
my ($name, $value) = @_;
my $d = 0;
sub process_expression {
my ($name, $val) = @_;

my $c = $d++;

while ($val =~ s/\(([^\(]*?)\)/\&\&\&\&VAL\&\&\&\&/) {
my $express = $1;

if (process_expression($name, $express)) {
$val =~ s/\&\&\&\&VAL\&\&\&\&/ 1 /;
} else {
$val =~ s/\&\&\&\&VAL\&\&\&\&/ 0 /;
}
}

$d--;
my $OR = "\\|\\|";
my $AND = "\\&\\&";

my $val = process_variables($value);
while ($val =~ s/^(.*?)($OR|$AND)//) {
my $express = $1;
my $op = $2;

if (process_expression($name, $express)) {
if ($op eq "||") {
return 1;
}
} else {
if ($op eq "&&") {
return 0;
}
}
}

if ($val =~ /(.*)(==|\!=|>=|<=|>|<)(.*)/) {
my $ret = process_compare($1, $2, $3);
Expand All @@ -431,7 +465,16 @@ sub process_if {
}

die ("$name: $.: Undefined content $val in if statement\n");
return 1;
}

sub process_if {
my ($name, $value) = @_;

# Convert variables and replace undefined ones with 0
my $val = process_variables($value, 1);
my $ret = process_expression $name, $val;

return $ret;
}

sub __read_config {
Expand Down
10 changes: 10 additions & 0 deletions trunk/tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@
# MAKE_CMD := make ARCH=x86
#
#
# And/or ops (&&,||) may also be used to make complex conditionals.
#
# TEST_START IF (DEFINED ALL_TESTS || ${MYTEST} == boottest) && ${MACHINE} == gandalf
#
# Notice the use of paranthesis. Without any paranthesis the above would be
# processed the same as:
#
# TEST_START IF DEFINED ALL_TESTS || (${MYTEST} == boottest && ${MACHINE} == gandalf)
#
#
#
# INCLUDE file
#
Expand Down

0 comments on commit 23fba18

Please sign in to comment.