Update testing tools (AppRTC, Go) to new versions
App engine is included in the AppRTC archive, so the separate archive is not needed anymore.
Mercurial is no longer necessary to include but it will be required during the vendoring step when the prebuilt archives are update.
The download/build scripts have been simplified accordingly.
The video quality test has been updated to work with the new appengine.
BUG=webrtc:7602
Review-Url: https://codereview.webrtc.org/2882073003
Cr-Commit-Position: refs/heads/master@{#18162}
diff --git a/webrtc/examples/androidtests/video_quality_loopback_test.py b/webrtc/examples/androidtests/video_quality_loopback_test.py
index 2500057..e8c4381 100755
--- a/webrtc/examples/androidtests/video_quality_loopback_test.py
+++ b/webrtc/examples/androidtests/video_quality_loopback_test.py
@@ -19,7 +19,6 @@
"""
import argparse
-import atexit
import logging
import os
import shutil
@@ -32,13 +31,6 @@
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir,
os.pardir))
-WEBRTC_DEPS_INSTRUCTIONS = """Please add a solution to your .gclient file like
-this and run gclient sync:
-{
- "name": "webrtc.DEPS",
- "url": "https://chromium.googlesource.com/chromium/deps/webrtc/webrtc.DEPS",
-},
-"""
class Error(Exception):
@@ -62,7 +54,6 @@
def _RunBackgroundCommand(argv, cwd=SRC_DIR):
logging.info('Running %r', argv)
process = subprocess.Popen(argv, cwd=cwd)
- atexit.register(process.terminate)
time.sleep(0.5)
status = process.poll()
if status: # is not None or 0
@@ -108,8 +99,14 @@
toolchain_dir = os.path.join(tools_dir, 'video_quality_toolchain')
# Download ffmpeg and zxing.
- download_script = os.path.join(tools_dir, 'download_tools.py')
- _RunCommand([sys.executable, download_script, toolchain_dir])
+ download_tools_script = os.path.join(tools_dir, 'download_tools.py')
+ _RunCommand([sys.executable, download_tools_script, toolchain_dir])
+
+ testing_tools_dir = os.path.join(SRC_DIR, 'webrtc', 'tools', 'testing')
+
+ # Download, extract and build AppRTC.
+ setup_apprtc_script = os.path.join(testing_tools_dir, 'setup_apprtc.py')
+ _RunCommand([sys.executable, setup_apprtc_script, temp_dir])
# Select an Android device in case multiple are connected
for line in _RunCommandWithOutput([adb_path, 'devices']).splitlines():
@@ -119,82 +116,88 @@
else:
raise VideoQualityTestError('Cannot find any connected Android device.')
- # Start AppRTC Server
- dev_appserver = os.path.join(SRC_DIR, 'out', 'apprtc', 'google_appengine',
- 'dev_appserver.py')
- if not os.path.isfile(dev_appserver):
- raise VideoQualityTestError('Cannot find %s.\n%s' %
- (dev_appserver, WEBRTC_DEPS_INSTRUCTIONS))
- appengine_dir = os.path.join(SRC_DIR, 'out', 'apprtc', 'out', 'app_engine')
- _RunBackgroundCommand(['python', dev_appserver, appengine_dir,
- '--port=9999', '--admin_port=9998',
- '--skip_sdk_update_check', '--clear_datastore=yes'])
+ processes = []
+ try:
+ # Start AppRTC Server
+ dev_appserver = os.path.join(temp_dir, 'apprtc', 'temp', 'google-cloud-sdk',
+ 'bin', 'dev_appserver.py')
+ appengine_dir = os.path.join(temp_dir, 'apprtc', 'out', 'app_engine')
+ processes.append(_RunBackgroundCommand([
+ 'python', dev_appserver, appengine_dir,
+ '--port=9999', '--admin_port=9998',
+ '--skip_sdk_update_check', '--clear_datastore=yes']))
- # Start Collider
- collider_path = os.path.join(SRC_DIR, 'out', 'go-workspace', 'bin',
- 'collidermain')
- if not os.path.isfile(collider_path):
- raise VideoQualityTestError('Cannot find %s.\n%s' %
- (collider_path, WEBRTC_DEPS_INSTRUCTIONS))
- _RunBackgroundCommand([collider_path, '-tls=false',
- '-port=8089', '-room-server=http://localhost:9999'])
+ # Start Collider
+ collider_path = os.path.join(temp_dir, 'collider', 'collidermain')
+ processes.append(_RunBackgroundCommand([
+ collider_path, '-tls=false', '-port=8089',
+ '-room-server=http://localhost:9999']))
- # Start adb reverse forwarder
- reverseforwarder_path = os.path.join(
- SRC_DIR, 'build', 'android', 'adb_reverse_forwarder.py')
- _RunBackgroundCommand([reverseforwarder_path, '--device', android_device,
- '9999', '9999', '8089', '8089'])
+ # Start adb reverse forwarder
+ reverseforwarder_path = os.path.join(
+ SRC_DIR, 'build', 'android', 'adb_reverse_forwarder.py')
+ processes.append(_RunBackgroundCommand([
+ reverseforwarder_path, '--device', android_device,
+ '9999', '9999', '8089', '8089']))
- # Run the Espresso code.
- test_script = os.path.join(build_dir_android,
- 'bin', 'run_AppRTCMobileTestStubbedVideoIO')
- _RunCommand([test_script, '--device', android_device])
+ # Run the Espresso code.
+ test_script = os.path.join(build_dir_android,
+ 'bin', 'run_AppRTCMobileTestStubbedVideoIO')
+ _RunCommand([test_script, '--device', android_device])
- # Pull the output video.
- test_video = os.path.join(temp_dir, 'test_video.y4m')
- _RunCommand([adb_path, '-s', android_device,
- 'pull', '/sdcard/output.y4m', test_video])
+ # Pull the output video.
+ test_video = os.path.join(temp_dir, 'test_video.y4m')
+ _RunCommand([adb_path, '-s', android_device,
+ 'pull', '/sdcard/output.y4m', test_video])
- test_video_yuv = os.path.join(temp_dir, 'test_video.yuv')
+ test_video_yuv = os.path.join(temp_dir, 'test_video.yuv')
- ffmpeg_path = os.path.join(toolchain_dir, 'linux', 'ffmpeg')
+ ffmpeg_path = os.path.join(toolchain_dir, 'linux', 'ffmpeg')
- def ConvertVideo(input_video, output_video):
- _RunCommand([ffmpeg_path, '-y', '-i', input_video, output_video])
+ def ConvertVideo(input_video, output_video):
+ _RunCommand([ffmpeg_path, '-y', '-i', input_video, output_video])
- ConvertVideo(test_video, test_video_yuv)
+ ConvertVideo(test_video, test_video_yuv)
- reference_video = os.path.join(SRC_DIR,
- 'resources', 'reference_video_640x360_30fps.y4m')
+ reference_video = os.path.join(SRC_DIR,
+ 'resources', 'reference_video_640x360_30fps.y4m')
- reference_video_yuv = os.path.join(temp_dir,
- 'reference_video_640x360_30fps.yuv')
+ reference_video_yuv = os.path.join(temp_dir,
+ 'reference_video_640x360_30fps.yuv')
- ConvertVideo(reference_video, reference_video_yuv)
+ ConvertVideo(reference_video, reference_video_yuv)
- # Run compare script.
- compare_script = os.path.join(SRC_DIR, 'webrtc', 'tools', 'compare_videos.py')
- zxing_path = os.path.join(toolchain_dir, 'linux', 'zxing')
+ # Run compare script.
+ compare_script = os.path.join(SRC_DIR, 'webrtc', 'tools',
+ 'compare_videos.py')
+ zxing_path = os.path.join(toolchain_dir, 'linux', 'zxing')
- # The frame_analyzer binary should be built for local computer and not for
- # Android
- frame_analyzer = os.path.join(build_dir_x86, 'frame_analyzer')
+ # The frame_analyzer binary should be built for local computer and not for
+ # Android
+ frame_analyzer = os.path.join(build_dir_x86, 'frame_analyzer')
- frame_width = 640
- frame_height = 360
+ frame_width = 640
+ frame_height = 360
- stats_file_ref = os.path.join(temp_dir, 'stats_ref.txt')
- stats_file_test = os.path.join(temp_dir, 'stats_test.txt')
+ stats_file_ref = os.path.join(temp_dir, 'stats_ref.txt')
+ stats_file_test = os.path.join(temp_dir, 'stats_test.txt')
- _RunCommand([
- sys.executable, compare_script, '--ref_video', reference_video_yuv,
- '--test_video', test_video_yuv, '--yuv_frame_width', str(frame_width),
- '--yuv_frame_height', str(frame_height),
- '--stats_file_ref', stats_file_ref,
- '--stats_file_test', stats_file_test, '--frame_analyzer', frame_analyzer,
- '--ffmpeg_path', ffmpeg_path, '--zxing_path', zxing_path])
+ _RunCommand([
+ sys.executable, compare_script, '--ref_video', reference_video_yuv,
+ '--test_video', test_video_yuv, '--yuv_frame_width', str(frame_width),
+ '--yuv_frame_height', str(frame_height),
+ '--stats_file_ref', stats_file_ref,
+ '--stats_file_test', stats_file_test,
+ '--frame_analyzer', frame_analyzer,
+ '--ffmpeg_path', ffmpeg_path, '--zxing_path', zxing_path])
- shutil.rmtree(temp_dir)
+ finally:
+ for process in processes:
+ if process:
+ process.terminate()
+ process.wait()
+
+ shutil.rmtree(temp_dir)
if __name__ == '__main__':