OLD | NEW |
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 logging | 6 import logging |
7 import os | 7 import os |
8 import unittest | 8 import unittest |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 ('foo\\001bar\\0', ['foo', 'bar']), | 44 ('foo\\001bar\\0', ['foo', 'bar']), |
45 ('\\"foo\\"\\0', ['"foo"']), | 45 ('\\"foo\\"\\0', ['"foo"']), |
46 ) | 46 ) |
47 for actual, expected in test_cases: | 47 for actual, expected in test_cases: |
48 self.assertEquals( | 48 self.assertEquals( |
49 expected, | 49 expected, |
50 trace_inputs.Dtrace.Context.process_escaped_arguments(actual)) | 50 trace_inputs.Dtrace.Context.process_escaped_arguments(actual)) |
51 | 51 |
52 | 52 |
53 def test_variable_abs(self): | 53 def test_variable_abs(self): |
54 value = trace_inputs.Results.File(None, '/foo/bar', False) | 54 value = trace_inputs.Results.File(None, '/foo/bar', False, False) |
55 actual = value.replace_variables({'$FOO': '/foo'}) | 55 actual = value.replace_variables({'$FOO': '/foo'}) |
56 self.assertEquals('$FOO/bar', actual.path) | 56 self.assertEquals('$FOO/bar', actual.path) |
57 self.assertEquals('$FOO/bar', actual.full_path) | 57 self.assertEquals('$FOO/bar', actual.full_path) |
58 self.assertEquals(True, actual.tainted) | 58 self.assertEquals(True, actual.tainted) |
59 | 59 |
60 def test_variable_rel(self): | 60 def test_variable_rel(self): |
61 value = trace_inputs.Results.File('/usr', 'foo/bar', False) | 61 value = trace_inputs.Results.File('/usr', 'foo/bar', False, False) |
62 actual = value.replace_variables({'$FOO': 'foo'}) | 62 actual = value.replace_variables({'$FOO': 'foo'}) |
63 self.assertEquals('$FOO/bar', actual.path) | 63 self.assertEquals('$FOO/bar', actual.path) |
64 self.assertEquals(os.path.join('/usr', '$FOO/bar'), actual.full_path) | 64 self.assertEquals(os.path.join('/usr', '$FOO/bar'), actual.full_path) |
65 self.assertEquals(True, actual.tainted) | 65 self.assertEquals(True, actual.tainted) |
66 | 66 |
67 def test_native_case_end_with_os_path_sep(self): | 67 def test_native_case_end_with_os_path_sep(self): |
68 # Make sure the trailing os.path.sep is kept. | 68 # Make sure the trailing os.path.sep is kept. |
69 path = trace_inputs.get_native_path_case(ROOT_DIR) + os.path.sep | 69 path = trace_inputs.get_native_path_case(ROOT_DIR) + os.path.sep |
70 self.assertEquals(trace_inputs.get_native_path_case(path), path) | 70 self.assertEquals(trace_inputs.get_native_path_case(path), path) |
71 | 71 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 'size': -1, | 417 'size': -1, |
418 }, | 418 }, |
419 ] | 419 ] |
420 self._test_lines(lines, '/home/foo_bar_user/src', files) | 420 self._test_lines(lines, '/home/foo_bar_user/src', files) |
421 | 421 |
422 | 422 |
423 if __name__ == '__main__': | 423 if __name__ == '__main__': |
424 VERBOSE = '-v' in sys.argv | 424 VERBOSE = '-v' in sys.argv |
425 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 425 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
426 unittest.main() | 426 unittest.main() |
OLD | NEW |