Skip to content

Commit

Permalink
sof_remove.sh: make lib.sh optional
Browse files Browse the repository at this point in the history
This makes is possible to use this file separately from sof-test, as
requested in #1169.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Jul 11, 2024
1 parent 9834162 commit edbf4da
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tools/kmod/sof_remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@

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"
else
printf '%s warning: %s not found, not sourced\n' "$0" "$libsh"
fi
}

remove_module() {

Expand All @@ -27,8 +36,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
Expand Down Expand Up @@ -56,6 +66,7 @@ kill_trace_users()
)
}

source_opt_libsh
trap 'exit_handler $?' EXIT

# Breaks systemctl --user and "double sudo" is not great
Expand Down

0 comments on commit edbf4da

Please sign in to comment.