From dfb75d7572e0ad38dfd2ce85a12895763a771424 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 11 Jul 2024 13:17:02 -0700 Subject: [PATCH] sof_remove.sh: make lib.sh optional This makes is possible to use this file separately from sof-test, as requested in #1169. Signed-off-by: Marc Herbert --- tools/kmod/sof_remove.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/kmod/sof_remove.sh b/tools/kmod/sof_remove.sh index 9bcf0c8c..149fa15d 100755 --- a/tools/kmod/sof_remove.sh +++ b/tools/kmod/sof_remove.sh @@ -5,8 +5,15 @@ TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -# shellcheck source=case-lib/lib.sh -source "$TOPDIR"/case-lib/lib.sh +# Used only by more advanced error handling +source_opt_libsh() +{ + local libsh="$TOPDIR"/case-lib/lib.sh + if test -e "$libsh"; then + # shellcheck source=case-lib/lib.sh + source "$libsh" + fi +} remove_module() { @@ -27,8 +34,9 @@ exit_handler() # "non-deterministically". So even if we are successful this time, # warn about any running pulseaudio because it could make us fail # the next time. + # TODO: display any pipewire process too. if pgrep -a pulseaudio; then - systemctl_show_pulseaudio + systemctl_show_pulseaudio || true fi if test "$exit_status" -ne 0; then @@ -56,6 +64,7 @@ kill_trace_users() ) } +source_opt_libsh trap 'exit_handler $?' EXIT # Breaks systemctl --user and "double sudo" is not great