test: validate defconfigs, ensure root login is disabled

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-11-14 10:20:00 +01:00
parent b4eb4508e4
commit c1fd4506e6
4 changed files with 63 additions and 1 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
test-dir := $(BR2_EXTERNAL_INFIX_PATH)/test
INFIX_TESTS ?= $(test-dir)/case/all-unit.yaml $(test-dir)/case/all.yaml
INFIX_TESTS ?= $(test-dir)/case/all-repo.yaml $(test-dir)/case/all-unit.yaml \
$(test-dir)/case/all.yaml
test-env = $(test-dir)/env \
-f $(BINARIES_DIR)/infix-x86_64.img \
+5
View File
@@ -0,0 +1,5 @@
---
# Tests in this suite sanity check the repo, e.g. defconfigs
- name: repo
suite: repo/all.yaml
+3
View File
@@ -0,0 +1,3 @@
---
- case: defconfig.sh
name: "validate defconfigs"
+53
View File
@@ -0,0 +1,53 @@
#!/bin/sh
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
CONFIGS="$SCRIPT_PATH/../../../configs"
whitelist()
{
nm=$(basename "$1")
case $nm in
aarch64_classic_defconfig | cn9130_crb_boot_defconfig | fireant_boot_defconfig | x86_64_classic_defconfig)
return 0
;;
*)
return 1
;;
esac
}
# 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
}
# For all defconfigs
check()
{
total=$#
num=1
echo "1..$total"
for defconfig in "$@"; do
fn=$(basename "$defconfig")
if disabled_root_login "$defconfig"; then
echo "ok $num - $fn"
else
echo "not ok $num - $fn has not disabled root login"
fi
num=$((num + 1))
done
}
check "$CONFIGS"/* || exit 1
exit 0