Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 275171
b: refs/heads/master
c: 45d73a5
h: refs/heads/master
i:
  275169: b85c6c5
  275167: 4baf1ed
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Oct 17, 2011
1 parent fe060f1 commit 9b5bf48
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 5 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: 4ab1cce5bdd87948b75ed4fe4a8629c0f76267ae
refs/heads/master: 45d73a5d8a98dbabcdf37e2da5ef5b0412244643
64 changes: 60 additions & 4 deletions trunk/tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,21 @@ sub set_variable {
}
}

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

my $val = process_variables($value);

if ($val =~ /^\s*0\s*$/) {
return 0;
} elsif ($val =~ /^\s*\d+\s*$/) {
return 1;
}

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

sub read_config {
my ($config) = @_;

Expand All @@ -376,6 +391,8 @@ sub read_config {
my $skip = 0;
my $rest;
my $test_case = 0;
my $if = 0;
my $if_set = 0;

while (<IN>) {

Expand All @@ -397,7 +414,7 @@ sub read_config {
$default = 0;
$repeat = 1;

if ($rest =~ /\s+SKIP(.*)/) {
if ($rest =~ /\s+SKIP\b(.*)/) {
$rest = $1;
$skip = 1;
} else {
Expand All @@ -411,9 +428,16 @@ sub read_config {
$repeat_tests{"$test_num"} = $repeat;
}

if ($rest =~ /\s+SKIP(.*)/) {
$rest = $1;
$skip = 1;
if ($rest =~ /\sIF\s+(\S*)(.*)/) {
$rest = $2;
if (process_if($name, $1)) {
$if_set = 1;
} else {
$skip = 1;
}
$if = 1;
} else {
$if = 0;
}

if ($rest !~ /^\s*$/) {
Expand All @@ -437,10 +461,42 @@ sub read_config {
$skip = 0;
}

if ($rest =~ /\sIF\s+(\S*)(.*)/) {
$if = 1;
$rest = $2;
if (process_if($name, $1)) {
$if_set = 1;
} else {
$skip = 1;
}
} else {
$if = 0;
}

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

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

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

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

next if ($skip);
Expand Down
38 changes: 38 additions & 0 deletions trunk/tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,44 @@
# 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).
#
# DEFAULTS IF ${IS_X86_32}
#
# The above will process the DEFAULTS section if the config
# variable IS_X86_32 evaluates to a non zero positive integer
# otherwise if it evaluates to zero, it will act the same
# as if the SKIP keyword was used.
#
# The ELSE keyword can be used directly after a section with
# a IF statement.
#
# TEST_START IF ${RUN_NET_TESTS}
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network
#
# ELSE
#
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-normal
#
#
# The ELSE keyword can also contain an IF statement to allow multiple
# if then else sections. But all the sections must be either
# DEFAULT or TEST_START, they can not be a mixture.
#
# TEST_START IF ${RUN_NET_TESTS}
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network
#
# ELSE IF ${RUN_DISK_TESTS}
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-tests
#
# ELSE IF ${RUN_CPU_TESTS}
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-cpu
#
# ELSE
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network
#

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

0 comments on commit 9b5bf48

Please sign in to comment.