Bug 1434958 - Allow using gstreamer 1.0 and don't hardcode paths when setting up fake devices for webrtc testing. r?pehrsons
MozReview-Commit-ID: 4ogpCqxMojK
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -1,15 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from abc import ABCMeta, abstractmethod, abstractproperty
from argparse import ArgumentParser, SUPPRESS
from distutils.util import strtobool
+from distutils import spawn
from itertools import chain
from urlparse import urlparse
import logging
import json
import os
import tempfile
from mozdevice import DroidADB
@@ -799,21 +800,30 @@ class MochitestArguments(ArgumentContain
if not os.path.isdir(options.dumpOutputDirectory):
parser.error('--dump-output-directory not a directory: %s' %
options.dumpOutputDirectory)
if options.useTestMediaDevices:
if not mozinfo.isLinux:
parser.error(
'--use-test-media-devices is only supported on Linux currently')
- for f in ['/usr/bin/gst-launch-0.10', '/usr/bin/pactl']:
- if not os.path.isfile(f):
- parser.error(
- 'Missing binary %s required for '
- '--use-test-media-devices' % f)
+
+ gst01 = spawn.find_executable("gst-launch-0.1")
+ gst10 = spawn.find_executable("gst-launch-1.0")
+ pactl = spawn.find_executable("pactl")
+
+ if not (gst01 or gst10):
+ parser.error(
+ 'Missing gst-launch-{0.1,1.0}, required for '
+ '--use-test-media-devices')
+
+ if not pactl:
+ parser.error(
+ 'Missing binary pactl required for '
+ '--use-test-media-devices')
if options.nested_oop:
options.e10s = True
options.leakThresholds = {
"default": options.defaultLeakThreshold,
"tab": options.defaultLeakThreshold,
# GMP rarely gets a log, but when it does, it leaks a little.
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -10,16 +10,17 @@ from __future__ import with_statement
import os
import sys
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
sys.path.insert(0, SCRIPT_DIR)
from argparse import Namespace
from collections import defaultdict
from contextlib import closing
+from distutils import spawn
import copy
import ctypes
import glob
import json
import mozcrash
import mozdebug
import mozinfo
import mozprocess
@@ -739,38 +740,47 @@ def findTestMediaDevices(log):
device = dev
break
if not (name and device):
log.error('Couldn\'t find a v4l2loopback video device')
return None
# Feed it a frame of output so it has something to display
- subprocess.check_call(['/usr/bin/gst-launch-0.10', 'videotestsrc',
+ gst01 = spawn.find_executable("gst-launch-0.1")
+ gst10 = spawn.find_executable("gst-launch-1.0")
+ if gst01:
+ gst = gst01
+ else:
+ gst = gst10
+ subprocess.check_call([gst, 'videotestsrc',
'pattern=green', 'num-buffers=1', '!',
'v4l2sink', 'device=%s' % device])
info['video'] = name
+ pactl = spawn.find_executable("pactl")
+ pacmd = spawn.find_executable("pacmd")
+
# Use pactl to see if the PulseAudio module-null-sink module is loaded.
def null_sink_loaded():
o = subprocess.check_output(
- ['/usr/bin/pactl', 'list', 'short', 'modules'])
+ [pactl, 'list', 'short', 'modules'])
return filter(lambda x: 'module-null-sink' in x, o.splitlines())
if not null_sink_loaded():
# Load module-null-sink
- subprocess.check_call(['/usr/bin/pactl', 'load-module',
+ subprocess.check_call([pactl, 'load-module',
'module-null-sink'])
if not null_sink_loaded():
log.error('Couldn\'t load module-null-sink')
return None
# Whether it was loaded or not make it the default output
- subprocess.check_call(['/usr/bin/pacmd', 'set-default-sink', 'null'])
+ subprocess.check_call([pacmd, 'set-default-sink', 'null'])
# Hardcode the name since it's always the same.
info['audio'] = 'Monitor of Null Output'
return info
class KeyValueParseError(Exception):