OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 # asan_test.py | |
7 | |
8 """Wrapper for running the test under AddressSanitizer.""" | |
9 | |
10 import datetime | |
11 import logging | |
12 import os | |
13 import re | |
14 | |
15 import common | |
16 import path_utils | |
17 import suppressions | |
18 | |
19 | |
20 class ASanWrapper(object): | |
21 def __init__(self, supp_files): | |
22 self._timeout = 1200 | |
23 | |
24 def PutEnvAndLog(self, env_name, env_value): | |
25 """Sets the env var |env_name| to |env_value| and writes to logging.info. | |
26 """ | |
27 os.putenv(env_name, env_value) | |
28 logging.info('export %s=%s', env_name, env_value) | |
29 | |
30 def Execute(self): | |
31 """Executes the app to be tested.""" | |
32 logging.info('starting execution...') | |
33 proc = self._args | |
34 self.PutEnvAndLog('G_SLICE', 'always-malloc') | |
35 self.PutEnvAndLog('NSS_DISABLE_ARENA_FREE_LIST', '1') | |
36 self.PutEnvAndLog('NSS_DISABLE_UNLOAD', '1') | |
37 self.PutEnvAndLog('GTEST_DEATH_TEST_USE_FORK', '1') | |
38 return common.RunSubprocess(proc, self._timeout) | |
39 | |
40 def Main(self, args): | |
41 self._args = args | |
42 start = datetime.datetime.now() | |
43 retcode = -1 | |
44 retcode = self.Execute() | |
45 end = datetime.datetime.now() | |
46 seconds = (end - start).seconds | |
47 hours = seconds / 3600 | |
48 seconds %= 3600 | |
49 minutes = seconds / 60 | |
50 seconds %= 60 | |
51 logging.info('elapsed time: %02d:%02d:%02d', hours, minutes, seconds) | |
52 logging.info('For more information on the AddressSanitizer bot see ' | |
53 'http://dev.chromium.org/developers/testing/' | |
54 'addresssanitizer') | |
55 return retcode | |
56 | |
57 | |
58 def RunTool(args, supp_files, module): | |
59 tool = ASanWrapper(supp_files) | |
60 return tool.Main(args[1:]) | |
OLD | NEW |