OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # valgrind_test.py | 6 # valgrind_test.py |
7 | 7 |
8 '''Runs an exe through Valgrind and puts the intermediate files in a | 8 '''Runs an exe through Valgrind and puts the intermediate files in a |
9 directory. | 9 directory. |
10 ''' | 10 ''' |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 logging.info("starting execution...") | 253 logging.info("starting execution...") |
254 | 254 |
255 proc = self.ValgrindCommand() | 255 proc = self.ValgrindCommand() |
256 os.putenv("G_SLICE", "always-malloc") | 256 os.putenv("G_SLICE", "always-malloc") |
257 logging.info("export G_SLICE=always-malloc"); | 257 logging.info("export G_SLICE=always-malloc"); |
258 os.putenv("NSS_DISABLE_ARENA_FREE_LIST", "1") | 258 os.putenv("NSS_DISABLE_ARENA_FREE_LIST", "1") |
259 logging.info("export NSS_DISABLE_ARENA_FREE_LIST=1"); | 259 logging.info("export NSS_DISABLE_ARENA_FREE_LIST=1"); |
260 os.putenv("GTEST_DEATH_TEST_USE_FORK", "1") | 260 os.putenv("GTEST_DEATH_TEST_USE_FORK", "1") |
261 logging.info("export GTEST_DEATH_TEST_USE_FORK=1"); | 261 logging.info("export GTEST_DEATH_TEST_USE_FORK=1"); |
262 | 262 |
263 common.RunSubprocess(proc, self._timeout) | 263 return common.RunSubprocess(proc, self._timeout) |
264 | |
265 # Always return true, even if running the subprocess failed. We depend on | |
266 # Analyze to determine if the run was valid. | |
267 return True | |
268 | 264 |
269 def Analyze(self): | 265 def Analyze(self): |
270 raise RuntimeError, "This method should be implemented " \ | 266 raise RuntimeError, "This method should be implemented " \ |
271 "in the tool-specific subclass" | 267 "in the tool-specific subclass" |
272 | 268 |
273 def Cleanup(self): | 269 def Cleanup(self): |
274 # Right now, we can cleanup by deleting our temporary directory. Other | 270 # Right now, we can cleanup by deleting our temporary directory. Other |
275 # cleanup is still a TODO? | 271 # cleanup is still a TODO? |
276 if not self._nocleanup_on_exit: | 272 if not self._nocleanup_on_exit: |
277 shutil.rmtree(self.TMP_DIR, ignore_errors=True) | 273 shutil.rmtree(self.TMP_DIR, ignore_errors=True) |
278 return True | 274 return True |
279 | 275 |
280 def RunTestsAndAnalyze(self): | 276 def RunTestsAndAnalyze(self): |
281 self.PrepareForTest() | 277 self.PrepareForTest() |
282 self.Execute() | 278 exec_retcode = self.Execute() |
| 279 analyze_retcode = self.Analyze() |
283 | 280 |
284 retcode = self.Analyze() | 281 if analyze_retcode: |
285 if retcode: | |
286 logging.error("Analyze failed.") | 282 logging.error("Analyze failed.") |
287 return retcode | 283 return analyze_retcode |
| 284 |
| 285 if exec_retcode: |
| 286 logging.error("Test Execution failed.") |
| 287 return exec_retcode |
| 288 |
288 logging.info("Execution and analysis completed successfully.") | 289 logging.info("Execution and analysis completed successfully.") |
289 return 0 | 290 return 0 |
290 | 291 |
291 def CreateBrowserWrapper(self, command): | 292 def CreateBrowserWrapper(self, command): |
292 """The program being run invokes Python or something else | 293 """The program being run invokes Python or something else |
293 that can't stand to be valgrinded, and also invokes | 294 that can't stand to be valgrinded, and also invokes |
294 the Chrome browser. Set an environment variable to | 295 the Chrome browser. Set an environment variable to |
295 tell the program to prefix the Chrome commandline | 296 tell the program to prefix the Chrome commandline |
296 with a magic wrapper. Build the magic wrapper here. | 297 with a magic wrapper. Build the magic wrapper here. |
297 """ | 298 """ |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 483 |
483 if __name__ == "__main__": | 484 if __name__ == "__main__": |
484 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: | 485 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: |
485 google.logging_utils.config_root(logging.DEBUG) | 486 google.logging_utils.config_root(logging.DEBUG) |
486 else: | 487 else: |
487 google.logging_utils.config_root() | 488 google.logging_utils.config_root() |
488 # TODO(timurrrr): valgrind tools may use -v/--verbose as well | 489 # TODO(timurrrr): valgrind tools may use -v/--verbose as well |
489 | 490 |
490 ret = RunTool(sys.argv) | 491 ret = RunTool(sys.argv) |
491 sys.exit(ret) | 492 sys.exit(ret) |
OLD | NEW |