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 <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#36044}
This commit is contained in:
Jeremy Leconte 2022-02-22 09:53:41 +01:00 committed by WebRTC LUCI CQ
parent c8f0502f0f
commit 7b0a30ec9a

View File

@ -67,24 +67,16 @@ def _ParseArgs():
'--isolated-script-test-output', '--isolated-script-test-output',
default=None, default=None,
help='Path to output an empty JSON file which Chromium infra requires.') 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 return parser.parse_known_args()
parser.add_argument('--test-launcher-summary-output', type=str, default=None)
args = parser.parse_args()
return args
def _GetPlatform(): def _GetPlatform():
if sys.platform == 'win32': if sys.platform == 'win32':
return 'win' return 'win'
elif sys.platform == 'darwin': if sys.platform == 'darwin':
return 'mac' return 'mac'
elif sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
return 'linux' return 'linux'
raise AssertionError('Unknown platform %s' % sys.platform) raise AssertionError('Unknown platform %s' % sys.platform)
@ -258,14 +250,13 @@ def _ConfigurePythonPath(args):
# Fail early in case the proto hasn't been built. # Fail early in case the proto hasn't been built.
try: try:
#pylint: disable=unused-variable #pylint: disable=unused-import
import histogram_pb2 import histogram_pb2
except ImportError as e: except ImportError as e:
logging.exception(e)
raise ImportError('Could not import 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 ' 'low_bandwidth_audio_perf_test target before invoking '
'this script. Expected to find ' '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(): def main():
@ -274,7 +265,7 @@ def main():
datefmt='%Y-%m-%d %H:%M:%S') datefmt='%Y-%m-%d %H:%M:%S')
logging.info('Invoked with %s', str(sys.argv)) logging.info('Invoked with %s', str(sys.argv))
args = _ParseArgs() args, extra_test_args = _ParseArgs()
_ConfigurePythonPath(args) _ConfigurePythonPath(args)
@ -309,7 +300,7 @@ def main():
test_process = subprocess.Popen(_LogCommand(test_command + [ test_process = subprocess.Popen(_LogCommand(test_command + [
'--sample_rate_hz=%d' % analyzer.sample_rate_hz, '--sample_rate_hz=%d' % analyzer.sample_rate_hz,
'--test_case_prefix=%s' % analyzer.name, '--test_case_prefix=%s' % analyzer.name,
] + args.extra_test_args), ] + extra_test_args),
universal_newlines=True, universal_newlines=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)