master - test: Fix handling of envvars in the runner.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3bf89ebcc98a1e03c1687d6b292be3274a9bc8a Commit: f3bf89ebcc98a1e03c1687d6b292be3274a9bc8a Parent: 0bd2a9b7b10640d9d16cceb9e753acff6356d5df Author: Petr Rockai <[email protected]> AuthorDate: Fri Jun 27 01:03:08 2014 +0200 Committer: Petr Rockai <[email protected]> CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Fix handling of envvars in the runner.
--- test/lib/runner.cpp | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
test/lib/runner.cpp +12 -3
@@ -391,6 +391,15 @@ struct Args { } }; +bool hasenv( const char *name ) { + const char *v = getenv( name ); + if ( !v ) + return false; + if ( strlen( v ) == 0 || !strcmp( v, "0" ) ) + return false; + return true; +} + int main(int argc, char **argv) { Args args( argc, argv );
@@ -399,17 +408,17 @@ int main(int argc, char **argv) if ( args.has( "--continue" ) ) opt.cont = true; - if ( args.has( "--quiet" ) || getenv( "QUIET" ) ) { + if ( args.has( "--quiet" ) || hasenv( "QUIET" ) ) { opt.verbose = false; opt.quiet = true; } - if ( args.has( "--verbose" ) || getenv( "VERBOSE" ) ) { + if ( args.has( "--verbose" ) || hasenv( "VERBOSE" ) ) { opt.quiet = false; opt.verbose = true; } - if ( args.has( "--interactive" ) || getenv( "INTERACTIVE" ) ) { + if ( args.has( "--interactive" ) || hasenv( "INTERACTIVE" ) ) { opt.verbose = false; opt.quiet = false; opt.interactive = true;