Add num-retries flag to Android perf tests.

Add a flag to Android perf tests, so we can specify the number of
retries.

Bug: chromium:755660
Change-Id: Ic498373421b7e0fdf779a4659a0c79d47a59fbde
Reviewed-on: https://webrtc-review.googlesource.com/61103
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22390}
diff --git a/examples/androidtests/video_quality_loopback_test.py b/examples/androidtests/video_quality_loopback_test.py
index ce10ee6..66a981b 100755
--- a/examples/androidtests/video_quality_loopback_test.py
+++ b/examples/androidtests/video_quality_loopback_test.py
@@ -86,6 +86,8 @@
   parser.add_argument('--temp_dir',
       help='A temporary directory to put the output.')
   parser.add_argument('--adb-path', help='Path to adb binary.', default='adb')
+  parser.add_argument('--num-retries', default=0,
+                      help='Number of times to retry the test on Android.')
   parser.add_argument('--isolated-script-test-perf-output',
       help='Where to store perf results in chartjson format.', default=None)
 
@@ -160,7 +162,7 @@
       '8089']))
 
 
-def RunTest(android_device, adb_path, build_dir, temp_dir,
+def RunTest(android_device, adb_path, build_dir, temp_dir, num_retries,
             chartjson_result_file):
   ffmpeg_path = os.path.join(TOOLCHAIN_DIR, 'ffmpeg')
   def ConvertVideo(input_video, output_video):
@@ -169,7 +171,8 @@
   # Start loopback call and record video.
   test_script = os.path.join(
       build_dir, 'bin', 'run_AppRTCMobileTestStubbedVideoIO')
-  _RunCommand([test_script, '--device', android_device])
+  _RunCommand([test_script, '--device', android_device,
+               '--num-retries', num_retries])
 
   # Pull the recorded video.
   test_video = os.path.join(temp_dir, 'test_video.y4m')
@@ -225,7 +228,7 @@
   try:
     android_device = SelectAndroidDevice(adb_path)
     SetUpTools(android_device, temp_dir, processes)
-    RunTest(android_device, adb_path, build_dir, temp_dir,
+    RunTest(android_device, adb_path, build_dir, temp_dir, args.num_retries,
             args.isolated_script_test_perf_output)
   finally:
     for process in processes: