[llvm-branch-commits] [cfe-branch] r151771 - in /cfe/branches/Apple/palisade-IB/order-files: commands.py gen-clang-order-data

Daniel Dunbar daniel at zuster.org
Wed Feb 29 15:35:41 PST 2012


Author: ddunbar
Date: Wed Feb 29 17:35:41 2012
New Revision: 151771

URL: http://llvm.org/viewvc/llvm-project?rev=151771&view=rev
Log:
build/order-files: Run dtrace scripts with a scrubbed environment.

Modified:
    cfe/branches/Apple/palisade-IB/order-files/commands.py
    cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data

Modified: cfe/branches/Apple/palisade-IB/order-files/commands.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/commands.py?rev=151771&r1=151770&r2=151771&view=diff
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/commands.py (original)
+++ cfe/branches/Apple/palisade-IB/order-files/commands.py Wed Feb 29 17:35:41 2012
@@ -50,7 +50,7 @@
         if e.errno != errno.EEXIST:
             raise
 
-def capture_with_result(args, include_stderr=False, cwd=None):
+def capture_with_result(args, include_stderr=False, cwd=None, env=None):
     import subprocess
     """capture_with_result(command) -> (output, exit code)
 
@@ -61,7 +61,7 @@
         stderr = subprocess.STDOUT
     try:
         p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=stderr,
-                             cwd=cwd)
+                             cwd=cwd, env=env)
     except OSError,e:
         if e.errno == errno.ENOENT:
             fatal('no such file or directory: %r' % args[0])
@@ -69,11 +69,11 @@
     out,_ = p.communicate()
     return out,p.wait()
 
-def capture(args, include_stderr=False, cwd=None):
+def capture(args, include_stderr=False, cwd=None, env=None):
     import subprocess
     """capture(command) - Run the given command (or argv list) in a shell and
     return the standard output."""
-    return capture_with_result(args, include_stderr, cwd)[0]
+    return capture_with_result(args, include_stderr, cwd, env)[0]
 
 def which(command, paths = None):
     """which(command, [paths]) - Look up the given command in the paths string

Modified: cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data?rev=151771&r1=151770&r2=151771&view=diff
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data (original)
+++ cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data Wed Feb 29 17:35:41 2012
@@ -39,11 +39,11 @@
         'trivial-c-i386', None, False,
         ('-c', 'trivial-input.c', '-O0', '-g', '-arch', 'i386'))
 
-def get_cc1_command_for_args(cmd, cwd):
+def get_cc1_command_for_args(cmd, cwd, env):
     # Find the cc1 command used by the compiler. To do this we execute the
     # compiler with '-###' to figure out what it wants to do.
     cc_output = commands.capture(cmd + ['-###'],
-                                 include_stderr=True, cwd=cwd).strip()
+                                 include_stderr=True, cwd=cwd, env=env).strip()
     cc_commands = []
     for ln in cc_output.split('\n'):
         # Filter out known garbage.
@@ -60,7 +60,7 @@
 
     return shlex.split(cc_commands[0])
 
-def execute_dtrace_test(args, data_name, opts,
+def execute_dtrace_test(args, data_name, opts, env,
                         suppress_stderr=False):
     # Form the dtrace script to run.
     if opts.use_multishot:
@@ -94,7 +94,7 @@
             stderr = None
         start_time = time.time()
         subprocess.check_call(dtrace_args, stdout=f, stderr=stderr,
-                              cwd=opts.inputs_path)
+                              cwd=opts.inputs_path, env=env)
         elapsed = time.time() - start_time
         commands.note("... data collection took %.4fs" % (elapsed,))
 
@@ -111,13 +111,17 @@
     full_args = [opts.cc] + list(actual_args) + [
         '-o', os.path.join(opts.temps_path, output_name)]
 
+    # Create a scrubbed environment to execute the tests in.
+    test_env = {
+        'PATH' : os.environ['PATH'] }
+
     # Gather data on the driver invocation.
     if opts.sample_driver and test_driver:
         execute_dtrace_test(full_args + ['-###'], "%s.driver" % (test_name),
-                            opts, suppress_stderr=True)
+                            opts, test_env, suppress_stderr=True)
 
     # Extract the cc1 level command.
-    cc1_cmd = get_cc1_command_for_args(full_args, opts.inputs_path)
+    cc1_cmd = get_cc1_command_for_args(full_args, opts.inputs_path, test_env)
 
     # We can't use dtrace's -c option if there are space in options.
     for arg in cc1_cmd:
@@ -126,7 +130,7 @@
                     cc1_cmd,))
 
     # Gather data on the cc1 invocation.
-    execute_dtrace_test(cc1_cmd, test_name, opts)
+    execute_dtrace_test(cc1_cmd, test_name, opts, test_env)
 
 def main():
     parser = OptionParser("%prog  [options]")





More information about the llvm-branch-commits mailing list