From 9d40e2971d283eaa2881bf1b7b9fd804e4b0601a Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 5 Jun 2012 19:12:40 +0000 Subject: Fix hardlinking issue happening on linux. Uses a temporary directory on the same filesystem than cache_dir if /tmp is mapped on another file system, like tmpfs. NOTRY=true R=cmp@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10538010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140575 0039d316-1c4b-4281-b951-d872f2087c98 --- tools/isolate/run_test_from_archive.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tools/isolate') diff --git a/tools/isolate/run_test_from_archive.py b/tools/isolate/run_test_from_archive.py index 847e5cf..220e24f 100755 --- a/tools/isolate/run_test_from_archive.py +++ b/tools/isolate/run_test_from_archive.py @@ -107,6 +107,14 @@ def rmtree(root): shutil.rmtree(root) +def is_same_filesystem(path1, path2): + """Returns True if both paths are on the same filesystem. + + This is required to enable the use of hardlinks. + """ + return os.stat(path1).st_dev == os.stat(path2).st_dev + + def open_remote(file_or_url): """Reads a file or url.""" if re.match(r'^https?://.+$', file_or_url): @@ -266,7 +274,15 @@ def run_tha_test(manifest, cache_dir, remote, max_cache_size, min_free_space): directory and runs the executable. """ cache = Cache(cache_dir, remote, max_cache_size, min_free_space) - outdir = tempfile.mkdtemp(prefix='run_tha_test') + + base_temp_dir = None + if not is_same_filesystem(cache_dir, tempfile.gettempdir()): + # Do not use tempdir since it's a separate filesystem than cache_dir. It + # could be tmpfs for example. This would mean copying up to 100mb of data + # there, when a simple tree of hardlinks would do. + base_temp_dir = os.path.dirname(cache_dir) + outdir = tempfile.mkdtemp(prefix='run_tha_test', dir=base_temp_dir) + try: for filepath, properties in manifest['files'].iteritems(): infile = properties['sha-1'] -- cgit v1.1