Remove ensure_webcam_is_running.py script.
Change-Id: I9e4e35f3e8b3010cbec7b6a6ed2b948072702d66 Bug: b/312914606 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350564 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42332}
This commit is contained in:
parent
4b8cfc4f13
commit
ef4d62e8d5
@ -52,6 +52,8 @@ PYLINT_OLD_STYLE = [
|
|||||||
"tools_webrtc/autoroller/roll_deps.py",
|
"tools_webrtc/autoroller/roll_deps.py",
|
||||||
"tools_webrtc/android/build_aar.py",
|
"tools_webrtc/android/build_aar.py",
|
||||||
"tools_webrtc/ios/build_ios_libs.py",
|
"tools_webrtc/ios/build_ios_libs.py",
|
||||||
|
"tools_webrtc/mb/mb.py",
|
||||||
|
"tools_webrtc/mb/mb_unittest.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
# These filters will always be removed, even if the caller specifies a filter
|
# These filters will always be removed, even if the caller specifies a filter
|
||||||
|
|||||||
@ -126,9 +126,7 @@
|
|||||||
},
|
},
|
||||||
"video_capture_tests": {
|
"video_capture_tests": {
|
||||||
"label": "//modules/video_capture:video_capture_tests",
|
"label": "//modules/video_capture:video_capture_tests",
|
||||||
"type": "non_parallel_console_test_launcher",
|
"type": "console_test_launcher",
|
||||||
# TODO(bugs.webrtc.org/9292): remove use_webcam and the ensure script.
|
|
||||||
"use_webcam": True,
|
|
||||||
},
|
},
|
||||||
"video_codec_perf_tests": {
|
"video_codec_perf_tests": {
|
||||||
"label": "//modules/video_coding:video_codec_perf_tests",
|
"label": "//modules/video_coding:video_codec_perf_tests",
|
||||||
|
|||||||
@ -1,103 +0,0 @@
|
|||||||
#!/usr/bin/env vpython3
|
|
||||||
|
|
||||||
# Copyright (c) 2014 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.
|
|
||||||
"""Checks if a virtual webcam is running and starts it if not.
|
|
||||||
|
|
||||||
Returns a non-zero return code if the webcam could not be started.
|
|
||||||
|
|
||||||
Prerequisites:
|
|
||||||
* The Python interpreter must have the psutil package installed.
|
|
||||||
* Windows: a scheduled task named 'ManyCam' must exist and be configured to
|
|
||||||
launch ManyCam preconfigured to auto-play the test clip.
|
|
||||||
* Mac: ManyCam must be installed in the default location and be preconfigured
|
|
||||||
to auto-play the test clip.
|
|
||||||
* Linux: Not implemented
|
|
||||||
|
|
||||||
NOTICE: When running this script as a buildbot step, make sure to set
|
|
||||||
usePTY=False for the build step when adding it, or the subprocess will die as
|
|
||||||
soon the step has executed.
|
|
||||||
|
|
||||||
If any command line arguments are passed to the script, it is executed as a
|
|
||||||
command in a subprocess.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
# psutil is not installed on non-Linux machines by default.
|
|
||||||
import psutil # pylint: disable=F0401
|
|
||||||
|
|
||||||
WEBCAM_WIN = ('schtasks', '/run', '/tn', 'ManyCam')
|
|
||||||
WEBCAM_MAC = ('open', '/Applications/ManyCam/ManyCam.app')
|
|
||||||
|
|
||||||
|
|
||||||
def IsWebCamRunning():
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
process_name = 'ManyCam.exe'
|
|
||||||
elif sys.platform.startswith('darwin'):
|
|
||||||
process_name = 'ManyCam'
|
|
||||||
elif sys.platform.startswith('linux'):
|
|
||||||
# TODO(bugs.webrtc.org/9636): Currently a no-op on Linux: sw webcams no
|
|
||||||
# longer in use.
|
|
||||||
print('Virtual webcam: no-op on Linux')
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
raise Exception('Unsupported platform: %s' % sys.platform)
|
|
||||||
for p in psutil.process_iter():
|
|
||||||
try:
|
|
||||||
if process_name == p.name:
|
|
||||||
print('Found a running virtual webcam (%s with PID %s)' %
|
|
||||||
(p.name, p.pid))
|
|
||||||
return True
|
|
||||||
except psutil.AccessDenied:
|
|
||||||
pass # This is normal if we query sys processes, etc.
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def StartWebCam():
|
|
||||||
try:
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
subprocess.check_call(WEBCAM_WIN)
|
|
||||||
print('Successfully launched virtual webcam.')
|
|
||||||
elif sys.platform.startswith('darwin'):
|
|
||||||
subprocess.check_call(WEBCAM_MAC)
|
|
||||||
print('Successfully launched virtual webcam.')
|
|
||||||
elif sys.platform.startswith('linux'):
|
|
||||||
# TODO(bugs.webrtc.org/9636): Currently a no-op on Linux: sw webcams no
|
|
||||||
# longer in use.
|
|
||||||
print('Not implemented on Linux')
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print('Failed to launch virtual webcam: %s' % e)
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _ForcePythonInterpreter(cmd):
|
|
||||||
"""Returns the fixed command line to call the right python executable."""
|
|
||||||
out = cmd[:]
|
|
||||||
if out[0] == 'vpython3':
|
|
||||||
out[0] = sys.executable
|
|
||||||
elif out[0].endswith('.py'):
|
|
||||||
out.insert(0, sys.executable)
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
def Main(argv):
|
|
||||||
if not IsWebCamRunning():
|
|
||||||
if not StartWebCam():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
if argv:
|
|
||||||
return subprocess.call(_ForcePythonInterpreter(argv))
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(Main(sys.argv[1:]))
|
|
||||||
@ -25,132 +25,133 @@ from tools.mb import mb
|
|||||||
|
|
||||||
|
|
||||||
def _GetExecutable(target, platform):
|
def _GetExecutable(target, platform):
|
||||||
executable_prefix = '.\\' if platform == 'win32' else './'
|
executable_prefix = '.\\' if platform == 'win32' else './'
|
||||||
executable_suffix = '.exe' if platform == 'win32' else ''
|
executable_suffix = '.exe' if platform == 'win32' else ''
|
||||||
return executable_prefix + target + executable_suffix
|
return executable_prefix + target + executable_suffix
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
mbw = WebRTCMetaBuildWrapper()
|
mbw = WebRTCMetaBuildWrapper()
|
||||||
return mbw.Main(args)
|
return mbw.Main(args)
|
||||||
|
|
||||||
|
|
||||||
class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
# Make sure default_config and default_isolate_map are attributes of the
|
|
||||||
# parent class before changing their values.
|
|
||||||
# pylint: disable=access-member-before-definition
|
|
||||||
assert self.default_config
|
|
||||||
assert self.default_isolate_map
|
|
||||||
self.default_config = os.path.join(_SCRIPT_DIR, 'mb_config.pyl')
|
|
||||||
self.default_isolate_map = os.path.join(_SRC_DIR, 'infra', 'specs',
|
|
||||||
'gn_isolate_map.pyl')
|
|
||||||
|
|
||||||
def GetSwarmingCommand(self, target, vals):
|
def __init__(self):
|
||||||
isolate_map = self.ReadIsolateMap()
|
super().__init__()
|
||||||
test_type = isolate_map[target]['type']
|
# Make sure default_config and default_isolate_map are attributes of the
|
||||||
|
# parent class before changing their values.
|
||||||
|
# pylint: disable=access-member-before-definition
|
||||||
|
assert self.default_config
|
||||||
|
assert self.default_isolate_map
|
||||||
|
self.default_config = os.path.join(_SCRIPT_DIR, 'mb_config.pyl')
|
||||||
|
self.default_isolate_map = os.path.join(_SRC_DIR, 'infra', 'specs',
|
||||||
|
'gn_isolate_map.pyl')
|
||||||
|
|
||||||
is_android = 'target_os="android"' in vals['gn_args']
|
def GetSwarmingCommand(self, target, vals):
|
||||||
is_fuchsia = 'target_os="fuchsia"' in vals['gn_args']
|
isolate_map = self.ReadIsolateMap()
|
||||||
is_ios = 'target_os="ios"' in vals['gn_args']
|
test_type = isolate_map[target]['type']
|
||||||
is_linux = self.platform.startswith('linux') and not is_android
|
|
||||||
is_win = self.platform.startswith('win')
|
|
||||||
|
|
||||||
if test_type == 'nontest':
|
is_android = 'target_os="android"' in vals['gn_args']
|
||||||
self.WriteFailureAndRaise('We should not be isolating %s.' % target,
|
is_fuchsia = 'target_os="fuchsia"' in vals['gn_args']
|
||||||
output_path=None)
|
is_ios = 'target_os="ios"' in vals['gn_args']
|
||||||
if test_type not in ('console_test_launcher', 'windowed_test_launcher',
|
is_linux = self.platform.startswith('linux') and not is_android
|
||||||
'non_parallel_console_test_launcher', 'raw',
|
is_win = self.platform.startswith('win')
|
||||||
'additional_compile_target', 'junit_test', 'script'):
|
|
||||||
self.WriteFailureAndRaise('No command line for '
|
|
||||||
'%s found (test type %s).' %
|
|
||||||
(target, test_type),
|
|
||||||
output_path=None)
|
|
||||||
|
|
||||||
cmdline = []
|
if test_type == 'nontest':
|
||||||
extra_files = [
|
self.WriteFailureAndRaise('We should not be isolating %s.' %
|
||||||
'../../.vpython3',
|
target,
|
||||||
'../../testing/test_env.py',
|
output_path=None)
|
||||||
]
|
if test_type not in ('console_test_launcher', 'windowed_test_launcher',
|
||||||
vpython_exe = 'vpython3'
|
'non_parallel_console_test_launcher', 'raw',
|
||||||
|
'additional_compile_target', 'junit_test',
|
||||||
|
'script'):
|
||||||
|
self.WriteFailureAndRaise('No command line for '
|
||||||
|
'%s found (test type %s).' %
|
||||||
|
(target, test_type),
|
||||||
|
output_path=None)
|
||||||
|
|
||||||
if isolate_map[target].get('script'):
|
cmdline = []
|
||||||
cmdline += [
|
extra_files = [
|
||||||
vpython_exe,
|
'../../.vpython3',
|
||||||
'../../' + self.ToSrcRelPath(isolate_map[target]['script'])
|
'../../testing/test_env.py',
|
||||||
]
|
|
||||||
elif is_android:
|
|
||||||
cmdline += [
|
|
||||||
'luci-auth', 'context', '--', vpython_exe,
|
|
||||||
'../../build/android/test_wrapper/logdog_wrapper.py', '--target',
|
|
||||||
target, '--logdog-bin-cmd',
|
|
||||||
'../../.task_template_packages/logdog_butler', '--logcat-output-file',
|
|
||||||
'${ISOLATED_OUTDIR}/logcats', '--store-tombstones'
|
|
||||||
]
|
|
||||||
elif is_ios or is_fuchsia or test_type == 'raw':
|
|
||||||
if is_win:
|
|
||||||
cmdline += ['bin\\run_{}.bat'.format(target)]
|
|
||||||
else:
|
|
||||||
cmdline += ['bin/run_{}'.format(target)]
|
|
||||||
else:
|
|
||||||
if isolate_map[target].get('use_webcam', False):
|
|
||||||
cmdline += [
|
|
||||||
vpython_exe, '../../tools_webrtc/ensure_webcam_is_running.py'
|
|
||||||
]
|
]
|
||||||
extra_files.append('../../tools_webrtc/ensure_webcam_is_running.py')
|
vpython_exe = 'vpython3'
|
||||||
if isolate_map[target].get('use_pipewire', False):
|
|
||||||
cmdline += [vpython_exe, '../../tools_webrtc/configure_pipewire.py']
|
|
||||||
extra_files.append('../../tools_webrtc/configure_pipewire.py')
|
|
||||||
|
|
||||||
# is_linux uses use_ozone and x11 by default.
|
if isolate_map[target].get('script'):
|
||||||
use_x11 = is_linux
|
cmdline += [
|
||||||
|
vpython_exe,
|
||||||
|
'../../' + self.ToSrcRelPath(isolate_map[target]['script'])
|
||||||
|
]
|
||||||
|
elif is_android:
|
||||||
|
cmdline += [
|
||||||
|
'luci-auth', 'context', '--', vpython_exe,
|
||||||
|
'../../build/android/test_wrapper/logdog_wrapper.py',
|
||||||
|
'--target', target, '--logdog-bin-cmd',
|
||||||
|
'../../.task_template_packages/logdog_butler',
|
||||||
|
'--logcat-output-file', '${ISOLATED_OUTDIR}/logcats',
|
||||||
|
'--store-tombstones'
|
||||||
|
]
|
||||||
|
elif is_ios or is_fuchsia or test_type == 'raw':
|
||||||
|
if is_win:
|
||||||
|
cmdline += ['bin\\run_{}.bat'.format(target)]
|
||||||
|
else:
|
||||||
|
cmdline += ['bin/run_{}'.format(target)]
|
||||||
|
else:
|
||||||
|
if isolate_map[target].get('use_pipewire', False):
|
||||||
|
cmdline += [
|
||||||
|
vpython_exe, '../../tools_webrtc/configure_pipewire.py'
|
||||||
|
]
|
||||||
|
extra_files.append('../../tools_webrtc/configure_pipewire.py')
|
||||||
|
|
||||||
xvfb = use_x11 and test_type == 'windowed_test_launcher'
|
# is_linux uses use_ozone and x11 by default.
|
||||||
if xvfb:
|
use_x11 = is_linux
|
||||||
cmdline += [vpython_exe, '../../testing/xvfb.py']
|
|
||||||
extra_files.append('../../testing/xvfb.py')
|
|
||||||
else:
|
|
||||||
cmdline += [vpython_exe, '../../testing/test_env.py']
|
|
||||||
|
|
||||||
extra_files += [
|
xvfb = use_x11 and test_type == 'windowed_test_launcher'
|
||||||
'../../third_party/gtest-parallel/gtest-parallel',
|
if xvfb:
|
||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
cmdline += [vpython_exe, '../../testing/xvfb.py']
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
extra_files.append('../../testing/xvfb.py')
|
||||||
]
|
else:
|
||||||
output_dir = '${ISOLATED_OUTDIR}/test_logs'
|
cmdline += [vpython_exe, '../../testing/test_env.py']
|
||||||
cmdline += [
|
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
|
||||||
'--output_dir=%s' % output_dir,
|
|
||||||
'--gtest_color=no',
|
|
||||||
]
|
|
||||||
if test_type == 'non_parallel_console_test_launcher':
|
|
||||||
# Still use the gtest-parallel-wrapper.py script since we
|
|
||||||
# need it to run tests on swarming, but don't execute tests
|
|
||||||
# in parallel.
|
|
||||||
cmdline.append('--workers=1')
|
|
||||||
|
|
||||||
asan = 'is_asan=true' in vals['gn_args']
|
extra_files += [
|
||||||
lsan = 'is_lsan=true' in vals['gn_args']
|
'../../third_party/gtest-parallel/gtest-parallel',
|
||||||
msan = 'is_msan=true' in vals['gn_args']
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
tsan = 'is_tsan=true' in vals['gn_args']
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
sanitizer = asan or lsan or msan or tsan
|
]
|
||||||
if not sanitizer:
|
output_dir = '${ISOLATED_OUTDIR}/test_logs'
|
||||||
# Retry would hide most sanitizers detections.
|
cmdline += [
|
||||||
cmdline.append('--retry_failed=3')
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
|
'--output_dir=%s' % output_dir,
|
||||||
|
'--gtest_color=no',
|
||||||
|
]
|
||||||
|
if test_type == 'non_parallel_console_test_launcher':
|
||||||
|
# Still use the gtest-parallel-wrapper.py script since we
|
||||||
|
# need it to run tests on swarming, but don't execute tests
|
||||||
|
# in parallel.
|
||||||
|
cmdline.append('--workers=1')
|
||||||
|
|
||||||
cmdline.append(_GetExecutable(target, self.platform))
|
asan = 'is_asan=true' in vals['gn_args']
|
||||||
|
lsan = 'is_lsan=true' in vals['gn_args']
|
||||||
|
msan = 'is_msan=true' in vals['gn_args']
|
||||||
|
tsan = 'is_tsan=true' in vals['gn_args']
|
||||||
|
sanitizer = asan or lsan or msan or tsan
|
||||||
|
if not sanitizer:
|
||||||
|
# Retry would hide most sanitizers detections.
|
||||||
|
cmdline.append('--retry_failed=3')
|
||||||
|
|
||||||
cmdline.extend([
|
cmdline.append(_GetExecutable(target, self.platform))
|
||||||
'--asan=%d' % asan,
|
|
||||||
'--lsan=%d' % lsan,
|
|
||||||
'--msan=%d' % msan,
|
|
||||||
'--tsan=%d' % tsan,
|
|
||||||
])
|
|
||||||
|
|
||||||
cmdline += isolate_map[target].get('args', [])
|
cmdline.extend([
|
||||||
|
'--asan=%d' % asan,
|
||||||
|
'--lsan=%d' % lsan,
|
||||||
|
'--msan=%d' % msan,
|
||||||
|
'--tsan=%d' % tsan,
|
||||||
|
])
|
||||||
|
|
||||||
return cmdline, extra_files
|
cmdline += isolate_map[target].get('args', [])
|
||||||
|
|
||||||
|
return cmdline, extra_files
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(sys.argv[1:]))
|
sys.exit(main(sys.argv[1:]))
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user