mirror of
https://github.com/Klipper4FlashForge/firmware.git
synced 2026-10-22 05:12:16 -05:00
Two changes that turned out to be one.
MOVED, NOT DELETED. `test/ffsim/` and `test/integration/printer/` are
`tools/replica/`. They were never tests: bin/patch.sh calls
bin/build-payload.py, which starts a replica and assembles the payload by
running the PRINTER'S OWN opkg against / inside it -- so the "test harness"
was on the build path, and deleting it as asked would have broken `make
build`. qa/lib/replica.py drives the same directory unmodified. No content
changed; what changed is qa/lib/replica.py's build directory, three launcher
sys.path lines, the Makefile targets and the CI shellcheck glob.
tools/replica/README.md says who drives it and why it is not under test/.
CUT TO 28. The five surviving modules were 136 tests; they are 28, chosen on
one question: would this failure be SILENT? What is kept is the mistakes that
run perfectly and are wrong --
test_startup 8 no stamp unless the values are verifiably saved (a
stamp written early is a printer that has lost its
factory calibration for good), and the handover order
test_tool_transform 7 every one is a move to the wrong place: a sign, a
frame left applied while probing, a stale gcode_move
cache, a config a calibrated printer cannot parse
test_ffscreen 5 the four ways it can do harm rather than look wrong
test_chamber 4 the chamber mistakes that cost a print before anyone
sees them, plus the parse gate they rest on
test_gcode 4 a renamed macro, and the safe file being cold
What went: the panel narration, the geometry probe and parse_geometry, the
z_adjust and per-job-Z bookkeeping, the config layout checks, the G-code
bounds checks. Each is either a wrong number shown to a person, or a failure
the printer reports loudly the first time -- and qa/replica/test_boot_screen.py
already renders the real frames on the real machine.
The rewrite is not a delete: assertions were folded so a kept test asks its
question in every direction it can be got wrong (both models, both rotations,
all four ways the migration can fail), and each file's header now says what it
dropped and why, where the next person will open it.
Also gone: conftest's `rootfs` fixture, orphaned two commits ago. Nothing under
test/ needs the firmware, docker, or a network any more.
28 host-side tests pass in 0.15s. qa/static unchanged at 218. `make rootfs`
re-verified end to end from its new path.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzLebCrvc8ssWR5JuEsha4
40 lines
1.6 KiB
Bash
Executable File
40 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Teach the kernel to run the printer's binaries.
|
|
#
|
|
# The stock qemu-mipsel binfmt registration does NOT match them: its mask
|
|
# requires e_ident[EI_ABIVERSION] (byte 8) to be 0, and every binary the
|
|
# Ingenic toolchain produced for this printer has 3 there. That single byte is
|
|
# why `exec format error` happens even with qemu installed and registered.
|
|
# Our handler masks byte 8 out; everything else is the stock mipsel matcher.
|
|
#
|
|
# Requires --privileged (or CAP_SYS_ADMIN + the binfmt_misc mount).
|
|
set -e
|
|
|
|
BF=/proc/sys/fs/binfmt_misc
|
|
NAME=c5printer
|
|
QEMU=/usr/bin/qemu-mipsel-static
|
|
|
|
[ -x "$QEMU" ] || { echo "binfmt: $QEMU missing" >&2; exit 1; }
|
|
|
|
if [ ! -f "$BF/register" ]; then
|
|
mount -t binfmt_misc binfmt_misc "$BF" 2>/dev/null \
|
|
|| { echo "binfmt: cannot mount binfmt_misc -- run the container --privileged" >&2; exit 1; }
|
|
fi
|
|
|
|
if [ "${BINFMT_RESET:-0}" = 1 ] && [ -f "$BF/$NAME" ]; then
|
|
echo -1 > "$BF/$NAME"
|
|
fi
|
|
|
|
if [ ! -f "$BF/$NAME" ]; then
|
|
# 7f E L F |32 |LE |v1 |os |abiver.....pad............|type |mach
|
|
MAGIC='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
|
|
# ^^^^ osabi and abiversion are don't-care
|
|
MASK='\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\xff\xff'
|
|
# F = interpreter is opened NOW and kept, so it resolves inside the chroot
|
|
# without copying qemu into the printer's filesystem.
|
|
# O = pass the binary as an fd, C = compute credentials from the binary.
|
|
echo ":$NAME:M::$MAGIC:$MASK:$QEMU:OCF" > "$BF/register"
|
|
fi
|
|
|
|
grep -q '^enabled' "$BF/$NAME" || { echo "binfmt: $NAME registered but disabled" >&2; exit 1; }
|