From a298fd54c1e59236a1eb37bac6f570c8f2814d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20H=C3=B6glund?= Date: Fri, 27 Mar 2020 14:27:59 +0100 Subject: [PATCH] Don't double import protobuf code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The proto code is copied into the out dir, so always use that since it is what isolate is using. Previously we pointed straight at the checkout code. I think copying python into the out dir is probably the right way to do things, so we should go that way in the future. Bug: chromium:1029452 Change-Id: I701cc84a674021d2f78c73db8808f55cd6ae5174 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171877 Reviewed-by: Mirko Bonadei Commit-Queue: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#30923} --- audio/test/low_bandwidth_audio_test.py | 11 +++++------ test/testsupport/perf_test.h | 9 ++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py index 3973a61965..6a95903373 100755 --- a/audio/test/low_bandwidth_audio_test.py +++ b/audio/test/low_bandwidth_audio_test.py @@ -221,10 +221,10 @@ def _ConfigurePythonPath(args): checkout_root = os.path.abspath( os.path.join(script_dir, os.pardir, os.pardir)) + # TODO(https://crbug.com/1029452): Use a copy rule and add these from the out + # dir like for the third_party/protobuf code. sys.path.insert(0, os.path.join(checkout_root, 'third_party', 'catapult', 'tracing')) - sys.path.insert(0, os.path.join(checkout_root, 'third_party', 'protobuf', - 'python')) # The low_bandwidth_audio_perf_test gn rule will build the protobuf stub for # python, so put it in the path for this script before we attempt to import @@ -232,16 +232,15 @@ def _ConfigurePythonPath(args): histogram_proto_path = os.path.join( os.path.abspath(args.build_dir), 'pyproto', 'tracing', 'tracing', 'proto') sys.path.insert(0, histogram_proto_path) - google_protobuf_path = os.path.join( - os.path.abspath(args.build_dir), 'pyproto') - sys.path.insert(0, google_protobuf_path) + proto_stub_path = os.path.join(os.path.abspath(args.build_dir), 'pyproto') + sys.path.insert(0, proto_stub_path) # Fail early in case the proto hasn't been built. try: import histogram_pb2 except ImportError as e: logging.exception(e) - raise ImportError('Could not find histogram_pb2. You need to build the ' + raise ImportError('Could not import histogram_pb2. You need to build the ' 'low_bandwidth_audio_perf_test target before invoking ' 'this script. Expected to find ' 'histogram_pb2.py in %s.' % histogram_proto_path) diff --git a/test/testsupport/perf_test.h b/test/testsupport/perf_test.h index 58fa0350f2..338a14480d 100644 --- a/test/testsupport/perf_test.h +++ b/test/testsupport/perf_test.h @@ -106,11 +106,14 @@ std::string GetPerfResults(); void PrintPlottableResults(const std::vector& desired_graphs); // Call GetPerfResults() and write its output to a file. Returns false if we -// failed to write to the file. +// failed to write to the file. If you want to print the proto in human readable +// format, use tracing/bin/proto2json from third_party/catapult in your WebRTC +// checkout. bool WritePerfResults(const std::string& output_path); -// By default, perf results are printed to stdout. Set the FILE* to where they -// should be printing instead. +// By default, human-readable perf results are printed to stdout. Set the FILE* +// to where they should be printing instead. These results are not used to +// upload to the dashboard, however - this is only through WritePerfResults. void SetPerfResultsOutput(FILE* output); // Only for use by tests.