Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/run_isolated_smoke_test.py

Issue 23380003: Fix run_isolated_smoke_test to work when /tmp is on a separate partition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 import hashlib 6 import hashlib
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import shutil 10 import shutil
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 import tempfile
14 import unittest 13 import unittest
15 14
16 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 15 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 sys.path.insert(0, ROOT_DIR) 16 sys.path.insert(0, ROOT_DIR)
18 17
19 # Imported for the rmtree and get_as_zip_package functions. 18 # Imported for the rmtree and get_as_zip_package functions.
20 import run_isolated 19 import run_isolated
21 20
22 VERBOSE = False 21 VERBOSE = False
23 22
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 f.write(content) 57 f.write(content)
59 58
60 59
61 def write_json(filepath, data): 60 def write_json(filepath, data):
62 with open(filepath, 'wb') as f: 61 with open(filepath, 'wb') as f:
63 json.dump(data, f, sort_keys=True, indent=2) 62 json.dump(data, f, sort_keys=True, indent=2)
64 63
65 64
66 class RunSwarmStep(unittest.TestCase): 65 class RunSwarmStep(unittest.TestCase):
67 def setUp(self): 66 def setUp(self):
68 self.tempdir = tempfile.mkdtemp(prefix='run_isolated_smoke_test') 67 self.tempdir = run_isolated.make_temp_dir(
68 'run_isolated_smoke_test', ROOT_DIR)
69 logging.debug(self.tempdir) 69 logging.debug(self.tempdir)
70 # run_isolated.zip executable package. 70 # run_isolated.zip executable package.
71 self.run_isolated_zip = os.path.join(self.tempdir, 'run_isolated.zip') 71 self.run_isolated_zip = os.path.join(self.tempdir, 'run_isolated.zip')
72 run_isolated.get_as_zip_package().zip_into_file( 72 run_isolated.get_as_zip_package().zip_into_file(
73 self.run_isolated_zip, compress=False) 73 self.run_isolated_zip, compress=False)
74 # The "source" hash table. 74 # The "source" hash table.
75 self.table = os.path.join(self.tempdir, 'table') 75 self.table = os.path.join(self.tempdir, 'table')
76 os.mkdir(self.table) 76 os.mkdir(self.table)
77 # The slave-side cache. 77 # The slave-side cache.
78 self.cache = os.path.join(self.tempdir, 'cache') 78 self.cache = os.path.join(self.tempdir, 'cache')
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if not VERBOSE: 175 if not VERBOSE:
176 self.assertEqual('', err) 176 self.assertEqual('', err)
177 self.assertEqual('Success\n', out, out) 177 self.assertEqual('Success\n', out, out)
178 self.assertEqual(0, returncode) 178 self.assertEqual(0, returncode)
179 actual = list_files_tree(self.cache) 179 actual = list_files_tree(self.cache)
180 self.assertEqual(sorted(set(expected)), actual) 180 self.assertEqual(sorted(set(expected)), actual)
181 181
182 def test_download_isolated(self): 182 def test_download_isolated(self):
183 out_dir = None 183 out_dir = None
184 try: 184 try:
185 out_dir = tempfile.mkdtemp() 185 out_dir = run_isolated.make_temp_dir('run_isolated_smoke_test', ROOT_DIR)
186 186
187 # Store the required files. 187 # Store the required files.
188 self._store('file1.txt') 188 self._store('file1.txt')
189 self._store('repeated_files.py') 189 self._store('repeated_files.py')
190 190
191 # Loads an arbitrary .isolated on the file system. 191 # Loads an arbitrary .isolated on the file system.
192 isolated = os.path.join(self.data_dir, 'download.isolated') 192 isolated = os.path.join(self.data_dir, 'download.isolated')
193 out, err, returncode = self._run( 193 out, err, returncode = self._run(
194 self._generate_args_with_isolated(isolated) + 194 self._generate_args_with_isolated(isolated) +
195 ['--download', out_dir]) 195 ['--download', out_dir])
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 self.assertEqual(0, returncode) 314 self.assertEqual(0, returncode)
315 315
316 self.assertEqual(os.stat(os.path.join(self.data_dir, 'file1.txt')).st_size, 316 self.assertEqual(os.stat(os.path.join(self.data_dir, 'file1.txt')).st_size,
317 os.stat(cached_file_path).st_size) 317 os.stat(cached_file_path).st_size)
318 318
319 319
320 if __name__ == '__main__': 320 if __name__ == '__main__':
321 VERBOSE = '-v' in sys.argv 321 VERBOSE = '-v' in sys.argv
322 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) 322 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
323 unittest.main() 323 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698