Commit 9900b5dc authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

ktest: Add DEFINED keyword for IF statements

Have IF statements process if a config variable or option has been
defined or not. Can use NOT DEFINED in the case for telling if
a variable or option has not been defined.

DEFAULTS IF NOT DEFINED SSH_USER
SSH_USER = root
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 3d1cc414
......@@ -396,6 +396,13 @@ sub process_compare {
return $ret;
}
sub value_defined {
my ($val) = @_;
return defined($variable{$2}) ||
defined($opt{$2});
}
sub process_if {
my ($name, $value) = @_;
......@@ -409,13 +416,21 @@ sub process_if {
return $ret;
}
if ($val =~ /^\s*(NOT\s*)?DEFINED\s+(\S+)\s*$/) {
if (defined $1) {
return !value_defined($2);
} else {
return value_defined($2);
}
}
if ($val =~ /^\s*0\s*$/) {
return 0;
} elsif ($val =~ /^\s*\d+\s*$/) {
return 1;
}
die ("$name: $.: Undefined variable $val in if statement\n");
die ("$name: $.: Undefined content $val in if statement\n");
return 1;
}
......
......@@ -137,6 +137,23 @@
# ELSE
# BUILD_TYPE = useconfig:${CONFIG_DIR}/config-64
#
# The DEFINED keyword can be used by the IF statements too.
# It returns true if the given config variable or option has been defined
# or false otherwise.
#
#
# DEFAULTS IF DEFINED USE_CC
# CC := ${USE_CC}
# ELSE
# CC := gcc
#
#
# As well as NOT DEFINED.
#
# DEFAULTS IF NOT DEFINED MAKE_CMD
# MAKE_CMD := make ARCH=x86
#
#
#
# INCLUDE file
#
......
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