diff --git a/src/viztracer/web_dist/trace_processor b/src/viztracer/web_dist/trace_processor index 50e7fe0f..0ee1e788 100755 --- a/src/viztracer/web_dist/trace_processor +++ b/src/viztracer/web_dist/trace_processor @@ -30,18 +30,18 @@ exec python3 - "$@" <<'#'EOF # ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/trace_processor_shell.py -# This file has been generated by: tools/roll-prebuilts v37.0 +# This file has been generated by: tools/roll-prebuilts v46.0 TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'arch': 'mac-amd64', 'file_name': 'trace_processor_shell', 'file_size': - 9551608, + 9503800, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/mac-amd64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/mac-amd64/trace_processor_shell', 'sha256': - 'f3def324604f551fdf7df088363aebf74de573fdaa02796fd994f1863ad58463', + 'c979a616c2aeada9ff5e0807f15089c7415de7e1f19670945792be5953c05f87', 'platform': 'darwin', 'machine': ['x86_64'] @@ -51,11 +51,11 @@ TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'file_name': 'trace_processor_shell', 'file_size': - 8064168, + 8873912, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/mac-arm64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/mac-arm64/trace_processor_shell', 'sha256': - 'f34a2cfb4f93579452bbaf4f47c9b0fe475394d55316c9626949760c206ec801', + '8f88e9ec002fb0e95bcfdd655e1a9632487010876a234bc545c85c44d0019294', 'platform': 'darwin', 'machine': ['arm64'] @@ -65,11 +65,11 @@ TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'file_name': 'trace_processor_shell', 'file_size': - 9415488, + 9675688, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/linux-amd64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell', 'sha256': - '86d133fc2fe0204693d2b22e9287363cb44bf76794b0091d4d0bb3388b7cd8d5', + '70adf26bc45d6de8327b1e46e98f64d4fe8ccf9fd31a1391bb0916c31aaa9df8', 'platform': 'linux', 'machine': ['x86_64'] @@ -79,11 +79,11 @@ TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'file_name': 'trace_processor_shell', 'file_size': - 6880412, + 7098492, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/linux-arm/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-arm/trace_processor_shell', 'sha256': - '21fd4b2ad68b1f9829cee72d3905b1712cbfa5e169e89b89cdd0a3a4b1682e7d', + 'b9d5abb196a99d1ade08db3d97bff3c71e8ee4ccd6fedb6332effa4d5d50c21d', 'platform': 'linux', 'machine': ['armv6l', 'armv7l', 'armv8l'] @@ -93,11 +93,11 @@ TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'file_name': 'trace_processor_shell', 'file_size': - 8843272, + 9297416, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/linux-arm64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-arm64/trace_processor_shell', 'sha256': - '97a6fb150fd6655f03394d8ad166fd2041a1b4ca56a9e7ce5b35902ff64e1a35', + 'b0495e1ba864f3a315a31353e02f25fe8bcfc993ec6cdae1545f12f33f008c8c', 'platform': 'linux', 'machine': ['aarch64'] @@ -107,55 +107,55 @@ TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'file_name': 'trace_processor_shell', 'file_size': - 6497440, + 7111084, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/android-arm/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/android-arm/trace_processor_shell', 'sha256': - '6018ce36314a75693c5e5c2a69a3aacc9848385bd3ab9121e23de70df5188e1e' + 'd8aa4b6460aca2e166755952fa14010d1f80ddb6b6dc406ca2b5246f9885b153' }, { 'arch': 'android-arm64', 'file_name': 'trace_processor_shell', 'file_size': - 8019768, + 9200536, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/android-arm64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/android-arm64/trace_processor_shell', 'sha256': - '4e36255ebcd5e19fe26def6578cc604d636df9c4fa335ec5901e6cd9aba92ac3' + '1c1843ec2e127b5f7aa8eb9e8d2c216e4cc99f681ecf437ff09f7abc56191cef' }, { 'arch': 'android-x86', 'file_name': 'trace_processor_shell', 'file_size': - 8897636, + 10094664, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/android-x86/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/android-x86/trace_processor_shell', 'sha256': - 'f21573cc77603150e461402c6f032b7ff8f103debcd9d9b2093f521a69f581f7' + '4501c9aa2eaaec62155aac914a35b3c61e9d434e765b20fcefa49b7d01f978f0' }, { 'arch': 'android-x64', 'file_name': 'trace_processor_shell', 'file_size': - 9162616, + 9464288, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/android-x64/trace_processor_shell', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/android-x64/trace_processor_shell', 'sha256': - '2cc5a02270a28db52aa17bfafcf215e3d754a936de595186a7152535ab28531b' + 'fb54ee018ca1d4895ad3e1192e2e585a3709b58864ef3beab4368af3ae17e5fb' }, { 'arch': 'windows-amd64', 'file_name': 'trace_processor_shell.exe', 'file_size': - 8790016, + 9548288, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/windows-amd64/trace_processor_shell.exe', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/windows-amd64/trace_processor_shell.exe', 'sha256': - 'e3193141bcb8bcc35b47c3ee8126d1f3ebe1b54a9ecde59ade9db4f22c6f77d6', + '41a3353caf59d4df14e7d5ba185861fdc8e41776c1720a6fc1eddc6a99afb6c0', 'platform': 'win32', 'machine': ['amd64'] @@ -210,6 +210,7 @@ The intended usage is: import hashlib import os import platform +import random import subprocess import sys @@ -236,9 +237,10 @@ def download_or_get_cached(file_name, url, sha256): if digest == sha256: needs_download = False - if needs_download: - # Either the filed doesn't exist or the SHA256 doesn't match. - tmp_path = bin_path + '.tmp' + if needs_download: # The file doesn't exist or the SHA256 doesn't match. + # Use a unique random file to guard against concurrent executions. + # See https://github.com/google/perfetto/issues/786 . + tmp_path = '%s.%d.tmp' % (bin_path, random.randint(0, 100000)) print('Downloading ' + url) subprocess.check_call(['curl', '-f', '-L', '-#', '-o', tmp_path, url]) with open(tmp_path, 'rb') as fd: @@ -248,8 +250,9 @@ def download_or_get_cached(file_name, url, sha256): (url, actual_sha256, sha256)) os.chmod(tmp_path, 0o755) os.replace(tmp_path, bin_path) - with open(sha256_path, 'w') as f: + with open(tmp_path, 'w') as f: f.write(sha256) + os.replace(tmp_path, sha256_path) return bin_path diff --git a/tests/test_viewer.py b/tests/test_viewer.py index 12b9d88b..9af7acd1 100644 --- a/tests/test_viewer.py +++ b/tests/test_viewer.py @@ -17,6 +17,7 @@ import urllib.request import webbrowser +import viztracer from viztracer.viewer import viewer_main from .cmdline_tmpl import CmdlineTmpl @@ -230,6 +231,23 @@ def test_use_external_processor(self): finally: os.remove(f.name) + def test_external_processor_version(self): + root_path = os.path.dirname(viztracer.__file__) + web_dist_path = os.path.join(root_path, "web_dist") + for path in os.listdir(web_dist_path): + # match the version number in the file name (v47.0-deadbeef) + if (match := re.match(r"v(\d+\.\d+)-[0-9a-f]+$", path)) is not None: + perfetto_version = match.group(1) + with open(os.path.join(web_dist_path, "trace_processor")) as f: + match = re.search(r"tools/roll-prebuilts v(\d+\.\d+)", f.read()) + if match is None: + self.fail("Can't find perfetto version in trace_processor") + processor_version = match.group(1) + # The trace processor version is usually a version before the perfetto version + # So we allow a 1.0 difference + self.assertAlmostEqual(float(perfetto_version), float(processor_version), delta=1.0) + break + @unittest.skipIf(sys.platform == "win32", "Can't send Ctrl+C reliably on Windows") def test_port_in_use_error(self): json_script = '{"file_info": {}, "traceEvents": []}'