OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import os |
| 7 import shutil |
| 8 import subprocess |
| 9 import sys |
| 10 import tempfile |
| 11 import unittest |
| 12 |
| 13 from tracing.extras.symbolizer import symbolize_trace |
| 14 |
| 15 _THIS_DIR_PATH = os.path.abspath(os.path.dirname(__file__)) |
| 16 _TRACING_DIR = os.path.abspath( |
| 17 os.path.join(_THIS_DIR_PATH, '..', '..', '..')) |
| 18 _PY_UTILS_PATH = os.path.abspath(os.path.join( |
| 19 _TRACING_DIR, |
| 20 '..', |
| 21 'common', |
| 22 'py_utils')) |
| 23 sys.path.append(_PY_UTILS_PATH) |
| 24 # pylint: disable=import-error |
| 25 import py_utils.cloud_storage as cloud_storage |
| 26 |
| 27 |
| 28 def _DownloadFromCloudStorage(path): |
| 29 print 'Downloading %s from gcs.' % (path) |
| 30 cloud_storage.GetIfChanged(path, cloud_storage.PARTNER_BUCKET) |
| 31 |
| 32 |
| 33 def GetGzipCrc(path): |
| 34 args = 'gzip -v -l ' + path + ' | awk \'{print $2}\' | tail -n 1' |
| 35 p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE) |
| 36 output, _ = p.communicate() |
| 37 return output |
| 38 |
| 39 |
| 40 class SymbolizeTraceEndToEndTest(unittest.TestCase): |
| 41 def testMacv1(self): |
| 42 if sys.platform != 'darwin': |
| 43 return |
| 44 |
| 45 # The corresponding macOS Chrome symbols must be uploaded to |
| 46 # "gs://chrome-partner-telemetry/desktop-symbolizer-test/61.0.3135.4/mac64/" |
| 47 # "Google Chrome.dSYM.tar.bz2" |
| 48 # since the waterfall bots do not have access to the chrome-unsigned bucket. |
| 49 trace_presymbolization_path = os.path.join( |
| 50 _THIS_DIR_PATH, 'data', 'mac_trace_v1_presymbolization.json.gz') |
| 51 _DownloadFromCloudStorage(trace_presymbolization_path) |
| 52 |
| 53 trace_postsymbolization_path = os.path.join( |
| 54 _THIS_DIR_PATH, 'data', 'mac_trace_v1_postsymbolization.json.gz') |
| 55 _DownloadFromCloudStorage(trace_postsymbolization_path) |
| 56 |
| 57 _, temporary_trace = tempfile.mkstemp(suffix='.json.gz') |
| 58 try: |
| 59 shutil.copy(trace_presymbolization_path, temporary_trace) |
| 60 self.assertTrue(symbolize_trace.main(['--only-symbolize-chrome-symbols', |
| 61 '--no-backup', |
| 62 '--cloud-storage-bucket', |
| 63 cloud_storage.PARTNER_BUCKET, |
| 64 temporary_trace])) |
| 65 temporary_trace_crc = GetGzipCrc(temporary_trace) |
| 66 expected_crc = GetGzipCrc(trace_postsymbolization_path) |
| 67 finally: |
| 68 if os.path.exists(temporary_trace): |
| 69 os.remove(temporary_trace) |
| 70 self.assertEquals(temporary_trace_crc, expected_crc) |
| 71 |
| 72 |
| 73 if __name__ == '__main__': |
| 74 unittest.main() |
OLD | NEW |