Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 275172
b: refs/heads/master
c: ab7a3f5
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Oct 17, 2011
1 parent 9b5bf48 commit 0d5bc18
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 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: 45d73a5d8a98dbabcdf37e2da5ef5b0412244643
refs/heads/master: ab7a3f52cef5ff1c784de7adfbda3421b10754a4
54 changes: 48 additions & 6 deletions trunk/tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,47 @@ sub set_variable {
}
}

sub process_compare {
my ($lval, $cmp, $rval) = @_;

# remove whitespace

$lval =~ s/^\s*//;
$lval =~ s/\s*$//;

$rval =~ s/^\s*//;
$rval =~ s/\s*$//;

if ($cmp eq "==") {
return $lval eq $rval;
} elsif ($cmp eq "!=") {
return $lval ne $rval;
}

my $statement = "$lval $cmp $rval";
my $ret = eval $statement;

# $@ stores error of eval
if ($@) {
return -1;
}

return $ret;
}

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

my $val = process_variables($value);

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

if ($val =~ /^\s*0\s*$/) {
return 0;
} elsif ($val =~ /^\s*\d+\s*$/) {
Expand Down Expand Up @@ -428,8 +464,8 @@ sub read_config {
$repeat_tests{"$test_num"} = $repeat;
}

if ($rest =~ /\sIF\s+(\S*)(.*)/) {
$rest = $2;
if ($rest =~ /\sIF\s+(.*)/) {
$rest = "";
if (process_if($name, $1)) {
$if_set = 1;
} else {
Expand Down Expand Up @@ -461,14 +497,14 @@ sub read_config {
$skip = 0;
}

if ($rest =~ /\sIF\s+(\S*)(.*)/) {
if ($rest =~ /\sIF\s+(.*)/) {
$if = 1;
$rest = $2;
if (process_if($name, $1)) {
$if_set = 1;
} else {
$skip = 1;
}
$rest = "";
} else {
$if = 0;
}
Expand All @@ -477,26 +513,32 @@ sub read_config {
die "$name: $.: Gargbage found after DEFAULTS\n$_";
}

} elsif (/^\s*ELSE(.*)$/) {
} elsif (/^\s*ELSE\b(.*)$/) {
if (!$if) {
die "$name: $.: ELSE found with out matching IF section\n$_";
}
$rest = $1;
if ($if_set) {
$skip = 1;
$rest = "";
} else {
$skip = 0;

if ($rest =~ /\sIF\s+(\S*)(.*)/) {
if ($rest =~ /\sIF\s+(.*)/) {
# May be a ELSE IF section.
if (!process_if($name, $1)) {
$skip = 1;
}
$rest = "";
} else {
$if = 0;
}
}

if ($rest !~ /^\s*$/) {
die "$name: $.: Gargbage found after DEFAULTS\n$_";
}

} elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {

next if ($skip);
Expand Down
14 changes: 14 additions & 0 deletions trunk/tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
# the same option name under the same test or as default
# ktest will fail to execute, and no tests will run.
#
#
#
# Both TEST_START and DEFAULTS sections can also have the IF keyword
# The value after the IF must evaluate into a 0 or non 0 positive
# integer, and can use the config variables (explained below).
Expand Down Expand Up @@ -110,6 +112,18 @@
# ELSE
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network
#
# The if statement may also have comparisons that will and for
# == and !=, strings may be used for both sides.
#
# BOX_TYPE := x86_32
#
# DEFAULTS IF ${BOX_TYPE} == x86_32
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-32
# ELSE
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-64
#



#### Config variables ####
#
Expand Down

0 comments on commit 0d5bc18

Please sign in to comment.