summaryrefslogtreecommitdiffstats
path: root/tools/valgrind/chrome_tests.py
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-27 02:07:51 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-27 02:07:51 +0000
commit238a21d057719470eb2b7189beb2c9dafc43dde1 (patch)
tree69d08e0195da21383650cdfad6a817a0787953a7 /tools/valgrind/chrome_tests.py
parentb98634fe1c7c035f224141d1a07a264d0d4577c3 (diff)
downloadchromium_src-238a21d057719470eb2b7189beb2c9dafc43dde1.zip
chromium_src-238a21d057719470eb2b7189beb2c9dafc43dde1.tar.gz
chromium_src-238a21d057719470eb2b7189beb2c9dafc43dde1.tar.bz2
Teach the valgrind and layout tests about the output directory used by the Make build on Linux
BUG=http://crbug.com/15454 TEST=export GYP_GENERATORS=make; rm -rf sconsbuild; gclient runhooks --force; make -r base_unittests layout_tests; sh tools/valgrind/chrome_tests.sh -t base_unittests; verify that it finds and runs base_unittests; same thing with -t layout_tests Review URL: http://codereview.chromium.org/147209 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/valgrind/chrome_tests.py')
-rwxr-xr-xtools/valgrind/chrome_tests.py66
1 files changed, 40 insertions, 26 deletions
diff --git a/tools/valgrind/chrome_tests.py b/tools/valgrind/chrome_tests.py
index 96e5bc0..1417c9f 100755
--- a/tools/valgrind/chrome_tests.py
+++ b/tools/valgrind/chrome_tests.py
@@ -35,6 +35,39 @@ import common
class TestNotFound(Exception): pass
+def Dir2IsNewer(dir1, dir2):
+ if dir2 == None or not os.path.isdir(dir2):
+ return False
+ if dir1 == None or not os.path.isdir(dir1):
+ return True
+ return (os.stat(dir2)[stat.ST_MTIME] - os.stat(dir1)[stat.ST_MTIME]) > 0
+
+def FindNewestDir(dirs):
+ newest_dir = None
+ for dir in dirs:
+ if Dir2IsNewer(newest_dir, dir):
+ newest_dir = dir
+ return newest_dir
+
+def File2IsNewer(file1, file2):
+ if file2 == None or not os.path.isfile(file2):
+ return False
+ if file1 == None or not os.path.isfile(file1):
+ return True
+ return (os.stat(file2)[stat.ST_MTIME] - os.stat(file1)[stat.ST_MTIME]) > 0
+
+def FindDirContainingNewestFile(dirs, file):
+ newest_dir = None
+ newest_file = None
+ for dir in dirs:
+ the_file = os.path.join(dir, file)
+ if File2IsNewer(newest_file, the_file):
+ newest_dir = dir
+ newest_file = the_file
+ if newest_dir == None:
+ logging.error("cannot find file %s anywhere, have you built it?" % file)
+ sys.exit(-1)
+ return newest_dir
class ChromeTests:
'''This class is derived from the chrome_tests.py file in ../purify/.
@@ -94,34 +127,15 @@ class ChromeTests:
self._data_dirs.append(os.path.join(module_dir, "data", "valgrind"))
if not self._options.build_dir:
- builddir = {
- 'darwin': 'xcodebuild',
- 'linux2': 'sconsbuild'
- }[sys.platform]
- dir_chrome = os.path.join(self._source_dir, builddir, "Debug")
- dir_module = os.path.join(module_dir, "Debug")
+ dirs = [
+ os.path.join(self._source_dir, "xcodebuild", "Debug"),
+ os.path.join(self._source_dir, "sconsbuild", "Debug"),
+ os.path.join(self._source_dir, "out", "Debug"),
+ ]
if exe:
- exe_chrome = os.path.join(dir_chrome, exe)
- exe_module = os.path.join(dir_module, exe)
- if os.path.isfile(exe_chrome) and not os.path.isfile(exe_module):
- self._options.build_dir = dir_chrome
- elif os.path.isfile(exe_module) and not os.path.isfile(exe_chrome):
- self._options.build_dir = dir_module
- elif (os.stat(exe_module)[stat.ST_MTIME] >
- os.stat(exe_chrome)[stat.ST_MTIME]):
- self._options.build_dir = dir_module
- else:
- self._options.build_dir = dir_chrome
+ self._options.build_dir = FindDirContainingNewestFile(dirs, exe)
else:
- if os.path.isdir(dir_chrome) and not os.path.isdir(dir_module):
- self._options.build_dir = dir_chrome
- elif os.path.isdir(dir_module) and not os.path.isdir(dir_chrome):
- self._options.build_dir = dir_module
- elif (os.stat(dir_module)[stat.ST_MTIME] >
- os.stat(dir_chrome)[stat.ST_MTIME]):
- self._options.build_dir = dir_module
- else:
- self._options.build_dir = dir_chrome
+ self._options.build_dir = FindNewestDir(dirs)
cmd = list(self._command_preamble)
for directory in self._data_dirs: