Files
felhom.eu/scripts/iso/test/test_bound_banner_clears.py
T

39 lines
1.4 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""W7 (rehearsal 2026-10-20): the linked banner clears the console AND its scroll-back before it paints, so the spent
pairing code is no longer readable above it. Pure file read (runs on the BusyBox CI runner).
RED-PROOF: remove the ESC[3J printf from print_bound_banner → FAIL.
Run: python3 scripts/iso/test/test_bound_banner_clears.py"""
import os
import re
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
SCRIPT = os.path.join(os.path.dirname(HERE), "felhom-bootstrap.sh")
def banner_body(text):
m = re.search(r"^print_bound_banner\(\) \{\n(.*?)^\}", text, re.S | re.M)
return m.group(1) if m else ""
def main():
body = banner_body(open(SCRIPT, encoding="utf-8").read())
if not body:
print("FAIL: print_bound_banner not found")
return 1
first = re.search(r"printf\s+'([^']*)'", body)
if not first or "\\033[3J" not in first.group(1) or "\\033[2J" not in first.group(1):
print("FAIL: the first thing the linked banner prints must clear the screen and its scroll-back (\\033[3J ... \\033[2J)")
return 1
# control: the decoy without the clear is refused
if "\\033[3J" in banner_body("print_bound_banner() {\n printf 'x'\n}\n"):
print("FAIL: control")
return 1
print("OK: the linked banner clears the console and its scroll-back first")
return 0
if __name__ == "__main__":
sys.exit(main())