diff options
author | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-27 02:07:51 +0000 |
---|---|---|
committer | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-27 02:07:51 +0000 |
commit | 238a21d057719470eb2b7189beb2c9dafc43dde1 (patch) | |
tree | 69d08e0195da21383650cdfad6a817a0787953a7 | |
parent | b98634fe1c7c035f224141d1a07a264d0d4577c3 (diff) | |
download | chromium_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
-rwxr-xr-x | tools/valgrind/chrome_tests.py | 66 | ||||
-rw-r--r-- | webkit/tools/layout_tests/layout_package/platform_utils_linux.py | 17 |
2 files changed, 53 insertions, 30 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: diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py index 18c0743..7a4ec11 100644 --- a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py +++ b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py @@ -23,6 +23,15 @@ THISDIR = os.path.dirname(os.path.abspath(__file__)) def PathFromBase(*pathies): return google.path_utils.FindUpward(THISDIR, *pathies) +def PathFromBuildResults(*pathies): + # FIXME(dkegel): use latest or warn if more than one found? + for dir in ["sconsbuild", "out", "xcodebuild"]: + try: + return google.path_utils.FindUpward(THISDIR, dir, *pathies) + except: + pass + raise google.path_utils.PathNotFound("Unable to find %s under any ancestor of %s" % (os.path.join(*pathies), THISDIR)) + def IsNonWindowsPlatformTargettingWindowsResults(): """Returns true iff this platform is targetting Windows baseline, but isn't Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to @@ -162,7 +171,7 @@ class PlatformUtility(object): def ImageCompareExecutablePath(self, target): """Path to the image_diff binary.""" - return PathFromBase('sconsbuild', target, 'image_diff') + return PathFromBuildResults(target, 'image_diff') def TestShellBinary(self): """The name of the binary for TestShell.""" @@ -177,8 +186,8 @@ class PlatformUtility(object): if target in ('Debug', 'Release'): try: - debug_path = PathFromBase('sconsbuild', 'Debug', self.TestShellBinary()) - release_path = PathFromBase('sconsbuild', 'Release', \ + debug_path = PathFromBuildResults('Debug', self.TestShellBinary()) + release_path = PathFromBuildResults('Release', \ self.TestShellBinary()) debug_mtime = os.stat(debug_path).st_mtime @@ -198,7 +207,7 @@ class PlatformUtility(object): except google.path_utils.PathNotFound: pass - return PathFromBase('sconsbuild', target, self.TestShellBinary()) + return PathFromBuildResults(target, self.TestShellBinary()) def FuzzyMatchBinaryPath(self): """Return the path to the fuzzy matcher binary.""" |