diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/libwebrtc/rtc_tools/testing | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/rtc_tools/testing')
9 files changed, 343 insertions, 0 deletions
diff --git a/third_party/libwebrtc/rtc_tools/testing/README.md b/third_party/libwebrtc/rtc_tools/testing/README.md new file mode 100644 index 0000000000..f60c65960a --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/README.md @@ -0,0 +1,44 @@ +This directory contains prebuilt tools used during end-to-end tests. +They will be downloaded by their SHA1 hash, and are not meant to be checked in. + +Updating prebuilt_apprtc.zip: + +- Follow AppRTC instructions: + - `git clone https://github.com/webrtc/apprtc` + - Install NodeJS: + - Download <https://nodejs.org/> and extract it + - `export PATH="$(pwd)/node-v6.10.3-linux-x64/bin:$PATH"` + - `cd apprtc` + - `npm install` + - `export PATH="$(pwd)/node_modules/.bin:$PATH"` + - `pip install --user --upgrade pip setuptools` - needed only on old systems + - `grunt` +- Vendor collider's dependencies: + - `ln -s "$(pwd)/src/collider" src/src` + - `GOPATH="$(pwd)/src" go get -d collidermain` + - `rm src/src` +- Install additional components: + - `python temp/google-cloud-sdk/bin/dev_appserver.py out/app_engine` + - Stop it and run the suggestion: `./temp/google-cloud-sdk/bin/gcloud + components install app-engine-python-extras` +- Remove largest unneeded files: + - `rm -rf .git node_modules browsers + temp/google-cloud-sdk/.install/.{backup,download} + temp/google-cloud-sdk/platform/google_appengine/lib/django-*` +- `zip -r prebuilt_apprtc.zip apprtc/` +- `mv prebuilt_apprtc.zip webrtc/src/rtc_tools/testing/prebuilt_apprtc.zip` + +Updating golang/*: + +- Go to <https://golang.org/dl/> +- Download these files: + - go*.linux-amd64.tar.gz -> golang/linux/go.tar.gz + - go*.darwin-amd64.tar.gz -> golang/mac/go.tar.gz + - go*.windows-amd64.zip -> golang/windows/go.zip + +After updating the archives: + +- `cd webrtc/src/rtc_tools/testing` +- For each updated archive: + - `upload_to_google_storage.py file.zip --bucket=chromium-webrtc-resources` +- `git commit -a && git cl upload` diff --git a/third_party/libwebrtc/rtc_tools/testing/build_apprtc.py b/third_party/libwebrtc/rtc_tools/testing/build_apprtc.py new file mode 100755 index 0000000000..2f680e6ad1 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/build_apprtc.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. +"""Builds the AppRTC collider using the golang toolchain. + +The golang toolchain is downloaded by download_apprtc.py. We use that here +to build the AppRTC collider server. + +This script needs to know the path to the 'src' directory in apprtc, the +root directory of 'go' and the output_dir. +""" + +import fileinput +import os +import shutil +import subprocess +import sys + +import utils + +USAGE_STR = "Usage: {} <apprtc_dir> <go_dir> <output_dir>" + + +def _ConfigureApprtcServerToDeveloperMode(app_yaml_path): + for line in fileinput.input(app_yaml_path, inplace=True): + # We can't click past these in browser-based tests, so disable them. + line = line.replace('BYPASS_JOIN_CONFIRMATION: false', + 'BYPASS_JOIN_CONFIRMATION: true') + sys.stdout.write(line) + + +def main(argv): + if len(argv) != 4: + print(USAGE_STR.format(argv[0])) + + apprtc_dir = os.path.abspath(argv[1]) + go_root_dir = os.path.abspath(argv[2]) + golang_workspace = os.path.abspath(argv[3]) + + app_yaml_path = os.path.join(apprtc_dir, 'out', 'app_engine', 'app.yaml') + _ConfigureApprtcServerToDeveloperMode(app_yaml_path) + + utils.RemoveDirectory(golang_workspace) + + collider_dir = os.path.join(apprtc_dir, 'src', 'collider') + shutil.copytree(collider_dir, os.path.join(golang_workspace, 'src')) + + golang_path = os.path.join(go_root_dir, 'bin', + 'go' + utils.GetExecutableExtension()) + golang_env = os.environ.copy() + golang_env['GOROOT'] = go_root_dir + golang_env['GOPATH'] = golang_workspace + golang_env['GO111MODULE'] = 'off' + collider_out = os.path.join(golang_workspace, + 'collidermain' + utils.GetExecutableExtension()) + subprocess.check_call( + [golang_path, 'build', '-o', collider_out, 'collidermain'], + env=golang_env) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/third_party/libwebrtc/rtc_tools/testing/download_apprtc.py b/third_party/libwebrtc/rtc_tools/testing/download_apprtc.py new file mode 100755 index 0000000000..a77955a3f6 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/download_apprtc.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. +"""Downloads prebuilt AppRTC and Go from WebRTC storage and unpacks it. + +Requires that depot_tools is installed and in the PATH. + +It downloads compressed files in the directory where the script lives. +This is because the precondition is that the script lives in the same +directory of the .sha1 files. +""" + +import os +import sys + +import utils + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + + +def _GetGoArchivePathForPlatform(): + archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz' + return os.path.join(utils.GetPlatform(), 'go.%s' % archive_extension) + + +def main(argv): + if len(argv) > 2: + return 'Usage: %s [output_dir]' % argv[0] + + output_dir = os.path.abspath(argv[1]) if len(argv) > 1 else None + + apprtc_zip_path = os.path.join(SCRIPT_DIR, 'prebuilt_apprtc.zip') + if os.path.isfile(apprtc_zip_path + '.sha1'): + utils.DownloadFilesFromGoogleStorage(SCRIPT_DIR, auto_platform=False) + + if output_dir is not None: + utils.RemoveDirectory(os.path.join(output_dir, 'apprtc')) + utils.UnpackArchiveTo(apprtc_zip_path, output_dir) + + golang_path = os.path.join(SCRIPT_DIR, 'golang') + golang_zip_path = os.path.join(golang_path, _GetGoArchivePathForPlatform()) + if os.path.isfile(golang_zip_path + '.sha1'): + utils.DownloadFilesFromGoogleStorage(golang_path) + + if output_dir is not None: + utils.RemoveDirectory(os.path.join(output_dir, 'go')) + utils.UnpackArchiveTo(golang_zip_path, output_dir) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/third_party/libwebrtc/rtc_tools/testing/golang/linux/go.tar.gz.sha1 b/third_party/libwebrtc/rtc_tools/testing/golang/linux/go.tar.gz.sha1 new file mode 100644 index 0000000000..aa2509557d --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/golang/linux/go.tar.gz.sha1 @@ -0,0 +1 @@ +a433f76c569055ff8536d796995518dd91a9fa5b
\ No newline at end of file diff --git a/third_party/libwebrtc/rtc_tools/testing/golang/mac/go.tar.gz.sha1 b/third_party/libwebrtc/rtc_tools/testing/golang/mac/go.tar.gz.sha1 new file mode 100644 index 0000000000..399edd5cd8 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/golang/mac/go.tar.gz.sha1 @@ -0,0 +1 @@ +e13521f5d61465fe873371b266bc3ceafcb13562
\ No newline at end of file diff --git a/third_party/libwebrtc/rtc_tools/testing/golang/win/go.zip.sha1 b/third_party/libwebrtc/rtc_tools/testing/golang/win/go.zip.sha1 new file mode 100644 index 0000000000..00fae8de9a --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/golang/win/go.zip.sha1 @@ -0,0 +1 @@ +26bf854fb81f12e9c80a146d8f0081cd22ae9d02
\ No newline at end of file diff --git a/third_party/libwebrtc/rtc_tools/testing/prebuilt_apprtc.zip.sha1 b/third_party/libwebrtc/rtc_tools/testing/prebuilt_apprtc.zip.sha1 new file mode 100644 index 0000000000..55fda33d81 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/prebuilt_apprtc.zip.sha1 @@ -0,0 +1 @@ +4a1853f16014b64446d9792088c1088abbe11083
\ No newline at end of file diff --git a/third_party/libwebrtc/rtc_tools/testing/setup_apprtc.py b/third_party/libwebrtc/rtc_tools/testing/setup_apprtc.py new file mode 100755 index 0000000000..387ba694a3 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/setup_apprtc.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. +"""This script sets up AppRTC and its dependencies. + +Requires that depot_tools is installed and in the PATH. + +It will put the result under <output_dir>/collider. +""" + +import os +import sys + +import utils + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + + +def main(argv): + if len(argv) == 1: + return 'Usage %s <output_dir>' % argv[0] + + output_dir = os.path.abspath(argv[1]) + + download_apprtc_path = os.path.join(SCRIPT_DIR, 'download_apprtc.py') + utils.RunSubprocessWithRetry( + [sys.executable, download_apprtc_path, output_dir]) + + build_apprtc_path = os.path.join(SCRIPT_DIR, 'build_apprtc.py') + apprtc_dir = os.path.join(output_dir, 'apprtc') + go_dir = os.path.join(output_dir, 'go') + collider_dir = os.path.join(output_dir, 'collider') + utils.RunSubprocessWithRetry( + [sys.executable, build_apprtc_path, apprtc_dir, go_dir, collider_dir]) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/third_party/libwebrtc/rtc_tools/testing/utils.py b/third_party/libwebrtc/rtc_tools/testing/utils.py new file mode 100755 index 0000000000..8a5de50cf8 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/testing/utils.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. +"""Utilities for all our deps-management stuff.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +import shutil +import subprocess +import sys +import tarfile +import time +import zipfile + + +def RunSubprocessWithRetry(cmd): + """Invokes the subprocess and backs off exponentially on fail.""" + for i in range(5): + try: + subprocess.check_call(cmd) + return + except subprocess.CalledProcessError as exception: + backoff = pow(2, i) + print('Got %s, retrying in %d seconds...' % (exception, backoff)) + time.sleep(backoff) + + print('Giving up.') + raise exception + + +def DownloadFilesFromGoogleStorage(path, auto_platform=True): + print('Downloading files in %s...' % path) + + extension = 'bat' if 'win32' in sys.platform else 'py' + cmd = [ + 'download_from_google_storage.%s' % extension, + '--bucket=chromium-webrtc-resources', '--directory', path + ] + if auto_platform: + cmd += ['--auto_platform', '--recursive'] + subprocess.check_call(cmd) + + +# Code partially copied from +# https://cs.chromium.org#chromium/build/scripts/common/chromium_utils.py +def RemoveDirectory(*path): + """Recursively removes a directory, even if it's marked read-only. + + Remove the directory located at *path, if it exists. + + shutil.rmtree() doesn't work on Windows if any of the files or directories + are read-only, which svn repositories and some .svn files are. We need to + be able to force the files to be writable (i.e., deletable) as we traverse + the tree. + + Even with all this, Windows still sometimes fails to delete a file, citing + a permission error (maybe something to do with antivirus scans or disk + indexing). The best suggestion any of the user forums had was to wait a + bit and try again, so we do that too. It's hand-waving, but sometimes it + works. :/ + """ + file_path = os.path.join(*path) + print('Deleting `{}`.'.format(file_path)) + if not os.path.exists(file_path): + print('`{}` does not exist.'.format(file_path)) + return + + if sys.platform == 'win32': + # Give up and use cmd.exe's rd command. + file_path = os.path.normcase(file_path) + for _ in range(3): + print('RemoveDirectory running %s' % + (' '.join(['cmd.exe', '/c', 'rd', '/q', '/s', file_path]))) + if not subprocess.call( + ['cmd.exe', '/c', 'rd', '/q', '/s', file_path]): + break + print(' Failed') + time.sleep(3) + return + else: + shutil.rmtree(file_path, ignore_errors=True) + + +def UnpackArchiveTo(archive_path, output_dir): + extension = os.path.splitext(archive_path)[1] + if extension == '.zip': + _UnzipArchiveTo(archive_path, output_dir) + else: + _UntarArchiveTo(archive_path, output_dir) + + +def _UnzipArchiveTo(archive_path, output_dir): + print('Unzipping {} in {}.'.format(archive_path, output_dir)) + zip_file = zipfile.ZipFile(archive_path) + try: + zip_file.extractall(output_dir) + finally: + zip_file.close() + + +def _UntarArchiveTo(archive_path, output_dir): + print('Untarring {} in {}.'.format(archive_path, output_dir)) + tar_file = tarfile.open(archive_path, 'r:gz') + try: + tar_file.extractall(output_dir) + finally: + tar_file.close() + + +def GetPlatform(): + if sys.platform.startswith('win'): + return 'win' + if sys.platform.startswith('linux'): + return 'linux' + if sys.platform.startswith('darwin'): + return 'mac' + raise Exception("Can't run on platform %s." % sys.platform) + + +def GetExecutableExtension(): + return '.exe' if GetPlatform() == 'win' else '' |