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/android/build_aar.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
|
||||
|
||||
@ -126,9 +126,7 @@
|
||||
},
|
||||
"video_capture_tests": {
|
||||
"label": "//modules/video_capture:video_capture_tests",
|
||||
"type": "non_parallel_console_test_launcher",
|
||||
# TODO(bugs.webrtc.org/9292): remove use_webcam and the ensure script.
|
||||
"use_webcam": True,
|
||||
"type": "console_test_launcher",
|
||||
},
|
||||
"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:]))
|
||||
@ -36,6 +36,7 @@ def main(args):
|
||||
|
||||
|
||||
class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# Make sure default_config and default_isolate_map are attributes of the
|
||||
@ -58,11 +59,13 @@ class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||
is_win = self.platform.startswith('win')
|
||||
|
||||
if test_type == 'nontest':
|
||||
self.WriteFailureAndRaise('We should not be isolating %s.' % target,
|
||||
self.WriteFailureAndRaise('We should not be isolating %s.' %
|
||||
target,
|
||||
output_path=None)
|
||||
if test_type not in ('console_test_launcher', 'windowed_test_launcher',
|
||||
'non_parallel_console_test_launcher', 'raw',
|
||||
'additional_compile_target', 'junit_test', 'script'):
|
||||
'additional_compile_target', 'junit_test',
|
||||
'script'):
|
||||
self.WriteFailureAndRaise('No command line for '
|
||||
'%s found (test type %s).' %
|
||||
(target, test_type),
|
||||
@ -83,10 +86,11 @@ class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||
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'
|
||||
'../../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:
|
||||
@ -94,13 +98,10 @@ class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||
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')
|
||||
if isolate_map[target].get('use_pipewire', False):
|
||||
cmdline += [vpython_exe, '../../tools_webrtc/configure_pipewire.py']
|
||||
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.
|
||||
|
||||
@ -25,13 +25,15 @@ from tools_webrtc.mb import mb
|
||||
|
||||
|
||||
class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
||||
|
||||
def __init__(self, win32=False):
|
||||
super().__init__()
|
||||
|
||||
# Override vars for test portability.
|
||||
if win32:
|
||||
self.chromium_src_dir = 'c:\\fake_src'
|
||||
self.default_config = 'c:\\fake_src\\tools_webrtc\\mb\\mb_config.pyl'
|
||||
self.default_config = (
|
||||
'c:\\fake_src\\tools_webrtc\\mb\\mb_config.pyl')
|
||||
self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\'
|
||||
'gn_isolate_map.pyl')
|
||||
self.platform = 'win32'
|
||||
@ -41,7 +43,8 @@ class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
||||
else:
|
||||
self.chromium_src_dir = '/fake_src'
|
||||
self.default_config = '/fake_src/tools_webrtc/mb/mb_config.pyl'
|
||||
self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
self.default_isolate_map = (
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl')
|
||||
self.executable = '/usr/bin/vpython3'
|
||||
self.platform = 'linux2'
|
||||
self.sep = '/'
|
||||
@ -226,7 +229,8 @@ def CreateFakeMBW(files=None, win32=False):
|
||||
mbw.files.setdefault(
|
||||
mbw.ToAbsPath('//build/args/bots/fake_group/fake_args_bot.gn'),
|
||||
'is_debug = false\ndcheck_always_on=false\n')
|
||||
mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'), '{}')
|
||||
mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'),
|
||||
'{}')
|
||||
if files:
|
||||
for path, contents in list(files.items()):
|
||||
mbw.files[path] = contents
|
||||
@ -284,7 +288,8 @@ class UnitTest(unittest.TestCase):
|
||||
" 'type': 'raw',"
|
||||
" 'args': [],"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = CreateFakeMBW(files)
|
||||
self.check([
|
||||
@ -306,11 +311,13 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'console_test_launcher',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'android_bot', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -348,11 +355,13 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'junit_test',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'android_bot', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -396,8 +405,9 @@ class UnitTest(unittest.TestCase):
|
||||
"foo_unittests_script.py\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'debug_goma', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -429,11 +439,13 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'raw',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'debug_goma', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -460,11 +472,13 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'non_parallel_console_test_launcher',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'debug_goma', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -512,8 +526,9 @@ class UnitTest(unittest.TestCase):
|
||||
"some_resource_file\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'debug_goma', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -566,12 +581,14 @@ class UnitTest(unittest.TestCase):
|
||||
'gen', '-c', 'debug_goma', '--swarming-targets-file',
|
||||
'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl', '//out/Default'
|
||||
'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl',
|
||||
'//out/Default'
|
||||
],
|
||||
mbw=mbw,
|
||||
ret=0)
|
||||
|
||||
isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate']
|
||||
isolate_file = mbw.files[
|
||||
'c:\\fake_src\\out\\Default\\unittests.isolate']
|
||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||
files = isolate_file_contents['variables']['files']
|
||||
command = isolate_file_contents['variables']['command']
|
||||
@ -608,60 +625,13 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'console_test_launcher',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
ret=0)
|
||||
|
||||
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||
files = isolate_file_contents['variables']['files']
|
||||
command = isolate_file_contents['variables']['command']
|
||||
|
||||
self.assertEqual(files, [
|
||||
'../../.vpython3',
|
||||
'../../testing/test_env.py',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||
'foo_unittests',
|
||||
])
|
||||
self.assertEqual(command, [
|
||||
'vpython3',
|
||||
'../../testing/test_env.py',
|
||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
|
||||
'--gtest_color=no',
|
||||
'--retry_failed=3',
|
||||
'./foo_unittests',
|
||||
'--asan=0',
|
||||
'--lsan=0',
|
||||
'--msan=0',
|
||||
'--tsan=0',
|
||||
])
|
||||
|
||||
def test_isolate_test_launcher_with_webcam(self):
|
||||
test_files = {
|
||||
'/tmp/swarming_targets':
|
||||
'foo_unittests\n',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||
("{'foo_unittests': {"
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'console_test_launcher',"
|
||||
" 'use_webcam': True,"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"
|
||||
"some_resource_file\n"),
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
mbw = self.check([
|
||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||
'/tmp/swarming_targets', '--isolate-map-file',
|
||||
'gen', '-c', 'debug_goma', '//out/Default',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl'
|
||||
],
|
||||
files=test_files,
|
||||
@ -677,14 +647,10 @@ class UnitTest(unittest.TestCase):
|
||||
'../../testing/test_env.py',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||
'../../tools_webrtc/ensure_webcam_is_running.py',
|
||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||
'foo_unittests',
|
||||
'some_resource_file',
|
||||
])
|
||||
self.assertEqual(command, [
|
||||
'vpython3',
|
||||
'../../tools_webrtc/ensure_webcam_is_running.py',
|
||||
'vpython3',
|
||||
'../../testing/test_env.py',
|
||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||
@ -707,7 +673,8 @@ class UnitTest(unittest.TestCase):
|
||||
" 'label': '//foo:foo_unittests',"
|
||||
" 'type': 'non_parallel_console_test_launcher',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||
("foo_unittests\n"),
|
||||
}
|
||||
self.check(
|
||||
['isolate', '-c', 'debug_goma', '//out/Default', 'foo_unittests'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user