diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 13c5b350..86fceadf 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1,7 +1,7 @@ #!/bin/bash # get test-case information -SCRIPT_HOME="$(dirname "$0")" +SCRIPT_HOME="$(dirname "${BASH_SOURCE[0]}")" # get test-case parent folder name SCRIPT_HOME=$(cd "$SCRIPT_HOME/.." && pwd) # shellcheck disable=SC2034 # external script can use it @@ -162,6 +162,42 @@ func_lib_check_sudo() } } +systemctl_show_pulseaudio() +{ + printf '\n' + local domain + for domain in --system --global --user; do + ( set -x + systemctl "$domain" list-unit-files --all '*pulse*' + ) || true + printf '\n' + done + + printf 'For %s ONLY:\n' "$(id -un)" + ( set -x + systemctl --user list-units --all '*pulse*' + ) || true + printf '\n' + + # pgrep ouput is nicer because it hides itself, however pgrep does + # not show a critical information: the userID which can be not us + # but 'gdm'! + # shellcheck disable=SC2009 + ps axu | grep -i pulse + >&2 printf 'ERROR: %s fails semi-randomly when pulseaudio is running\n' \ + "$(basename "$0")" + + >&2 printf '\nTry: sudo systemctl --global mask pulseaudio.{socket,service} and reboot. + --global is required for session managers like "gdm" +' + # We cannot suggest "systemctl --user mask" for a 'gdm' user + # because we can't 'su' to it and access its DBUS, so we suggest + # --global to keep it simple. If --global is too strong for you, you + # can manually create a + # /var/lib/gdm3/.config/systemd/user/pulseaudio.service -> /dev/null + # symlink +} + declare -a PULSECMD_LST declare -a PULSE_PATHS diff --git a/tools/kmod/sof_remove.sh b/tools/kmod/sof_remove.sh index 7647fd53..9c95adad 100755 --- a/tools/kmod/sof_remove.sh +++ b/tools/kmod/sof_remove.sh @@ -2,6 +2,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel Corporation. All rights reserved. + +TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) + +# shellcheck source=case-lib/lib.sh +source "$TOPDIR"/case-lib/lib.sh + remove_module() { local MODULE="$1" @@ -22,9 +28,7 @@ exit_handler() # warn about any running pulseaudio because it could make us fail # the next time. if pgrep -a pulseaudio; then - >&2 printf 'ERROR: %s fails semi-randomly when pulseaudio is running\n' \ - "$(basename "$0")" - systemctl --user list-units --all '*pulse*' || true + systemctl_show_pulseaudio fi if test "$exit_status" -ne 0; then