test: simplify and skip UNIX backup files

- Drop 'local', not available in POSIX shell scripts
 - Check for an assortment of backup file combos
 - Simplify nested if-statements, skip whitelist first

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-09-28 07:26:45 +02:00
parent 065f86a74c
commit c61b4361ab
+13 -9
View File
@@ -23,21 +23,25 @@ disabled_root_login()
# For all defconfigs
check()
{
local total=$#
local num=1
local base=
total=$#
num=1
base=
echo "1..$total"
for defconfig in "$@"; do
# Skip UNIX backup files
case "$defconfig" in
*~|*.bak|'#'*'#'|.#*)
continue
;;
esac
base=$(basename "$defconfig")
if disabled_root_login "$defconfig"; then
if whitelist "$base"; then
echo "ok $num - $base is exempted # skip"
elif disabled_root_login "$defconfig"; then
echo "ok $num - $base disables root logins"
else
if whitelist "$base"; then
echo "ok $num - $base is exempted # skip"
else
echo "not ok $num - $base has not disabled root login"
fi
echo "not ok $num - $base has not disabled root login"
fi
num=$((num + 1))
done