From 962dd7ee276cefd808d16681d5c3d0ba0eb84c86 Mon Sep 17 00:00:00 2001 From: Edwin Takahashi Date: Mon, 21 Oct 2019 16:34:43 +0000 Subject: [PATCH] Bug 1565332 - change how pulseaudio is initialized for Debian 10 test image without affecting existing Ubuntu 16.04 process r=jlund,dustin Changes: - for Debian platforms, do not initialize pulseaudio in `test-linux.sh`; instead initialize pulseaudio if required in the `desktop_unittest.py` mozharness script Differential Revision: https://phabricator.services.mozilla.com/D45768 --HG-- extra : moz-landing-system : lando --- .../debian10-test/dot-files/pulse/default.pa | 164 ------------------ taskcluster/scripts/tester/test-linux.sh | 33 +--- testing/mozharness/mozharness/base/python.py | 2 +- testing/mozharness/mozharness/base/script.py | 15 +- .../mozharness/scripts/desktop_unittest.py | 22 +++ 5 files changed, 39 insertions(+), 197 deletions(-) delete mode 100644 taskcluster/docker/debian10-test/dot-files/pulse/default.pa diff --git a/taskcluster/docker/debian10-test/dot-files/pulse/default.pa b/taskcluster/docker/debian10-test/dot-files/pulse/default.pa deleted file mode 100644 index 39bb44aa7d3a..000000000000 --- a/taskcluster/docker/debian10-test/dot-files/pulse/default.pa +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/pulseaudio -nF -# -# This file is part of PulseAudio. -# -# PulseAudio is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# PulseAudio is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with PulseAudio; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -# This startup script is used only if PulseAudio is started per-user -# (i.e. not in system mode) - -.nofail - -### Load something into the sample cache -#load-sample-lazy x11-bell /usr/share/sounds/gtk-events/activate.wav -#load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav -#load-sample-lazy pulse-coldplug /usr/share/sounds/startup3.wav -#load-sample-lazy pulse-access /usr/share/sounds/generic.wav - -.fail - -### Automatically restore the volume of streams and devices -load-module module-device-restore -load-module module-stream-restore -load-module module-card-restore - -### Automatically augment property information from .desktop files -### stored in /usr/share/application -load-module module-augment-properties - -### Load audio drivers statically -### (it's probably better to not load these drivers manually, but instead -### use module-udev-detect -- see below -- for doing this automatically) -#load-module module-alsa-sink -#load-module module-alsa-source device=hw:1,0 -#load-module module-oss device="/dev/dsp" sink_name=output source_name=input -#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input -#load-module module-null-sink -#load-module module-pipe-sink - -### Automatically load driver modules depending on the hardware available -.ifexists module-udev-detect.so -load-module module-udev-detect -.else -### Use the static hardware detection module (for systems that lack udev/hal support) -load-module module-detect -.endif - -### Automatically connect sink and source if JACK server is present -.ifexists module-jackdbus-detect.so -.nofail -load-module module-jackdbus-detect -.fail -.endif - -### Automatically load driver modules for Bluetooth hardware -# This module causes a pulseaudio startup failure on "gecko-tester" -#.ifexists module-bluetooth-discover.so -#load-module module-bluetooth-discover -#.endif - -### Load several protocols -.ifexists module-esound-protocol-unix.so -load-module module-esound-protocol-unix -.endif -load-module module-native-protocol-unix - -### Network access (may be configured with paprefs, so leave this commented -### here if you plan to use paprefs) -#load-module module-esound-protocol-tcp -#load-module module-native-protocol-tcp -#load-module module-zeroconf-publish - -### Load the RTP receiver module (also configured via paprefs, see above) -#load-module module-rtp-recv - -### Load the RTP sender module (also configured via paprefs, see above) -#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'" -#load-module module-rtp-send source=rtp.monitor - -### Load additional modules from GConf settings. This can be configured with the paprefs tool. -### Please keep in mind that the modules configured by paprefs might conflict with manually -### loaded modules. -.ifexists module-gconf.so -.nofail -load-module module-gconf -.fail -.endif - -### Automatically restore the default sink/source when changed by the user -### during runtime -### NOTE: This should be loaded as early as possible so that subsequent modules -### that look up the default sink/source get the right value -load-module module-default-device-restore - -### Automatically move streams to the default sink if the sink they are -### connected to dies, similar for sources -load-module module-rescue-streams - -### Make sure we always have a sink around, even if it is a null sink. -load-module module-always-sink - -### Honour intended role device property -load-module module-intended-roles - -### Automatically suspend sinks/sources that become idle for too long -load-module module-suspend-on-idle - -### If autoexit on idle is enabled we want to make sure we only quit -### when no local session needs us anymore. -# This module causes a pulseaudio startup failure on "gecko-tester" -#.ifexists module-console-kit.so -#load-module module-console-kit -#.endif - -### Enable positioned event sounds -load-module module-position-event-sounds - -### Cork music streams when a phone stream is active -#load-module module-cork-music-on-phone - -### Modules to allow autoloading of filters (such as echo cancellation) -### on demand. module-filter-heuristics tries to determine what filters -### make sense, and module-filter-apply does the heavy-lifting of -### loading modules and rerouting streams. -load-module module-filter-heuristics -load-module module-filter-apply - -### Load DBus protocol -#.ifexists module-dbus-protocol.so -#load-module module-dbus-protocol -#.endif - -# X11 modules should not be started from default.pa so that one daemon -# can be shared by multiple sessions. - -### Load X11 bell module -#load-module module-x11-bell sample=bell-windowing-system - -### Register ourselves in the X11 session manager -#load-module module-x11-xsmp - -### Publish connection data in the X11 root window -#.ifexists module-x11-publish.so -#.nofail -#load-module module-x11-publish -#.fail -#.endif - -load-module module-switch-on-port-available - -### Make some devices default -#set-default-sink output -#set-default-source input diff --git a/taskcluster/scripts/tester/test-linux.sh b/taskcluster/scripts/tester/test-linux.sh index 1427d788689e..bf6a391710b3 100755 --- a/taskcluster/scripts/tester/test-linux.sh +++ b/taskcluster/scripts/tester/test-linux.sh @@ -49,33 +49,9 @@ fail() { # start pulseaudio maybe_start_pulse() { if $NEED_PULSEAUDIO; then - # call pulseaudio with varying parameters + # call pulseaudio for Ubuntu only if [ $DISTRIBUTION == "Ubuntu" ]; then pulseaudio --fail --daemonize --start - elif [ $DISTRIBUTION == "Debian" ]; then - # temporarily turn errexit off - # nicely kill existing daemons/processes if exist - set +e - pulseaudio --kill - - # Debian needs additional stabilization and debugging - ps ax | grep 'pulseaudio' - ps -ef | grep 'pulseaudio' | grep -v grep | awk '{print $2}' | xargs -r kill -9 - ps ax | grep 'pulseaudio' - - # check and start pulseaudio with debugging - pulseaudio --check; echo $? - pulseaudio --fail --daemonize --start -vvvv --exit-idle-time=-1 --log-level=4 --log-time=1 - set -e - else - : - fi - - pulseaudio --check - if [ $? -eq 0 ]; then - echo "Pulseaudio successfully initialized" - else - echo "Pulseaudio failed to initialize, trying again" fi fi } @@ -172,6 +148,7 @@ if $NEED_WINDOW_MANAGER; then gsettings set org.gnome.desktop.screensaver idle-activation-enabled false gsettings set org.gnome.desktop.screensaver lock-enabled false gsettings set org.gnome.desktop.screensaver lock-delay 3600 + # Disable the screen saver xset s off s reset @@ -193,12 +170,6 @@ fi maybe_start_pulse -if $NEED_PULSEAUDIO; then - # Load null-sink using pactl, and if it was successful. - pactl load-module module-null-sink - pactl list modules short -fi - # For telemetry purposes, the build process wants information about the # source it is running export MOZ_SOURCE_REPO="${GECKO_HEAD_REPOSITORY}" diff --git a/testing/mozharness/mozharness/base/python.py b/testing/mozharness/mozharness/base/python.py index 4698eeec2d75..8baf48708de4 100644 --- a/testing/mozharness/mozharness/base/python.py +++ b/testing/mozharness/mozharness/base/python.py @@ -365,7 +365,7 @@ class VirtualenvMixin(object): # imports to fail. See # https://github.com/pypa/virtualenv/issues/565. Therefore # only use --alway-copy when not using Redhat. - if self._is_redhat(): + if self._is_redhat_based(): self.warning("creating virtualenv without --always-copy " "due to issues on Redhat derived distros") else: diff --git a/testing/mozharness/mozharness/base/script.py b/testing/mozharness/mozharness/base/script.py index 5c10f9e82830..e476ff2d7856 100755 --- a/testing/mozharness/mozharness/base/script.py +++ b/testing/mozharness/mozharness/base/script.py @@ -119,7 +119,20 @@ class PlatformMixin(object): if sys.platform.startswith("linux"): return True - def _is_redhat(self): + def _is_debian(self): + """ check if the current operating system is explicitly Debian. + This intentionally doesn't count Debian derivatives like Ubuntu. + + Returns: + bool: True if the current platform is debian, False otherwise + """ + if not self._is_linux(): + return False + self.info(mozinfo.linux_distro) + re_debian_distro = re.compile('debian') + return re_debian_distro.match(mozinfo.linux_distro) is not None + + def _is_redhat_based(self): """ check if the current operating system is a Redhat derived Linux distribution. Returns: diff --git a/testing/mozharness/scripts/desktop_unittest.py b/testing/mozharness/scripts/desktop_unittest.py index f31890c0a242..073a996aa81b 100755 --- a/testing/mozharness/scripts/desktop_unittest.py +++ b/testing/mozharness/scripts/desktop_unittest.py @@ -196,6 +196,7 @@ class DesktopUnittest(TestingMixin, MercurialScript, MozbaseMixin, 'clobber', 'download-and-extract', 'create-virtualenv', + 'start-pulseaudio', 'install', 'stage-files', 'run-tests', @@ -609,6 +610,27 @@ class DesktopUnittest(TestingMixin, MercurialScript, MozbaseMixin, super(DesktopUnittest, self).download_and_extract(extract_dirs=extract_dirs, suite_categories=target_categories) + def start_pulseaudio(self): + command = [] + if (os.environ.get('NEED_PULSEAUDIO') == 'true' and self._is_debian()): + # Debian platform requires additional idle timer specification so + # that it will not terminate the process on its own. + command.extend([ + 'pulseaudio', + '--daemonize', + '--log-level=4', + '--log-time=1', + '-vvvvv', + '--exit-idle-time=-1' + ]) + + # Instantiate pulseaudio. + if self._is_debian(): + self._kill_named_proc('pulseaudio') + self.run_command(command) + self.run_command('pactl load-module module-null-sink') + self.run_command('pactl list modules short') + def stage_files(self): for category in SUITE_CATEGORIES: suites = self._query_specified_suites(category)