[Lldb-commits] [lldb] r149304 - /lldb/trunk/test/dotest.py

Johnny Chen johnny.chen at apple.com
Mon Jan 30 16:38:04 PST 2012


Author: johnny
Date: Mon Jan 30 18:38:03 2012
New Revision: 149304

URL: http://llvm.org/viewvc/llvm-project?rev=149304&view=rev
Log:
Add a '-u ENV_VAR_NAME' option to the test driver, whose purpose is to unset the said
environment variable before starting the test runner which executes the test cases and
may spawn child processes.  An example:

    ./dotest.py -u MY_ENV1 -u MY_ENV2 -v -p TestWatchLocationWithWatchSet.py

Modified:
    lldb/trunk/test/dotest.py

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=149304&r1=149303&r2=149304&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon Jan 30 18:38:03 2012
@@ -161,6 +161,9 @@
 # svn_info stores the output from 'svn info lldb.base.dir'.
 svn_info = ''
 
+# The environment variables to unset before running the test cases.
+unsets = []
+
 # Default verbosity is 0.
 verbose = 0
 
@@ -229,6 +232,8 @@
        with errored or failed status; if not specified, the test driver uses the
        timestamp as the session dir name
 -t   : turn on tracing of lldb command and other detailed test executions
+-u   : specify an environment variable to unset before running the test cases
+       e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble'
 -v   : do verbose mode of unittest framework (print out each test case invocation)
 -X   : exclude a directory from consideration for test discovery
        -X types => if 'types' appear in the pathname components of a potential testfile
@@ -362,6 +367,7 @@
     global regexp
     global rdir
     global sdir_name
+    global unsets
     global verbose
     global testdirs
 
@@ -503,6 +509,13 @@
         elif sys.argv[index].startswith('-t'):
             os.environ["LLDB_COMMAND_TRACE"] = "YES"
             index += 1
+        elif sys.argv[index].startswith('-u'):
+            # Increment by 1 to fetch the environment variable to unset.
+            index += 1
+            if index >= len(sys.argv) or sys.argv[index].startswith('-'):
+                usage()
+            unsets.append(sys.argv[index])
+            index += 1
         elif sys.argv[index].startswith('-v'):
             verbose = 2
             index += 1
@@ -1009,6 +1022,16 @@
     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
 # over different configurations.
 #





More information about the lldb-commits mailing list