mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test: validate defconfigs, ensure root login is disabled
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -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 \
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
# Tests in this suite sanity check the repo, e.g. defconfigs
|
||||
|
||||
- name: repo
|
||||
suite: repo/all.yaml
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- case: defconfig.sh
|
||||
name: "validate defconfigs"
|
||||
Executable
+53
@@ -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
|
||||
Reference in New Issue
Block a user