Skip to content

Commit

Permalink
ktest: Allow perl regex expressions in conditional statements
Browse files Browse the repository at this point in the history
Add '=~' and '!~' to the list of allowed conditionals for DEFAULT and
TEST_START section if statements.

ie.

 TEST_START IF TEST =~ .*test$

Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
Steven Rostedt authored and rostedt committed Jul 30, 2012
1 parent 9b1d367 commit 8fddbe9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ sub process_compare {
return $lval eq $rval;
} elsif ($cmp eq "!=") {
return $lval ne $rval;
} elsif ($cmp eq "=~") {
return $lval =~ m/$rval/;
} elsif ($cmp eq "!~") {
return $lval !~ m/$rval/;
}

my $statement = "$lval $cmp $rval";
Expand Down Expand Up @@ -678,7 +682,7 @@ sub process_expression {
}
}

if ($val =~ /(.*)(==|\!=|>=|<=|>|<)(.*)/) {
if ($val =~ /(.*)(==|\!=|>=|<=|>|<|=~|\!~)(.*)/) {
my $ret = process_compare($1, $2, $3);
if ($ret < 0) {
die "$name: $.: Unable to process comparison\n";
Expand Down

0 comments on commit 8fddbe9

Please sign in to comment.