refactor: harden diagnostics and consolidate runtime code

This commit is contained in:
Mikhail Chusavitin
2026-09-01 13:01:28 +03:00
parent ac4bc0b2b7
commit 0a6ca8ba0f
49 changed files with 1441 additions and 837 deletions
+42
View File
@@ -11,8 +11,37 @@ LOG_DIR="$TEST_ROOT/log"
mkdir -p "$LOG_DIR"
. "$BUILDER_DIR/lib/iso-validation.sh"
. "$BUILDER_DIR/lib/template.sh"
. "$BUILDER_DIR/lib/bootloader.sh"
literal_file="$TEST_ROOT/literal-file"
printf '%s\n' 'before %%VALUE%% after %%VALUE%%' > "$literal_file"
replace_literal_in_file "$literal_file" '%%VALUE%%' 'a&b#c\\d'
if [ "$(cat "$literal_file")" != 'before a&b#c\\d after a&b#c\\d' ]; then
echo "ERROR: generic literal replacement changed replacement characters" >&2
exit 1
fi
if replace_literal_in_file "$literal_file" '' value >/dev/null 2>&1; then
echo "ERROR: generic literal replacement accepted an empty placeholder" >&2
exit 1
fi
if replace_literal_in_file "$literal_file" '%%MISSING%%' value >/dev/null 2>&1; then
echo "ERROR: generic literal replacement accepted a missing placeholder" >&2
exit 1
fi
for valid_version in 13 13.0 v13.0-2-gabcdef0-dirty; do
if ! validate_project_version "$valid_version"; then
echo "ERROR: rejected valid project version: $valid_version" >&2
exit 1
fi
done
for invalid_version in '' '.13' '13.' '13/0' '13_0' '13 0' '13&0'; do
if validate_project_version "$invalid_version"; then
echo "ERROR: accepted unsafe project version: $invalid_version" >&2
exit 1
fi
done
literal_template="$TEST_ROOT/literal-template"
literal_output="$TEST_ROOT/literal-output"
printf '%s\n' '@VERSION@ @KERNEL@ @APPEND_LIVE@ @INITRD@' > "$literal_template"
@@ -23,6 +52,11 @@ if [ "$(cat "$literal_output")" != "$literal_expected" ]; then
echo "ERROR: bootloader renderer changed literal replacement characters" >&2
exit 1
fi
if render_bootloader_template "$literal_template" "$literal_output" \
'13.0-test' '@MISSING_KERNEL@' '/live/vmlinuz' 'boot=live' '@INITRD@' '/live/initrd.img' >/dev/null 2>&1; then
echo "ERROR: bootloader renderer accepted a missing required placeholder" >&2
exit 1
fi
rendered_grub="$TEST_ROOT/grub.cfg"
rendered_isolinux="$TEST_ROOT/live.cfg"
@@ -49,6 +83,14 @@ if validate_live_cmdline_params "$missing_serialization" linux GRUB "$BEE_ISO_VO
exit 1
fi
missing_boot_live="$TEST_ROOT/missing-boot-live.cfg"
awk 'BEGIN { removed=0 } /^ linux / && !removed { sub(/ boot=live/, ""); removed=1 } { print }' \
"$rendered_grub" > "$missing_boot_live"
if validate_live_cmdline_params "$missing_boot_live" linux GRUB "$BEE_ISO_VOLUME" >/dev/null 2>&1; then
echo "ERROR: validator ignored a live entry without boot=live" >&2
exit 1
fi
CACHE_ROOT="$TEST_ROOT/cache"
BUILD_VARIANT="test"
BUILD_WORK_DIR="$TEST_ROOT/work"