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