1#!/usr/bin/env vpython3 2# Copyright 2024 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6""" 7A wrapper script for //third_party/perfetto/tools/test_data. The wrapper 8ensures that we upload the correct directory. 9 10Usage: 11./test_data.py status # Prints the status of new & modified files. 12./test_data.py download # To sync remote>local (used by gclient runhooks). 13./test_data.py upload # To upload newly created and modified files. 14 15WARNING: the `download` command will overwrite any locally modified files. 16If you want to keep locally modified test data, you should upload it before 17running `gclient runhooks` otherwise you will lose this data. 18""" 19 20import argparse 21import os 22import subprocess 23import sys 24 25def main(): 26 parser = argparse.ArgumentParser() 27 parser.add_argument('cmd', choices=['status', 'download', 'upload']) 28 parser.add_argument('--verbose', '-v', action='store_true') 29 args = parser.parse_args() 30 31 src_root = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) 32 perfetto_dir = os.path.join(src_root, 'third_party', 'perfetto') 33 tool = os.path.join(perfetto_dir, "tools", "test_data") 34 test_dir = os.path.join(src_root, 'base', 'tracing', 'test', 'data') 35 36 command = ['vpython3', tool, '--dir', test_dir, '--overwrite', args.cmd] 37 if args.verbose: 38 command.append('--verbose') 39 40 completed_process = subprocess.run( 41 command, 42 check=False, 43 capture_output=True) 44 sys.stderr.buffer.write(completed_process.stderr) 45 sys.stdout.buffer.write(completed_process.stdout) 46 47if __name__ == '__main__': 48 sys.exit(main())