Chromium Code Reviews| Index: tools/isolate/run_test_cases.py |
| diff --git a/tools/isolate/run_test_cases.py b/tools/isolate/run_test_cases.py |
| index d2c69c7ae960ee9fcdad1928ba06ff179cea3747..00bbb5d576ccb33f77afa59b8bb3d1023f980b4c 100755 |
| --- a/tools/isolate/run_test_cases.py |
| +++ b/tools/isolate/run_test_cases.py |
| @@ -16,6 +16,7 @@ import optparse |
| import os |
| import Queue |
| import subprocess |
| +import stat |
| import sys |
| import threading |
| import time |
| @@ -56,6 +57,24 @@ GTEST_ENV_VARS_TO_REMOVE = [ |
| 'GTEST_TOTAL_SHARDS', |
| ] |
| +CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' |
| +CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' |
| + |
| + |
| +def should_enable_sandbox(sandbox_path): |
| + """Return a boolean indicating that the current slave is capable of using the |
| + sandbox and should enable it. This should return True iff the slave is a |
| + Linux host with the sandbox file present and configured correctly.""" |
| + if not (sys.platform.startswith('linux') and |
| + os.path.exists(sandbox_path)): |
| + return False |
| + sandbox_stat = os.stat(sandbox_path) |
| + if ((sandbox_stat.st_mode & stat.S_ISUID) and |
| + (sandbox_stat.st_mode & stat.S_IRUSR) and |
| + (sandbox_stat.st_mode & stat.S_IXUSR) and |
| + (sandbox_stat.st_uid == 0)): |
| + return True |
| + return False |
| def num_processors(): |
| """Returns the number of processors. |
| @@ -561,6 +580,21 @@ class Runner(object): |
| self.env = setup_gtest_env() |
| self.decider = decider |
| + # Setup the chrome sandbox, using the default path if no path is specified. |
|
M-A Ruel
2012/08/30 18:47:37
This code doesn't belong here, run_test_cases.py i
|
| + if CHROME_SANDBOX_ENV in self.env: |
| + chrome_sandbox_path = self.env[CHROME_SANDBOX_ENV] |
| + else: |
| + chrome_sandbox_path = CHROME_SANDBOX_PATH |
| + |
| + if should_enable_sandbox(chrome_sandbox_path): |
| + print 'Enabling sandbox. Setting environment variable:' |
| + print ' %s="%s"' % (CHROME_SANDBOX_ENV, chrome_sandbox_path) |
| + self.env[CHROME_SANDBOX_ENV] = chrome_sandbox_path |
| + else: |
| + print 'Disabling sandbox. Setting environment variable:' |
| + print ' %s=""' % CHROME_SANDBOX_ENV |
| + self.env[CHROME_SANDBOX_ENV] = '' |
| + |
| def map(self, test_case): |
| """Traces a single test case and returns its output.""" |
| cmd = [self.executable, '--gtest_filter=%s' % test_case] |