diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-27 14:07:04 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-27 14:07:04 +0000 |
commit | 20884a9443f6bc3bbe7dca820729e6eb6f8c50bf (patch) | |
tree | 3ac98c0b29f809e4a3b50378518d556a134da1c1 | |
parent | 46537b9965921d79d1c866e9bfb0e07ccf8bff32 (diff) | |
download | chromium_src-20884a9443f6bc3bbe7dca820729e6eb6f8c50bf.zip chromium_src-20884a9443f6bc3bbe7dca820729e6eb6f8c50bf.tar.gz chromium_src-20884a9443f6bc3bbe7dca820729e6eb6f8c50bf.tar.bz2 |
Add symlink smoke test to trace_inputs.py.
This is to ensure correctness when adding symlink support to isolate.py
R=cmp@chromium.org
NOTRY=true
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10657049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144454 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | tools/isolate/data/trace_inputs/symlink.py | 37 | ||||
-rwxr-xr-x | tools/isolate/trace_inputs_smoke_test.py | 44 |
2 files changed, 81 insertions, 0 deletions
diff --git a/tools/isolate/data/trace_inputs/symlink.py b/tools/isolate/data/trace_inputs/symlink.py new file mode 100755 index 0000000..f7c7af4 --- /dev/null +++ b/tools/isolate/data/trace_inputs/symlink.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys + + +def main(): + print 'symlink: touches files2/' + assert len(sys.argv) == 1 + + expected = { + 'bar': 'Foo\n', + 'foo': 'Bar\n', + } + + if not os.path.basename(os.getcwd()) == 'data': + print 'Start this script from inside "data"' + return 1 + + root = os.path.join('trace_inputs', 'files2') + actual = dict( + (filename, open(os.path.join(root, filename), 'rb').read()) + for filename in (os.listdir(root))) + + if actual != expected: + print 'Failure' + print actual + print expected + return 2 + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/isolate/trace_inputs_smoke_test.py b/tools/isolate/trace_inputs_smoke_test.py index b97adb6..cbd2af4 100755 --- a/tools/isolate/trace_inputs_smoke_test.py +++ b/tools/isolate/trace_inputs_smoke_test.py @@ -507,6 +507,50 @@ class TraceInputsImport(TraceInputsBase): self.assertTrue(actual['root']['children'][0].pop('pid')) self.assertEquals(expected_results[index], actual) + def test_trace_symlink(self): + expected = { + 'root': { + 'children': [], + 'command': [ + self.executable, + os.path.join('trace_inputs', 'symlink.py'), + ], + 'executable': self.real_executable, + 'files': [ + { + 'path': os.path.join(u'data', 'trace_inputs', 'files2', 'bar'), + 'size': self._size('data', 'trace_inputs', 'files2', 'bar'), + }, + { + 'path': os.path.join(u'data', 'trace_inputs', 'files2', 'foo'), + 'size': self._size('data', 'trace_inputs', 'files2', 'foo'), + }, + { + 'path': os.path.join(u'data', 'trace_inputs', 'symlink.py'), + 'size': self._size('data', 'trace_inputs', 'symlink.py'), + }, + ], + 'initial_cwd': self.initial_cwd, + }, + } + cmd = [sys.executable, os.path.join('trace_inputs', 'symlink.py')] + results = self._execute(cmd) + actual = results.flatten() + self.maxDiff = None + self.assertTrue(actual['root'].pop('pid')) + self.assertEquals(expected, actual) + files = [ + # In particular, the symlink is *not* resolved. + u'data/trace_inputs/files2/'.replace('/', os.path.sep), + u'data/trace_inputs/symlink.py'.replace('/', os.path.sep), + ] + def blacklist(f): + return f.endswith(('.pyc', '.svn', 'do_not_care.txt')) + simplified = self.trace_inputs.extract_directories( + ROOT_DIR, results.files, blacklist) + self.assertEquals(files, [f.path for f in simplified]) + + if __name__ == '__main__': VERBOSE = '-v' in sys.argv logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |