From 7b0a30ec9ac7a07bb4b49ce2f5672b0a7c41d788 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Tue, 22 Feb 2022 09:53:41 +0100 Subject: [PATCH] Allow low_bandwith_audio_test.py to pass unknown arg to the test. * The idea is copied from flags_compatibility since this file does a bit the same thing. * Remove extra_test_args which is not used and becomes unecessary. * Fix lint issues. Bug: b/197492097 Change-Id: I378e163a5116ded13619f91ce50859519c9550df Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252004 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36044} --- audio/test/low_bandwidth_audio_test.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py index 051d67fea4..07065e2c8d 100755 --- a/audio/test/low_bandwidth_audio_test.py +++ b/audio/test/low_bandwidth_audio_test.py @@ -67,24 +67,16 @@ def _ParseArgs(): '--isolated-script-test-output', default=None, help='Path to output an empty JSON file which Chromium infra requires.') - parser.add_argument('--extra-test-args', - default=[], - action='append', - help='Extra args to path to the test binary.') - # Ignore Chromium-specific flags - parser.add_argument('--test-launcher-summary-output', type=str, default=None) - args = parser.parse_args() - - return args + return parser.parse_known_args() def _GetPlatform(): if sys.platform == 'win32': return 'win' - elif sys.platform == 'darwin': + if sys.platform == 'darwin': return 'mac' - elif sys.platform.startswith('linux'): + if sys.platform.startswith('linux'): return 'linux' raise AssertionError('Unknown platform %s' % sys.platform) @@ -258,14 +250,13 @@ def _ConfigurePythonPath(args): # Fail early in case the proto hasn't been built. try: - #pylint: disable=unused-variable + #pylint: disable=unused-import import histogram_pb2 except ImportError as e: - logging.exception(e) 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) + 'histogram_pb2.py in %s.' % histogram_proto_path) from e def main(): @@ -274,7 +265,7 @@ def main(): datefmt='%Y-%m-%d %H:%M:%S') logging.info('Invoked with %s', str(sys.argv)) - args = _ParseArgs() + args, extra_test_args = _ParseArgs() _ConfigurePythonPath(args) @@ -309,7 +300,7 @@ def main(): test_process = subprocess.Popen(_LogCommand(test_command + [ '--sample_rate_hz=%d' % analyzer.sample_rate_hz, '--test_case_prefix=%s' % analyzer.name, - ] + args.extra_test_args), + ] + extra_test_args), universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)