From 5e5e5faaa3dbfdd119058cdd64de5cb54f5c1844 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 18 May 2021 17:37:41 -0700 Subject: [PATCH] check-sof-logger: fail when there are multiple sof-logger in PATH We don't want to test random versions. Signed-off-by: Marc Herbert --- test-case/check-sof-logger.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test-case/check-sof-logger.sh b/test-case/check-sof-logger.sh index c30be25b..4293241d 100755 --- a/test-case/check-sof-logger.sh +++ b/test-case/check-sof-logger.sh @@ -29,9 +29,21 @@ type -a sof-logger || die "sof-logger Not Installed!" -if type -a sof-logger | tail -n +2 | grep -q . ; then - dlogw "There are multiple sof-loggers in system" - dlogw "using $(type -p sof-logger)" +# Checksum a list of files, one filename per stdin line. +# Whitespace-safe and shellcheck-approved. +md5list() +{ + while read -r; do md5sum "$REPLY"; done +} + +# Recent Ubuntu versions symlink the entire /bin -> /usr/bin so we +# cannot just count the number of filenames we found. Count the +# number of different _checksums_ we found in PATH. +if type -a -p sof-logger | md5list | awk '{ print $1 }' | + sort -u | tail -n +2 | grep -q . ; then + dloge "There are different sof-logger in PATH on the system $(hostname)!" + type -a -p sof-logger | md5list + die "Not testing a random sof-logger version" fi loggerBin=$(type -p sof-logger) dlogi "Found file: $(md5sum "$loggerBin" | awk '{print $2, $1;}')"