From 8baca7df031a7e3bf7907ba876c7ef9ae7d53557 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 17 Jun 2024 13:38:23 +0200 Subject: [PATCH] test: unit: defconfig: Skip root login checks for all boot configs Also, hoist the whitelist check up one level, so that we can report which configs we are exempting, and which ones we are actually checking. --- test/case/repo/defconfig.sh | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/test/case/repo/defconfig.sh b/test/case/repo/defconfig.sh index edfd743c..e8d0768a 100755 --- a/test/case/repo/defconfig.sh +++ b/test/case/repo/defconfig.sh @@ -5,44 +5,39 @@ CONFIGS="$SCRIPT_PATH/../../../configs" whitelist() { - nm=$(basename "$1") - case $nm in - cn9130_crb_boot_defconfig | fireant_boot_defconfig) + case "$1" in + *_boot_defconfig) return 0 ;; - *) - return 1 - ;; esac + + return 1 } # Check for disabled root login disabled_root_login() { - txt="# BR2_TARGET_ENABLE_ROOT_LOGIN is not set" - fn=$(realpath "$1") - - if ! grep -q "$txt" "$fn"; then - if ! whitelist "$fn"; then - echo "Missing '$txt' in $fn!" - return 1 - fi - fi + grep -q "# BR2_TARGET_ENABLE_ROOT_LOGIN is not set" "$1" } # For all defconfigs check() { - total=$# - num=1 + local total=$# + local num=1 + local base= echo "1..$total" for defconfig in "$@"; do - fn=$(basename "$defconfig") + base=$(basename "$defconfig") if disabled_root_login "$defconfig"; then - echo "ok $num - $fn" + echo "ok $num - $base disables root logins" else - echo "not ok $num - $fn has not disabled root login" + if whitelist "$base"; then + echo "ok $num - $base is exempted # skip" + else + echo "not ok $num - $base has not disabled root login" + fi fi num=$((num + 1)) done