aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest/ktest.pl
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-09-30 22:41:14 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-10-17 11:54:11 -0400
commit9900b5dc067551fcdcaec63d013b1d95b36835ae (patch)
tree7d5b8009f6ee03e4bae24efcb802be9b620c78c9 /tools/testing/ktest/ktest.pl
parent3d1cc41432b0491a39a3185b52bfa1d0411bba10 (diff)
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: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-xtools/testing/ktest/ktest.pl17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 7bce412bbdcc..76a5964595da 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -396,6 +396,13 @@ sub process_compare {
396 return $ret; 396 return $ret;
397} 397}
398 398
399sub value_defined {
400 my ($val) = @_;
401
402 return defined($variable{$2}) ||
403 defined($opt{$2});
404}
405
399sub process_if { 406sub process_if {
400 my ($name, $value) = @_; 407 my ($name, $value) = @_;
401 408
@@ -409,13 +416,21 @@ sub process_if {
409 return $ret; 416 return $ret;
410 } 417 }
411 418
419 if ($val =~ /^\s*(NOT\s*)?DEFINED\s+(\S+)\s*$/) {
420 if (defined $1) {
421 return !value_defined($2);
422 } else {
423 return value_defined($2);
424 }
425 }
426
412 if ($val =~ /^\s*0\s*$/) { 427 if ($val =~ /^\s*0\s*$/) {
413 return 0; 428 return 0;
414 } elsif ($val =~ /^\s*\d+\s*$/) { 429 } elsif ($val =~ /^\s*\d+\s*$/) {
415 return 1; 430 return 1;
416 } 431 }
417 432
418 die ("$name: $.: Undefined variable $val in if statement\n"); 433 die ("$name: $.: Undefined content $val in if statement\n");
419 return 1; 434 return 1;
420} 435}
421 436