Unset the environment variables as soon as possible when running the test suite. Also don't store the unset list into a global when they aren't needed in a global variable.

llvm-svn: 174750
This commit is contained in:
Greg Clayton 2013-02-08 21:52:32 +00:00
parent 7adbc0eaa4
commit 0dd5e7b598
1 changed files with 9 additions and 18 deletions

View File

@ -206,9 +206,6 @@ sdir_has_content = False
# svn_info stores the output from 'svn info lldb.base.dir'. # svn_info stores the output from 'svn info lldb.base.dir'.
svn_info = '' svn_info = ''
# The environment variables to unset before running the test cases.
unsets = []
# Default verbosity is 0. # Default verbosity is 0.
verbose = 0 verbose = 0
@ -346,7 +343,6 @@ def parseOptionsAndInitTestdirs():
global regexp global regexp
global rdir global rdir
global sdir_name global sdir_name
global unsets
global verbose global verbose
global testdirs global testdirs
@ -406,7 +402,7 @@ def parseOptionsAndInitTestdirs():
X('-n', "Don't print the headers like build dir, lldb version, and svn info at all") X('-n', "Don't print the headers like build dir, lldb version, and svn info at all")
X('-S', "Skip the build and cleanup while running the test. Use this option with care as you would need to build the inferior(s) by hand and build the executable(s) with the correct name(s). This can be used with '-# n' to stress test certain test cases for n number of times") X('-S', "Skip the build and cleanup while running the test. Use this option with care as you would need to build the inferior(s) by hand and build the executable(s) with the correct name(s). This can be used with '-# n' to stress test certain test cases for n number of times")
X('-t', 'Turn on tracing of lldb command and other detailed test executions') X('-t', 'Turn on tracing of lldb command and other detailed test executions')
group.add_argument('-u', metavar='variable', action='append', help='Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble') group.add_argument('-u', dest='unset_env_varnames', metavar='variable', action='append', help='Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble')
X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)') X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)')
X('-w', 'Insert some wait time (currently 0.5 sec) between consecutive test cases') X('-w', 'Insert some wait time (currently 0.5 sec) between consecutive test cases')
@ -420,6 +416,14 @@ def parseOptionsAndInitTestdirs():
platform_system = platform.system() platform_system = platform.system()
platform_machine = platform.machine() platform_machine = platform.machine()
if args.unset_env_varnames:
for env_var in args.unset_env_varnames:
if env_var in os.environ:
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
# is automatically translated into a corresponding call to unsetenv().
del os.environ[env_var]
#os.unsetenv(env_var)
# only print the args if being verbose # only print the args if being verbose
if args.v: if args.v:
print args print args
@ -568,9 +572,6 @@ def parseOptionsAndInitTestdirs():
if args.t: if args.t:
os.environ['LLDB_COMMAND_TRACE'] = 'YES' os.environ['LLDB_COMMAND_TRACE'] = 'YES'
if args.u:
unsets.extend(args.u)
if args.v: if args.v:
verbose = 2 verbose = 2
@ -1162,16 +1163,6 @@ with open(fname, "w") as f:
print >> f, svn_info print >> f, svn_info
print >> f, "Command invoked: %s\n" % getMyCommandLine() print >> f, "Command invoked: %s\n" % getMyCommandLine()
#
# If we have environment variables to unset, do it here before we invoke the test runner.
#
for env_var in unsets :
if env_var in os.environ:
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
# is automatically translated into a corresponding call to unsetenv().
del os.environ[env_var]
#os.unsetenv(env_var)
# #
# Invoke the default TextTestRunner to run the test suite, possibly iterating # Invoke the default TextTestRunner to run the test suite, possibly iterating
# over different configurations. # over different configurations.