5 echo "running as" $
(id
)
9 if [ "${ID}" == "ubuntu" ]; then
11 elif [ "${ID}" == "debian" ]; then
14 DISTRIBUTION
="Unknown"
17 # Detect release version if supported
18 FILE
="/etc/lsb-release"
19 if [ -e $FILE ] ; then
21 RELEASE
="${DISTRIB_RELEASE}"
27 # Taskcluster friendly wrapper for performing fx desktop tests via mozharness.
30 # Inputs, with defaults
32 : GECKO_PATH
${GECKO_PATH}
33 : MOZHARNESS_PATH
${MOZHARNESS_PATH}
34 : MOZHARNESS_URL
${MOZHARNESS_URL}
35 : MOZHARNESS_SCRIPT
${MOZHARNESS_SCRIPT}
36 : MOZHARNESS_CONFIG
${MOZHARNESS_CONFIG}
37 : MOZHARNESS_OPTIONS
${MOZHARNESS_OPTIONS}
38 : MOZ_ENABLE_WAYLAND
${MOZ_ENABLE_WAYLAND}
39 : NEED_XVFB
${NEED_XVFB:=true}
40 : NEED_WINDOW_MANAGER
${NEED_WINDOW_MANAGER:=false}
41 : NEED_PULSEAUDIO
${NEED_PULSEAUDIO:=false}
42 : NEED_COMPIZ
${NEED_COPMPIZ:=false}
43 : START_VNC
${START_VNC:=false}
44 : TASKCLUSTER_INTERACTIVE
${TASKCLUSTER_INTERACTIVE:=false}
45 : mozharness args
"${@}"
46 : WORKING_DIR
${WORKING_DIR:=$(pwd)}
47 : WORKSPACE
${WORKSPACE:=${WORKING_DIR%/}/workspace}
54 echo # make sure error message is on a new line
55 echo "[test-linux.sh:error]" "${@}"
61 if $NEED_PULSEAUDIO; then
62 # call pulseaudio for Ubuntu only
63 if [ $DISTRIBUTION == "Ubuntu" ]; then
64 pulseaudio
--daemonize --log-level=4 --log-time=1 --log-target=stderr
--start --fail -vvvvv --exit-idle-time=-1 --cleanup-shm --dump-conf
69 # test required parameters are supplied
70 if [ -z "${MOZHARNESS_PATH}" -a -z "${MOZHARNESS_URL}" ]; then
71 fail
"MOZHARNESS_PATH or MOZHARNESS_URL must be defined";
74 if [[ -z ${MOZHARNESS_SCRIPT} ]]; then fail
"MOZHARNESS_SCRIPT is not set"; fi
75 if [[ -z ${MOZHARNESS_CONFIG} ]]; then fail
"MOZHARNESS_CONFIG is not set"; fi
77 if [ $MOZ_ENABLE_WAYLAND ]; then
79 NEED_WINDOW_MANAGER
=true
82 # make sure artifact directories exist
83 mkdir
-p "$WORKSPACE/logs"
84 mkdir
-p "$WORKING_DIR/artifacts/public"
85 mkdir
-p "$WORKSPACE/build/blobber_upload_dir"
88 local mutter_pids
=`ps aux | grep 'mutter --wayland' | grep -v grep | awk '{print $2}'`
89 if [ "$mutter_pids" != "" ]; then
90 echo "Killing the following Mutter processes: $mutter_pids"
91 sudo
kill $mutter_pids
93 echo "No Mutter processes to kill"
99 if [[ -s $HOME/.xsession-errors
]]; then
101 cp "$HOME/.xsession-errors" "$WORKING_DIR/artifacts/public/xsession-errors.log"
103 if [ $MOZ_ENABLE_WAYLAND ]; then
111 trap cleanup EXIT INT
113 # Download mozharness with exponential backoff
114 # curl already applies exponential backoff, but not for all
115 # failed cases, apparently, as we keep getting failed downloads
117 download_mozharness
() {
118 local max_attempts
=10
122 echo "Downloading mozharness"
124 while [[ $attempt < $max_attempts ]]; do
125 if curl
--fail -o mozharness.
zip --retry 10 -L $MOZHARNESS_URL; then
127 if unzip -q mozharness.
zip -d mozharness
; then
130 echo "error unzipping mozharness.zip" >&2
132 echo "failed to download mozharness zip" >&2
134 echo "Download failed, retrying in $timeout seconds..." >&2
136 timeout
=$
((timeout
*2))
137 attempt
=$
((attempt
+1))
140 fail
"Failed to download and unzip mozharness"
143 # Download mozharness if we're told to.
144 if [ ${MOZHARNESS_URL} ]; then
148 if ! [ -d mozharness
]; then
149 fail
"mozharness zip did not contain mozharness/"
152 MOZHARNESS_PATH
=`pwd`/mozharness
155 # run XVfb in the background, if necessary
157 # note that this file is not available when run under native-worker
158 .
$HOME/scripts
/xvfb.sh
159 start_xvfb
'1600x1200x24' 0
163 x11vnc
> "$WORKING_DIR/artifacts/public/x11vnc.log" 2>&1 &
166 if $NEED_WINDOW_MANAGER; then
167 # This is read by xsession to select the window manager
169 if [ $DISTRIBUTION == "Ubuntu" ] && [ $RELEASE == "16.04" ]; then
170 echo DESKTOP_SESSION
=ubuntu
> $HOME/.xsessionrc
171 elif [ $DISTRIBUTION == "Ubuntu" ] && [ $RELEASE == "18.04" ]; then
172 echo export DESKTOP_SESSION
=gnome
> $HOME/.xsessionrc
173 echo export XDG_CURRENT_DESKTOP
=GNOME
> $HOME/.xsessionrc
174 if [ $MOZ_ENABLE_WAYLAND ]; then
175 echo export XDG_SESSION_TYPE
=wayland
>> $HOME/.xsessionrc
177 echo export XDG_SESSION_TYPE
=x11
>> $HOME/.xsessionrc
183 # DISPLAY has already been set above
184 # XXX: it would be ideal to add a semaphore logic to make sure that the
185 # window manager is ready
186 /etc
/X11
/Xsession
2>&1 &
188 # Turn off the screen saver and screen locking
189 gsettings
set org.gnome.desktop.screensaver idle-activation-enabled false
190 gsettings
set org.gnome.desktop.screensaver lock-enabled false
191 gsettings
set org.gnome.desktop.screensaver lock-delay
3600
193 # Disable the screen saver
196 # This starts the gnome-keyring-daemon with an unlocked login keyring. libsecret uses this to
197 # store secrets. Firefox uses libsecret to store a key that protects sensitive information like
198 # credit card numbers.
199 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
200 # if not found, launch a new one
201 eval `dbus-launch --sh-syntax`
203 eval `echo '' | /usr/bin/gnome-keyring-daemon -r -d --unlock --components=secrets`
205 # Run mutter as nested wayland compositor to provide Wayland environment
207 if [ $MOZ_ENABLE_WAYLAND ]; then
209 export XDG_RUNTIME_DIR
=$WORKING_DIR
210 mutter
--display=:0 --wayland --nested &
211 export WAYLAND_DISPLAY
=wayland-0
214 until [ $retry_count -gt $max_retries ]; do
215 if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then
216 retry_count
=$
(($max_retries + 1))
218 retry_count
=$
(($retry_count + 1))
219 echo "Waiting for Mutter, retry: $retry_count"
226 if [[ $NEED_COMPIZ == true
]] && [[ $RELEASE == 16.04 ]]; then
228 elif [[ $NEED_COMPIZ == true
]] && [[ $RELEASE == 18.04 ]]; then
229 compiz
--replace 2>&1 &
232 # Bug 1607713 - set cursor position to 0,0 to avoid odd libx11 interaction
233 if [ $NEED_WINDOW_MANAGER ] && [ $DISPLAY == ':0' ]; then
239 # For telemetry purposes, the build process wants information about the
240 # source it is running
241 export MOZ_SOURCE_REPO
="${GECKO_HEAD_REPOSITORY}"
242 export MOZ_SOURCE_CHANGESET
="${GECKO_HEAD_REV}"
244 # support multiple, space delimited, config files
246 for cfg
in $MOZHARNESS_CONFIG; do
247 config_cmds
="${config_cmds} --config-file ${MOZHARNESS_PATH}/configs/${cfg}"
250 if [ -n "$MOZHARNESS_OPTIONS" ]; then
252 for option
in $MOZHARNESS_OPTIONS; do
253 options
="$options --$option"
257 # Save the computed mozharness command to a binary which is useful for
259 mozharness_bin
="$HOME/bin/run-mozharness"
260 mkdir
-p $
(dirname $mozharness_bin)
262 echo -e "#!/usr/bin/env bash
263 # Some mozharness scripts assume base_work_dir is in
264 # the current working directory, see bug 1279237
266 cmd=\"${PYTHON:-python3} ${MOZHARNESS_PATH}/scripts/${MOZHARNESS_SCRIPT} ${config_cmds} ${options} ${@} \${@}\"
267 echo \"Running: \${cmd}\"
268 exec \${cmd}" > ${mozharness_bin}
269 chmod +x
${mozharness_bin}
271 # In interactive mode, the user will be prompted with options for what to do.
272 if ! $TASKCLUSTER_INTERACTIVE; then
273 # run the given mozharness script and configs, but pass the rest of the
274 # arguments in from our own invocation
278 # Run a custom mach command (this is typically used by action tasks to run
279 # harnesses in a particular way)
280 if [ "$CUSTOM_MACH_COMMAND" ]; then
281 eval "'$WORKSPACE/build/venv/bin/python' '$WORKSPACE/build/tests/mach' ${CUSTOM_MACH_COMMAND} ${@}"