-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-tests.sh
More file actions
executable file
·1975 lines (1830 loc) · 103 KB
/
Copy pathci-tests.sh
File metadata and controls
executable file
·1975 lines (1830 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# ci-tests.sh — CI-runnable, non-hardware parity test suite (P3.12).
#
# Consolidates, into ONE command:
# - the existing image-contract scripts (check-zimage-dtb.sh, check-linux-img.sh,
# check-size-budget.sh) -- called, not reimplemented;
# - the Makefile's structural initramfs checks (check-initramfs, initramfs-verify);
# - the full P1.12 QEMU boot test of the initramfs /init (scripts/test-initramfs.sh);
# - a P2.2/P2.8-style stock-`MiSTer`-binary ABI smoke, run under qemu-user against
# the built rootfs (the dynamic-link-resolves-clean check and the
# dies-at-FPGA-access-not-earlier whitelist -- docs/abi-contract.md §2.4/§2.5,
# A-10/A-22). NOTE: this is a *lightweight* interim of just those two qemu-user
# gates. The full ABI/loader checklist (docs/abi-contract.md §13.1) now lives in
# its own deliverable, scripts/check-abi.sh (P2.2), which build.yml runs
# alongside this suite. The overlap on A-10/A-22 is deliberate: they are the two
# highest-value checks and cheap enough to assert in both places.
# - per-service / per-artifact parity checks harvested from each Phase 3 parity
# doc's "verify-in-build" checklist, asserted against the built
# output/images/rootfs.tar (the actual shipped artifact) and, where a binary
# must run, qemu-user against output/target as the sysroot.
#
# Usage: scripts/ci-tests.sh [build-dir]
# build-dir defaults to "output" (repo-root-relative). Only the image-contract
# scripts and the Phase-3 artifact checks honor an override -- the Makefile-based
# initramfs checks and scripts/test-initramfs.sh use Buildroot's own fixed
# output/ + output-initramfs/ layout (Makefile: OUTPUT_DIR := $(CURDIR)/output,
# not parameterized) and are SKIPPED with an explicit reason if build-dir differs.
#
# Output: one PASS/FAIL/SKIP line per check (grouped by phase/subsystem), full
# detail from called scripts shown inline, then a summary. SKIP never fails the
# suite; any FAIL does.
#
# The run is long (thousands of lines once the called scripts' own output is in
# there), so the LAST thing printed is a self-contained digest, in this order:
#
# SKIPPED (n) -- checks that did NOT run, with why. A skip is not a pass.
# FAILURES (n) -- every failure, with its reason. Omitted when there are none.
# RESULT: PASS|FAIL
#
# So `scripts/ci-tests.sh | tail -n 30` tells you what broke and why, without
# scrolling or grepping -- which is the whole point: the previous version printed
# the failure ONLY at the moment it happened (on stderr, buried mid-run) and the
# end-of-run summary was a flat 46-line PASS/FAIL list, so a `tail` showed the
# counts and named nothing. An intermittent failure was seen but not identifiable.
# Under GitHub Actions each failure is additionally emitted as a ::error::
# annotation, so it shows up in the run UI rather than only in the raw log.
#
# Exit: 0 = every check PASSed or SKIPped. 1 = at least one FAIL. 2 = usage error.
#
# Env overrides (all optional):
# CI_TESTS_SKIP_QEMU_SYSTEM=1 skip scripts/test-initramfs.sh (the slow one --
# builds/reuses a whole QEMU test kernel and boots
# it 6 times; everything else in this suite is fast)
# CI_TESTS_LOG=<path> where to write the machine-readable result list
# (default: <build-dir>/ci-tests-results.txt). Best
# -effort: if the path is not writable the run still
# passes. Upload this as a CI artifact.
set -u
# Deliberately not -e: this script's entire job is "run every check, keep going,
# report the full picture" -- exactly test-initramfs.sh's own stated rationale.
prog=${0##*/}
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$HERE/.." && pwd)"
BUILD_DIR_ARG="${1:-output}"
case "$BUILD_DIR_ARG" in
/*) BUILD_DIR="$BUILD_DIR_ARG" ;;
*) BUILD_DIR="$ROOT/$BUILD_DIR_ARG" ;;
esac
IS_DEFAULT_OUTPUT=0
[ "$BUILD_DIR" = "$ROOT/output" ] && IS_DEFAULT_OUTPUT=1
IMAGES="$BUILD_DIR/images"
TARGET="$BUILD_DIR/target"
HOST_SBIN="$BUILD_DIR/host/sbin"
ROOTFS_TAR="$IMAGES/rootfs.tar"
ZIMAGE_DTB="$IMAGES/zImage_dtb"
LINUX_IMG="$IMAGES/linux.img"
# The MAIN kernel's version. Every module/vermagic check below scopes to
# usr/lib/modules/$KVER/ on purpose: since ADR 0021's 2026-07-18 amendment the
# rootfs may also carry kernel-VARIANT trees (e.g. the RT beta's 7.2.0 — that
# example read "7.2.0-rc3*" until the pin reached 7.2 final on 2026-08-17; it
# is illustrative either way, nothing here globs on it,
# merged in via work/extra-modules-overlay), and those are deliberately out of
# scope here — their depmod health is asserted by check-abi.sh A-25 (every
# tree), and their presence in CI by build.yml's merged-kver assert. Do not
# "fix" these checks to glob across all trees; they would then pass on the
# variant tree while the main one regressed.
#
# DERIVED, never hardcoded. This was literally `KVER=6.18.38` until 2026-07-19,
# and it drifted the moment the kernel moved to 6.18.39: every module check
# below started looking in usr/lib/modules/6.18.38/, found nothing, and
# reported six failures that all read like the kernel-module packages had gone
# stale ("a kernel bump needs 'make <pkg>-dirclean'") when in fact the build was
# fine and only this constant was wrong. A hardcoded version here does not fail
# safe -- it fails *misleadingly*, pointing the reader at the wrong subsystem.
#
# Read the DE10 board fragment specifically, which is what the scoping note
# above is about: configs/mister_rt.fragment overrides this symbol for the RT
# variant; the kernel-only stack shares this very fragment with the image
# (configs/fragments/stacks.mk), so there is no lockstep copy to worry about.
#
# Anchored to ^ and taking the last match on purpose: a comment quoting the
# symbol verbatim would otherwise match too -- the exact bug fixed in the
# hash-sync workflow (#42).
KVER=$(sed -n 's/^BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="\([^"]*\)".*$/\1/p' \
"$ROOT/configs/fragments/de10nano.fragment" | tail -1)
if [ -z "$KVER" ]; then
echo "FATAL: could not read BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE from" >&2
echo " $ROOT/configs/fragments/de10nano.fragment" >&2
exit 1
fi
# ---------------------------------------------------------------- reporting
PASS_COUNT=0
FAIL_COUNT=0
SKIP_COUNT=0
declare -a SUMMARY=()
# Why these two exist, and not just SUMMARY: a failing run buries its one FAIL
# line among ~45 PASS lines, and the end-of-run summary reprinted the same flat
# list -- so `tail` landed on the counts and showed WHICH checks failed nowhere.
# (That is not hypothetical; it is exactly how an intermittent failure was seen
# but not identified.) These hold the failures and skips, with their reason text,
# so the end of the run can reprint just those. Element format: "name<TAB>reason".
declare -a FAILED=()
declare -a SKIPPED=()
section() {
printf '\n=== %s ===\n' "$*"
}
pass() {
printf 'PASS %s\n' "$1"
SUMMARY+=("PASS $1")
PASS_COUNT=$((PASS_COUNT + 1))
}
fail() {
# stderr, so a failure is still visible when stdout is redirected away --
# but it is ALSO recorded in FAILED and reprinted to stdout at the end, so
# that a plain `... | tail` (stdout only) can never miss it.
printf 'FAIL %s\n' "$1" >&2
[ -n "${2:-}" ] && printf ' %s\n' "$2" >&2
SUMMARY+=("FAIL $1")
FAILED+=("$1"$'\t'"${2:-}")
FAIL_COUNT=$((FAIL_COUNT + 1))
}
skip() {
printf 'SKIP %s -- %s\n' "$1" "$2"
SUMMARY+=("SKIP $1 -- $2")
SKIPPED+=("$1"$'\t'"$2")
SKIP_COUNT=$((SKIP_COUNT + 1))
}
note() { printf ' %s\n' "$*"; }
# Run an external check-*.sh (or similar) command, show its output, then convert
# its exit code to one summary line. Reuses the script's own PASS/FAIL logic --
# does NOT re-derive it.
run_script() {
local name=$1; shift
printf -- '--- %s: %s ---\n' "$name" "$*"
if "$@"; then
pass "$name"
else
fail "$name" "'$*' exited nonzero -- see output above"
fi
}
have() { command -v "$1" >/dev/null 2>&1; }
# require_present PATH LABEL -- PASS if PATH is in rootfs.tar, else FAIL.
require_present() {
if tar_has "$1"; then
pass "$2 present"
else
fail "$2 present" "$1 not in rootfs.tar"
fi
}
# require_absent PATH LABEL [WHY] -- PASS if PATH is NOT in rootfs.tar, else FAIL.
# The mirror of require_present, for the deliberate-exclusion gates: a package
# whose upstream default installs more than we want (ADR 0022's client-only
# nfs-utils being the case in hand) regains the extra binaries silently on any
# option or version bump, and nothing else in the build would complain.
require_absent() {
if tar_has "$1"; then
fail "$2 absent" "$1 IS in rootfs.tar${3:+ -- $3}"
else
pass "$2 absent"
fi
}
# not_busybox_symlink PATH LABEL -- PASS if PATH is present in rootfs.tar AND
# is not a symlink into busybox, else FAIL. For the T5 "two packages install
# the same path, BusyBox must not be the one that won" regression guard
# (board/mister/de10nano/busybox.fragment): a collision that quietly resolves
# back to the BusyBox stub -- e.g. a future edit re-enables the applet without
# noticing a real package already owns that path -- is silent at build time
# (last install just wins) and would otherwise only surface as a user running
# a crippled lsof/lsusb/mkdosfs/chvt/openvt at runtime. require_present alone
# does not catch that (both providers satisfy "present"), so this checks what
# provided it.
not_busybox_symlink() {
local path="$1" label="$2" line
if ! tar_has "$path"; then
fail "$label is the real package, not BusyBox" "$path not in rootfs.tar at all"
return
fi
line=$(tar tvf "$ROOTFS_TAR" -- "./$path" 2>/dev/null | head -1)
case "$line" in
*'-> '*busybox*)
fail "$label is the real package, not BusyBox" "still a busybox symlink: $line" ;;
*)
pass "$label is the real package, not BusyBox" ;;
esac
}
# ---------------------------------------------------------------- prereqs
[ -f "$ROOTFS_TAR" ] || { echo "$prog: no $ROOTFS_TAR -- run a build first (or pass the build dir as \$1)." >&2; exit 2; }
TAR_LIST="$(mktemp "${TMPDIR:-/tmp}/ci-tests-tarlist.XXXXXX")"
WORKDIR="$(mktemp -d "${TMPDIR:-/tmp}/ci-tests-work.XXXXXX")"
# shellcheck disable=SC2329 # invoked indirectly via `trap cleanup EXIT` below
cleanup() { rm -f "$TAR_LIST"; rm -rf "$WORKDIR"; }
trap cleanup EXIT
tar tf "$ROOTFS_TAR" > "$TAR_LIST"
# tar_has PATH -- PATH without leading "./"; true if that exact entry (file,
# dir, or symlink -- tar tf lists all of them by name regardless of type) is
# in the built rootfs.tar.
tar_has() { grep -qxF "./$1" "$TAR_LIST"; }
# tar_size PATH -- prints the byte size tar recorded for PATH (0 for dirs/symlinks).
tar_size() {
tar tvf "$ROOTFS_TAR" -- "./$1" 2>/dev/null | awk '{print $3; exit}'
}
QEMU_ARM=""
have qemu-arm && QEMU_ARM=qemu-arm
qemu_target() {
# Run a target-ARM binary from $TARGET against $TARGET as its own sysroot.
"$QEMU_ARM" -L "$TARGET" "$@"
}
echo "$prog: build dir = $BUILD_DIR"
echo "$prog: rootfs.tar = $ROOTFS_TAR ($(wc -c <"$ROOTFS_TAR" | tr -d ' ') bytes, $(wc -l <"$TAR_LIST" | tr -d ' ') entries)"
[ -n "$QEMU_ARM" ] && echo "$prog: qemu-arm = $(command -v qemu-arm) ($(qemu-arm --version 2>&1 | head -1))" \
|| echo "$prog: qemu-arm NOT FOUND -- qemu-user checks will SKIP"
# =============================================================================
section "Image contracts (A3 / A9 / ADR 0015 / size budget)"
# =============================================================================
run_script "check-zimage-dtb.sh" "$ROOT/scripts/check-zimage-dtb.sh" "$ZIMAGE_DTB"
run_script "check-linux-img.sh" "$ROOT/scripts/check-linux-img.sh" "$LINUX_IMG" "$HOST_SBIN"
run_script "check-size-budget.sh" "$ROOT/scripts/check-size-budget.sh" "$LINUX_IMG" "$HOST_SBIN"
# =============================================================================
section "Initramfs (P1.10-P1.12, A7)"
# =============================================================================
if [ "$IS_DEFAULT_OUTPUT" -eq 1 ]; then
printf -- '--- check-initramfs (Makefile: main kernel .config has CONFIG_BLK_DEV_INITRD / CONFIG_INITRAMFS_SOURCE) ---\n'
if ( cd "$ROOT" && make --no-print-directory check-initramfs ); then
pass "check-initramfs (main kernel config)"
else
fail "check-initramfs (main kernel config)"
fi
printf -- '--- initramfs-verify (Makefile: required BusyBox applets + /init + /dev/console present in the cpio, ash -n parses /init) ---\n'
if ( cd "$ROOT" && make --no-print-directory initramfs-verify ); then
pass "initramfs-verify (cpio applet/structure check)"
else
fail "initramfs-verify (cpio applet/structure check)"
fi
else
skip "check-initramfs (main kernel config)" "Makefile's OUTPUT_DIR is fixed to ./output, not parameterized; build dir here is $BUILD_DIR"
skip "initramfs-verify (cpio applet/structure check)" "same fixed-OUTPUT_DIR reason"
fi
if [ "${CI_TESTS_SKIP_QEMU_SYSTEM:-0}" = "1" ]; then
skip "test-initramfs.sh (P1.12 QEMU boot test, 8 cases)" "CI_TESTS_SKIP_QEMU_SYSTEM=1"
elif ! have qemu-system-arm; then
skip "test-initramfs.sh (P1.12 QEMU boot test, 8 cases)" "qemu-system-arm not found on PATH"
else
printf -- '--- test-initramfs.sh: fat32 exfat fsck-request symlink label nonascii missing-image rootwait ---\n'
printf ' (builds/reuses a QEMU test kernel and boots it 8 times -- can take several minutes)\n'
if "$ROOT/scripts/test-initramfs.sh"; then
pass "test-initramfs.sh (P1.12 QEMU boot test, 8 cases)"
else
fail "test-initramfs.sh (P1.12 QEMU boot test, 8 cases)" "one or more of the 8 cases failed -- see output above"
fi
fi
# =============================================================================
section "ABI / stock-binary smoke (P2.2 + P2.8 core checks)"
# =============================================================================
# The stock `MiSTer` binary is a one-off P0.3-era extraction (work/, gitignored --
# not reproduced by a fresh `make all`), so this whole group degrades to SKIP
# when it isn't present, per this script's own design contract: a missing input
# is not a build regression.
STOCK_MISTER=""
for cand in "$ROOT/work/imgroot/tmp/MiSTer" "$ROOT/work/extracted/files/MiSTer"; do
[ -f "$cand" ] && { STOCK_MISTER="$cand"; break; }
done
if [ -z "$QEMU_ARM" ]; then
skip "dynamic-link resolution (P2.2/A-10)" "qemu-arm not found on PATH"
skip "FPGA-access whitelist (P2.8/A-22)" "qemu-arm not found on PATH"
elif [ -z "$STOCK_MISTER" ]; then
skip "dynamic-link resolution (P2.2/A-10)" "no stock MiSTer binary found (looked at work/imgroot/tmp/MiSTer, work/extracted/files/MiSTer -- a P0.3-era extraction, gitignored, not a build artifact)"
skip "FPGA-access whitelist (P2.8/A-22)" "same missing stock-binary reason"
else
MX="$WORKDIR/MiSTer.x"
cp "$STOCK_MISTER" "$MX"
chmod +x "$MX"
printf -- '--- dynamic-link resolution: LD_TRACE_LOADED_OBJECTS against %s ---\n' "$TARGET"
ldtrace_out="$WORKDIR/ldtrace.out"
LD_TRACE_LOADED_OBJECTS=1 "$QEMU_ARM" -L "$TARGET" -E LD_TRACE_LOADED_OBJECTS=1 "$MX" >"$ldtrace_out" 2>&1
ldtrace_rc=$?
sed 's/^/ /' "$ldtrace_out"
# NOTE: docs/abi-contract.md §2.4 measured "exactly 15 lines" against the
# STOCK rootfs (work/imgroot) as a known-good baseline -- not a number to pin
# against OUR rootfs, whose newer glibc legitimately resolves a different
# (currently 14-line) set with no `libdl.so.2` line. The actual P2.2
# assertion is "every name resolves, none 'not found'" -- that's what's
# checked here.
if [ "$ldtrace_rc" -eq 0 ] && [ -s "$ldtrace_out" ] && ! grep -qi 'not found' "$ldtrace_out"; then
pass "dynamic-link resolution (P2.2/A-10): $(wc -l <"$ldtrace_out" | tr -d ' ') libs, none 'not found'"
else
fail "dynamic-link resolution (P2.2/A-10)" "rc=$ldtrace_rc, or a 'not found' entry above -- see $ldtrace_out"
fi
printf -- '--- FPGA-access whitelist: qemu-arm -strace, expect openat(.../dev/mem) EACCES then SIGSEGV, nothing earlier ---\n'
strace_out="$WORKDIR/strace.out"
timeout -k 5 20 "$QEMU_ARM" -L "$TARGET" -strace "$MX" >"$strace_out" 2>&1
# The entry and the return are matched SEPARATELY, and the return is allowed to
# be one line late. That is not sloppiness -- qemu-user's -strace is not
# line-atomic. It emits the syscall entry and its return as two separate
# writes, so with a threaded guest (the stock MiSTer binary is threaded)
# another thread's line can land BETWEEN them and split the return off:
#
# openat(AT_FDCWD,"/dev/mem",O_RDWR|...|O_CLOEXEC)852734 futex(...) = 0
# = -1 errno=13 (Permission denied)
#
# The old single-line regex (entry .* return) therefore missed roughly 1 run in
# 40 -- measured, not guessed -- and reported it as "never reached /dev/mem",
# i.e. announced a REGRESSION on what was really trace interleaving. That was
# the suite's intermittent failure.
devmem_entry='openat\(.*"/dev/mem"'
devmem_denied='= *-1 .*(errno=13|EACCES)'
if grep -q 'error while loading shared libraries' "$strace_out"; then
fail "FPGA-access whitelist (P2.8/A-22)" "dynamic linker itself failed -- regression before any real syscall; see $strace_out"
elif ! grep -qE "$devmem_entry" "$strace_out"; then
fail "FPGA-access whitelist (P2.8/A-22)" "never reached openat(\"/dev/mem\") -- died earlier (regression) or ran past it; see $strace_out"
elif grep -A1 -E "$devmem_entry" "$strace_out" | grep -qE "$devmem_denied"; then
devmem_line=$(grep -nE "$devmem_entry" "$strace_out" | head -1 | cut -d: -f1)
note "reached openat(\"/dev/mem\") at line $devmem_line of the trace (permission denied, as expected -- no FPGA bridge under qemu-user)"
pass "FPGA-access whitelist (P2.8/A-22): dies at /dev/mem access, not earlier"
else
fail "FPGA-access whitelist (P2.8/A-22)" \
"reached openat(\"/dev/mem\") but its return was not the expected -1 EACCES. If the trace shows it SUCCEEDING, whoever ran this has /dev/mem access (running as root?) and the check's premise no longer holds; see $strace_out"
fi
fi
# =============================================================================
section "P3.1/P3.3 — Module autoload + vermagic"
# =============================================================================
MODULES_DEP="usr/lib/modules/$KVER/modules.dep"
MODULES_ALIAS="usr/lib/modules/$KVER/modules.alias"
if tar_has "$MODULES_DEP"; then
dep_lines=$(tar xOf "$ROOTFS_TAR" "./$MODULES_DEP" 2>/dev/null | wc -l | tr -d ' ')
if [ "$dep_lines" -gt 0 ]; then
pass "modules.dep non-empty ($dep_lines lines)"
else
fail "modules.dep non-empty" "file present but empty -- depmod did not run or found nothing"
fi
else
fail "modules.dep non-empty" "$MODULES_DEP not in rootfs.tar"
fi
if tar_has "$MODULES_ALIAS"; then
alias_lines=$(tar xOf "$ROOTFS_TAR" "./$MODULES_ALIAS" 2>/dev/null | wc -l | tr -d ' ')
alias_content="$WORKDIR/modules.alias"
tar xOf "$ROOTFS_TAR" "./$MODULES_ALIAS" 2>/dev/null > "$alias_content"
if [ "$alias_lines" -gt 0 ]; then
pass "modules.alias non-empty ($alias_lines lines)"
else
fail "modules.alias non-empty" "file present but empty"
fi
if grep -qi ' btusb$' "$alias_content"; then
pass "btusb modalias present in modules.alias"
else
fail "btusb modalias present in modules.alias" "no 'alias usb:... btusb' line found"
fi
if grep -qiE ' (rtl8187|rtl8192cu|rtl8xxxu|r8188eu|8188eu|rtw88_usb|rtw_8[0-9]{3}[a-z]?u)$' "$alias_content"; then
pass "Realtek USB WiFi modalias present in modules.alias"
else
fail "Realtek USB WiFi modalias present in modules.alias" "no rtl8187/rtl8192cu/rtl8xxxu/r8188eu/rtw88 alias line found"
fi
else
fail "modules.alias non-empty" "$MODULES_ALIAS not in rootfs.tar"
skip "btusb modalias present in modules.alias" "modules.alias missing"
skip "Realtek USB WiFi modalias present in modules.alias" "modules.alias missing"
fi
# Vermagic: every .ko/.ko.xz under this kernel's modules dir must agree on a
# single "$KVER ... ARMv7" string (mismatched vermagic = module refuses to load).
ko_list="$WORKDIR/ko_list.txt"
grep -E "^\./usr/lib/modules/$KVER/.*\.ko(\.xz)?\$" "$TAR_LIST" > "$ko_list" || true
ko_count=$(wc -l <"$ko_list" | tr -d ' ')
if [ "$ko_count" -eq 0 ]; then
fail "module vermagic ($KVER, ARMv7)" "no .ko/.ko.xz files found under usr/lib/modules/$KVER"
elif ! have xz; then
skip "module vermagic ($KVER, ARMv7)" "xz not found on PATH (needed to decompress .ko.xz)"
else
vermagics="$WORKDIR/vermagics.txt"
: > "$vermagics"
while IFS= read -r member; do
path="${member#./}"
case "$path" in
*.ko.xz)
tar xOf "$ROOTFS_TAR" "./$path" 2>/dev/null | xz -dc 2>/dev/null | strings | grep -m1 '^vermagic=' >> "$vermagics"
;;
*.ko)
tar xOf "$ROOTFS_TAR" "./$path" 2>/dev/null | strings | grep -m1 '^vermagic=' >> "$vermagics"
;;
esac
done < "$ko_list"
distinct=$(LC_ALL=C sort -u "$vermagics" | wc -l | tr -d ' ')
bad=$(grep -cvE "^vermagic=$KVER .*ARMv7" "$vermagics" || true)
if [ "$distinct" -eq 1 ] && [ "$bad" -eq 0 ]; then
pass "module vermagic ($KVER, ARMv7): consistent across all $ko_count modules -- $(LC_ALL=C sort -u "$vermagics")"
else
fail "module vermagic ($KVER, ARMv7)" "$distinct distinct vermagic string(s) across $ko_count modules, $bad not matching '$KVER ... ARMv7':"
sed 's/^/ /' "$vermagics" | LC_ALL=C sort -u >&2
fi
fi
# =============================================================================
section "P3.3 — Firmware parity (docs/firmware-parity.md documented present-set)"
# =============================================================================
STOCK_FW_MD="$ROOT/docs/stock-inventory/firmware.md"
PARITY_FW_MD="$ROOT/docs/firmware-parity.md"
if [ ! -f "$STOCK_FW_MD" ] || [ ! -f "$PARITY_FW_MD" ]; then
skip "firmware present-set (docs/firmware-parity.md)" "doc(s) missing: $STOCK_FW_MD / $PARITY_FW_MD"
else
all_fw="$WORKDIR/fw_all66.txt"
missing_fw="$WORKDIR/fw_missing10.txt"
present_fw="$WORKDIR/fw_present.txt"
# shellcheck disable=SC2016 # backticks are literal markdown code-span
# delimiters in docs/stock-inventory/firmware.md, not command substitution.
grep -E '^\| `[^`]+` \|' "$STOCK_FW_MD" | sed -E 's/^\| `([^`]+)`.*/\1/' | grep -v '/$' | LC_ALL=C sort > "$all_fw"
awk '/\*\*Missing \([0-9]+\):\*\*/{f=1;next} f&&/^```/{c++;if(c==2)exit;next} f&&c==1{print}' "$PARITY_FW_MD" | LC_ALL=C sort > "$missing_fw"
comm -23 "$all_fw" "$missing_fw" > "$present_fw"
all_n=$(wc -l <"$all_fw" | tr -d ' ')
missing_n=$(wc -l <"$missing_fw" | tr -d ' ')
present_n=$(wc -l <"$present_fw" | tr -d ' ')
note "docs say: $all_n stock files total, $missing_n documented as not reproduced (justified omissions), $present_n expected present"
if [ "$all_n" -eq 0 ] || [ "$present_n" -eq 0 ]; then
fail "firmware present-set (docs/firmware-parity.md)" "doc parsing produced an empty list -- doc format probably changed; script needs updating, not the build"
else
fw_missing_from_tar="$WORKDIR/fw_missing_from_tar.txt"
: > "$fw_missing_from_tar"
while IFS= read -r p; do
tar_has "usr/lib/firmware/$p" || echo "$p" >> "$fw_missing_from_tar"
done < "$present_fw"
nmiss=$(wc -l <"$fw_missing_from_tar" | tr -d ' ')
if [ "$nmiss" -eq 0 ]; then
pass "firmware present-set: all $present_n documented-present stock files are in rootfs.tar"
else
fail "firmware present-set" "$nmiss of $present_n documented-present files are MISSING from rootfs.tar:"
sed 's/^/ /' "$fw_missing_from_tar" >&2
fi
fi
fi
# =============================================================================
section "P3.2 — xone (Xbox One/Series accessory driver)"
# =============================================================================
xone_mods="xone_dongle xone_gip xone_gip_chatpad xone_gip_gamepad xone_gip_headset xone_gip_madcatz_glam xone_gip_madcatz_strat xone_gip_pdp_jaguar xone_wired"
xone_missing=""
for m in $xone_mods; do
tar_has "usr/lib/modules/$KVER/updates/$m.ko.xz" || xone_missing="$xone_missing $m"
done
if [ -z "$xone_missing" ]; then
pass "xone: all 9 .ko.xz modules present"
else
fail "xone: all 9 .ko.xz modules present" "missing:$xone_missing"
fi
# In-kernel USB WiFi (ADR 0016 as updated in v10, docs/wifi-parity.md §6).
#
# This assertion USED to check the opposite thing: that the out-of-tree
# 8812au/8821au .ko.xz were present under updates/. They are deliberately gone
# now -- mainline gained rtw88_8812au / rtw88_8821au (the shared rtw88_88xxa
# core, 6.13), so BR2_PACKAGE_RTL8812AU and BR2_PACKAGE_RTL8821AU_MORROWNR are
# deselected. Asserting the in-kernel replacements is the same protection
# against the same failure: a chip silently losing its driver.
#
# The stale-kmod hazard the old comment described is real and NOT solved by
# moving in-tree -- it just moved too. A kernel version bump rebuilds in-tree
# modules into a NEW lib/modules/<newver>/ while any out-of-tree kernel-module
# PACKAGE (xone and, since v10.2, rtl8852cu-morrownr -- both asserted here)
# stays stamped against the OLD kernel, landing in a stale tree. Because these
# paths are $KVER-scoped, this check fires if the in-tree modules ever fail to
# build for the shipped kernel. Fix when it fires: `make <pkg>-dirclean` for the
# stale package, or `make linux-rebuild all`, then rebuild.
rtwdir="usr/lib/modules/$KVER/kernel/drivers/net/wireless/realtek/rtw88"
# All seven rtw88 USB parts 6.18 offers -- 8814au was migrated in PR #35;
# 8812au/8821au/8723du complete the set in v10.
rtw88_usb_mods="rtw88_8822bu rtw88_8822cu rtw88_8821cu rtw88_8814au rtw88_8723du rtw88_8821au rtw88_8812au"
rtw88_missing=""
for m in $rtw88_usb_mods; do
tar_has "$rtwdir/$m.ko.xz" || rtw88_missing="$rtw88_missing $m"
done
if [ -z "$rtw88_missing" ]; then
pass "in-kernel WiFi: all 7 rtw88 USB .ko.xz present (ADR 0016 / v10)"
else
fail "in-kernel WiFi: all 7 rtw88 USB .ko.xz present (ADR 0016 / v10)" \
"missing:$rtw88_missing -- a CONFIG_RTW88_*U was dropped, or a kernel bump left the module tree stale (make linux-rebuild all)"
fi
# The REDUNDANT out-of-tree forks must NOT come back: if both an OOT fork and
# the in-kernel driver for the same chip ship, they bind-fight on the same USB
# IDs and which one wins is load-order dependent (ADR 0016's stated reason for
# disabling, not merely not-enabling, them). Assert their absence so a
# well-meaning re-enable of BR2_PACKAGE_RTL8812AU / _RTL8821AU_MORROWNR fails
# loudly here.
#
# NOTE this list is specifically 8812au/8821au, and it is NOT a blanket "no
# out-of-tree WiFi" rule -- v10.2 deliberately ships one such module, 8852cu,
# asserted PRESENT just below. The two assertions do not contradict each other
# because ADR 0016's rule was never "no forks": it is "no fork for a chip
# mainline can already drive". 8812au/8821au have rtw88_8812au/rtw88_8821au;
# RTL8852CU has nothing (rtw89 is PCIe-only for 8852C). Anything added to this
# list must be a chip with an in-kernel USB driver in the shipped kernel.
ootwifi_present=""
for m in 8812au 8821au; do
tar_has "usr/lib/modules/$KVER/updates/$m.ko.xz" && ootwifi_present="$ootwifi_present $m"
done
if [ -z "$ootwifi_present" ]; then
pass "redundant out-of-tree WiFi forks absent (8812au/8821au, ADR 0016 / v10)"
else
fail "redundant out-of-tree WiFi forks absent (8812au/8821au, ADR 0016 / v10)" \
"present:$ootwifi_present -- would bind-fight the in-kernel rtw88_88xxa drivers on the same USB IDs"
fi
# The ONE permitted out-of-tree WiFi fork must be present: 8852cu.ko
# (package/rtl8852cu-morrownr, BR2_PACKAGE_RTL8852CU_MORROWNR=y), for the
# RTL8852CU/RTL8832CU Wi-Fi 6E USB chips. Mainline 6.18 has the 8852C chip HAL
# in rtw89 but only a PCIe bus file (rtw8852ce.c; no rtw8852cu.c), and
# RTW89_8852CE depends on PCI which this board has not got -- so without this
# module those dongles bind NOTHING. See docs/wifi-parity.md §8 and ADR 0016's
# v10.2 update.
#
# Same shape and same path as the xone assertion above (updates/, .ko.xz),
# because it is the same mechanism: the kernel's scripts/Makefile.modinst
# defaults INSTALL_MOD_DIR to `updates` for M= builds, and Buildroot xz-
# compresses modules. It therefore catches the same two failures -- the package
# silently building no .ko (its `obj-$(CONFIG_RTL8852CU)` needs the
# CONFIG_RTL8852CU=m the .mk passes, and its ccflags need the KSRC= override; if
# either is lost the build "succeeds" with zero objects), and a kernel bump
# leaving the module stamped against the OLD $KVER.
if tar_has "usr/lib/modules/$KVER/updates/8852cu.ko.xz"; then
pass "out-of-tree WiFi: 8852cu.ko.xz present under updates/ (RTL8852CU, ADR 0016 / v10.2)"
else
fail "out-of-tree WiFi: 8852cu.ko.xz present under updates/ (RTL8852CU, ADR 0016 / v10.2)" \
"BR2_PACKAGE_RTL8852CU_MORROWNR dropped, the package built zero objects (CONFIG_RTL8852CU=m / KSRC= lost from MODULE_MAKE_OPTS), or a kernel bump left it stale (make rtl8852cu-morrownr-dirclean; make linux-rebuild all)"
fi
# Broadcom/Cypress FullMAC USB (v10): brcmfmac + its brcmutil helper. New in
# this image -- CONFIG_WLAN_VENDOR_BROADCOM was off entirely before.
brcm_missing=""
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz" \
|| brcm_missing="$brcm_missing brcmfmac"
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko.xz" \
|| brcm_missing="$brcm_missing brcmutil"
if [ -z "$brcm_missing" ]; then
pass "in-kernel WiFi: brcmfmac + brcmutil .ko.xz present (BCM43xx/CYW43xx USB, v10)"
else
fail "in-kernel WiFi: brcmfmac + brcmutil .ko.xz present (BCM43xx/CYW43xx USB, v10)" \
"missing:$brcm_missing -- CONFIG_BRCMFMAC/CONFIG_WLAN_VENDOR_BROADCOM dropped?"
fi
# Firmware for drivers that were being built with NO firmware at all
# (docs/wifi-parity.md §6.2/§6.3, docs/bluetooth-parity.md §9): MT7663U, ath3k,
# and the MediaTek BT half of the MT7921AU/MT7925U combo dongles whose WiFi half
# we already shipped, all probed and then failed at request_firmware(). Assert
# the blobs ship so that regression cannot recur silently.
# - MT7663U needs BOTH ROM-patch/N9 pairs: the driver picks the N9 to match
# whichever patch bound, so a half-set breaks a live fallback path.
# - The QCA pair is the "_usb_" variant specifically -- btusb's QCA path is
# self-contained (no CONFIG_BT_QCA) and asks for exactly these names.
# - rtl8761b/bu back the most common cheap USB Bluetooth 5 dongles on sale;
# they already shipped, and are asserted here so a firmware sub-option
# reshuffle cannot drop them unnoticed.
fw_missing=""
for f in \
mediatek/mt7663pr2h.bin mediatek/mt7663_n9_v3.bin \
mediatek/mt7663pr2h_rebb.bin mediatek/mt7663_n9_rebb.bin \
ath3k-1.fw \
brcm/brcmfmac43143.bin brcm/brcmfmac43236b.bin \
brcm/brcmfmac43242a.bin brcm/brcmfmac43569.bin \
rtlwifi/rtl8192dufw.bin rsi/rs9113_wlan_qspi.rps rsi/rs9116_wlan.rps \
mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin \
mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin \
mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin \
qca/rampatch_usb_00000302.bin qca/nvm_usb_00000302.bin \
brcm/BCM-0bb4-0306.hcd brcm/BCM20702A1-0b05-17cb.hcd \
rtl_bt/rtl8761b_fw.bin rtl_bt/rtl8761bu_fw.bin
do
tar_has "usr/lib/firmware/$f" || fw_missing="$fw_missing $f"
done
if [ -z "$fw_missing" ]; then
pass "WiFi/BT firmware: mt7663/ath3k/brcmfmac/rtl8192du/rsi + MTK-BT/QCA-BT/brcm-hcd/rtl8761b present"
else
fail "WiFi/BT firmware: mt7663/ath3k/brcmfmac/rtl8192du/rsi + MTK-BT/QCA-BT/brcm-hcd/rtl8761b present" \
"missing:$fw_missing -- a driver would probe then fail at request_firmware()"
fi
# v10.1 USB WiFi round-out (docs/wifi-parity.md §7). Every one of these had its
# firmware checked above or already shipping; assert the modules themselves.
# ath6k/AR6004 is a DIRECTORY in Buildroot's file list, so the firmware check
# above deliberately does not name a file inside it -- covered here by the
# driver's presence plus the ATHEROS_6004 defconfig symbol.
v101_missing=""
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8192du/rtl8192du.ko.xz" \
|| v101_missing="$v101_missing rtl8192du"
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko.xz" \
|| v101_missing="$v101_missing ath6kl_usb"
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/rsi/rsi_usb.ko.xz" \
|| v101_missing="$v101_missing rsi_usb"
if [ -z "$v101_missing" ]; then
pass "in-kernel WiFi: rtl8192du + ath6kl_usb + rsi_usb .ko.xz present (v10.1)"
else
fail "in-kernel WiFi: rtl8192du + ath6kl_usb + rsi_usb .ko.xz present (v10.1)" \
"missing:$v101_missing -- a CONFIG_ symbol was dropped, or the module tree is stale"
fi
# The SDIO bus drivers for the three vendors whose USB driver we build are all
# `default y`/`default m` under CONFIG_MMC=y, so each needs an explicit `is not
# set` in linux.config or olddefconfig silently builds a second bus driver for a
# slot this board does not have. Assert they stayed out of the image -- this is
# the check that catches a linux.config edit dropping those lines.
sdio_present=""
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac-sdio.ko.xz" \
&& sdio_present="$sdio_present brcmfmac-sdio"
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko.xz" \
&& sdio_present="$sdio_present ath6kl_sdio"
tar_has "usr/lib/modules/$KVER/kernel/drivers/net/wireless/rsi/rsi_sdio.ko.xz" \
&& sdio_present="$sdio_present rsi_sdio"
if [ -z "$sdio_present" ]; then
pass "SDIO WiFi bus drivers absent (no SDIO WiFi slot on DE10-Nano, v10/v10.1)"
else
fail "SDIO WiFi bus drivers absent (no SDIO WiFi slot on DE10-Nano, v10/v10.1)" \
"present:$sdio_present -- a '# CONFIG_*_SDIO is not set' line was dropped from linux.config"
fi
xow_size=$(tar_size "usr/lib/firmware/xow_dongle.bin")
if [ "${xow_size:-0}" -eq 70620 ] 2>/dev/null; then
pass "xow_dongle.bin present, 70620 bytes"
else
fail "xow_dongle.bin present, 70620 bytes" "got size='${xow_size:-<missing>}'"
fi
xone_02e6_size=$(tar_size "usr/lib/firmware/xone_dongle_02e6.bin")
if [ "${xone_02e6_size:-0}" -eq 70008 ] 2>/dev/null; then
pass "xone_dongle_02e6.bin present, 70008 bytes"
else
fail "xone_dongle_02e6.bin present, 70008 bytes" "got size='${xone_02e6_size:-<missing>}'"
fi
# =============================================================================
section "P3.4 — WiFi userland"
# =============================================================================
for spec in "usr/bin/bash:bash" "usr/bin/dialog:dialog" "usr/sbin/iw:iw" "usr/sbin/ip:ip" "usr/sbin/iwconfig:iwconfig"; do
path="${spec%%:*}"; label="${spec##*:}"
if tar_has "$path"; then
pass "$label present ($path)"
else
fail "$label present ($path)" "not in rootfs.tar"
fi
done
if tar_has "usr/sbin/iwlist"; then
pass "iwlist present (symlink to iwconfig)"
else
fail "iwlist present (symlink to iwconfig)" "not in rootfs.tar"
fi
if tar_has "usr/sbin/iwgetid"; then
pass "iwgetid present (symlink to iwconfig)"
else
fail "iwgetid present (symlink to iwconfig)" "not in rootfs.tar"
fi
# =============================================================================
section "T2 — WiFi hotplug (70-persistent-net.rules, docs/wifi-parity.md §9)"
# =============================================================================
# Closes docs/stock-reconciliation.md §3c's former "top follow-up": a WiFi
# dongle plugged in after boot must come up without a reboot. The rule
# deliberately does NOT match stock's literal text (no NAME="wlan0", RUN+=
# targets %k via an async helper instead of a blocking `ifup -a`) -- see the
# rule file's own header comment and docs/wifi-parity.md §9 for the verified
# reasoning. These checks assert the artifact ships correctly AND that the
# two deliberate divergences have not silently been "corrected" back toward
# stock's text (which would regress two-adapter support -- see §9).
HOTPLUG_RULE="etc/udev/rules.d/70-persistent-net.rules"
HOTPLUG_SCRIPT="etc/wifi-hotplug.sh"
require_present "$HOTPLUG_RULE" "70-persistent-net.rules"
require_present "$HOTPLUG_SCRIPT" "wifi-hotplug.sh"
if tar_has "$HOTPLUG_SCRIPT"; then
mode=$(tar tvf "$ROOTFS_TAR" -- "./$HOTPLUG_SCRIPT" 2>/dev/null | awk '{print $1; exit}')
case "$mode" in
-rwx*|-r-x*) pass "wifi-hotplug.sh executable ($mode)" ;;
*) fail "wifi-hotplug.sh executable" "mode is '$mode', not executable -- RUN+= execs it directly, udev does not go through a shell" ;;
esac
else
skip "wifi-hotplug.sh executable" "$HOTPLUG_SCRIPT missing (see above)"
fi
# The rule file's mode is asserted exactly, unlike the script's (which only
# has to be executable): udev must be able to READ it, and nothing should ever
# execute it. 644 is also what docs/wifi-parity.md §9 "What ships" promises,
# and an unasserted documented mode is how that promise silently rots.
if tar_has "$HOTPLUG_RULE"; then
mode=$(tar tvf "$ROOTFS_TAR" -- "./$HOTPLUG_RULE" 2>/dev/null | awk '{print $1; exit}')
case "$mode" in
-rw-r--r--) pass "70-persistent-net.rules mode 644 ($mode)" ;;
*) fail "70-persistent-net.rules mode 644" "mode is '$mode', expected '-rw-r--r--' -- see docs/wifi-parity.md §9" ;;
esac
else
skip "70-persistent-net.rules mode 644" "$HOTPLUG_RULE missing (see above)"
fi
if tar_has "$HOTPLUG_RULE"; then
# Comments stripped before any of the content checks below: the file's own
# header comment QUOTES stock's original rule verbatim (NAME="wlan0" and
# all) as part of explaining the divergence, which would otherwise false-
# positive the very regression guard this section exists to run. Only the
# active, uncommented directive lines are what actually ships as behavior.
rule_content="$WORKDIR/70-persistent-net.rules"
tar xOf "$ROOTFS_TAR" "./$HOTPLUG_RULE" 2>/dev/null | grep -v '^#' > "$rule_content"
if grep -q 'KERNEL=="wlan\*"' "$rule_content"; then
pass "70-persistent-net.rules matches KERNEL==\"wlan*\""
else
fail "70-persistent-net.rules matches KERNEL==\"wlan*\"" "no such match in the shipped rule"
fi
if grep -q 'RUN+="/etc/wifi-hotplug.sh up %k"' "$rule_content" \
&& grep -q 'RUN+="/etc/wifi-hotplug.sh down %k"' "$rule_content"; then
pass "70-persistent-net.rules RUN+= dispatches to wifi-hotplug.sh, targeted by %k"
else
fail "70-persistent-net.rules RUN+= dispatches to wifi-hotplug.sh, targeted by %k" \
"expected both 'RUN+=\"/etc/wifi-hotplug.sh up %k\"' and '... down %k' -- see $rule_content"
fi
# Regression guard: NAME="wlan0" would break this image's two-adapter
# support (auto wlan0 AND auto wlan1 in /etc/network/interfaces since
# P2.3) -- see the rule file's own comment and docs/wifi-parity.md §9,
# divergence 1, for why this is a deliberate, verified omission, not an
# oversight to "fix" back toward stock's literal text.
if grep -q 'NAME="wlan0"' "$rule_content"; then
fail "70-persistent-net.rules has NOT reintroduced NAME=\"wlan0\"" \
"found NAME=\"wlan0\" in the shipped rule -- this collapses wlan0/wlan1 to one name and breaks two-adapter support; see docs/wifi-parity.md §9"
else
pass "70-persistent-net.rules has NOT reintroduced stock's NAME=\"wlan0\" (two-adapter support preserved)"
fi
else
skip "70-persistent-net.rules content checks (KERNEL match, RUN+= target, NAME= regression guard)" "$HOTPLUG_RULE missing (see above)"
fi
# =============================================================================
section "T3 — addon.tar §3c closure (helpers, console/UX config, mc)"
# =============================================================================
# docs/stock-reconciliation.md §3c. The seven stock helper scripts are vendored
# BYTE-IDENTICAL from addon.tar (verified against work/imgroot at vendoring
# time); these checks pin presence, mode, and one content marker each -- the
# marker is the line whose absence would mean the file was quietly replaced
# with something other than the stock script (or that a "cleanup" broke the
# documented mechanism).
# -- executable helpers: path, +x, and a stock content marker ----------------
# name:marker (marker chosen from the script's load-bearing line)
for spec in \
"usr/bin/vhd_mount:losetup /dev/loop1" \
"usr/bin/m3u_play:mpg123 -@" \
"usr/bin/timidity:MC_EXT_SELECTED" \
"usr/sbin/vmode:/dev/MiSTer_cmd" \
"usr/sbin/uartmode:midilink MENU QUIET" \
"usr/sbin/btpair:btctl pair" \
"usr/sbin/btctl:org.bluez" \
"etc/jms583-phantom-guard.sh:152d" \
; do
f="${spec%%:*}"; marker="${spec#*:}"
if ! tar_has "$f"; then
fail "§3c helper $f present+executable+stock-marker" "$f not in rootfs.tar"
continue
fi
mode=$(tar tvf "$ROOTFS_TAR" -- "./$f" 2>/dev/null | awk '{print $1; exit}')
case "$mode" in
-rwx*) : ;;
*) fail "§3c helper $f present+executable+stock-marker" "mode is '$mode', not executable"; continue ;;
esac
if tar xOf "$ROOTFS_TAR" "./$f" 2>/dev/null | grep -qF "$marker"; then
pass "§3c helper $f present+executable+stock-marker"
else
fail "§3c helper $f present+executable+stock-marker" "marker '$marker' not found -- file is not the vendored stock script"
fi
done
# btctl must actually RUN on this image: it needs dbus-python + PyGObject
# (BR2_PACKAGE_DBUS_PYTHON / BR2_PACKAGE_PYTHON_GOBJECT -- the same bindings
# stock ships for its python3.9). Presence in the tar first, then a real
# import + a compile of the shipped script under qemu.
#
# MATCH .pyc, NOT .py. This defconfig sets BR2_PACKAGE_PYTHON3_PYC_ONLY=y, so
# target-finalize BYTE-COMPILES every module and DELETES the .py source --
# `site-packages/dbus/__init__.py` does not exist on this target and never
# will, while `__init__.pyc` does. An earlier revision asserted the .py and
# failed against a perfectly good build, with a message blaming a missing
# BR2_PACKAGE_* symbol that was in fact set. Both spellings are accepted below
# so the check keeps working if PYC_ONLY is ever turned off.
for sitepkg in "dbus:dbus-python" "gi:PyGObject (gi)"; do
sitepkg_dir=${sitepkg%%:*}
sitepkg_label=${sitepkg#*:}
if grep -qE "^\./usr/lib/python3\.[0-9]+/site-packages/$sitepkg_dir/__init__\.pyc?$" "$TAR_LIST"; then
pass "$sitepkg_label in site-packages (btctl runtime)"
else
fail "$sitepkg_label in site-packages (btctl runtime)" \
"no site-packages/$sitepkg_dir/__init__.py[c] in rootfs.tar -- package not installed at all (note PYC_ONLY means .pyc is the expected spelling)"
fi
done
if [ -z "$QEMU_ARM" ]; then
skip "btctl imports + compiles (dbus, dbus.mainloop.glib, GLib)" "qemu-arm not found on PATH"
elif [ ! -x "$TARGET/usr/bin/python3" ] || [ ! -f "$TARGET/usr/sbin/btctl" ]; then
skip "btctl imports + compiles (dbus, dbus.mainloop.glib, GLib)" "target python3 or usr/sbin/btctl not present in output/target"
else
btctl_out="$WORKDIR/btctl-imports.out"
# cfile= is MANDATORY here, not tidiness. py_compile.compile() with no
# cfile writes to importlib.util.cache_from_source(file) -- for an
# extension-less script that is
# $TARGET/usr/sbin/__pycache__/btctlcpython-314.pyc (no dot: rpartition
# ('.') finds none, so the stem and the cache tag concatenate). qemu_target
# is `qemu-arm -L $TARGET ...`; -L only redirects the ELF loader, so the
# path argument is a plain HOST path and that write really lands in
# output/target. Buildroot never wipes output/target between builds, so the
# next `make all` would tar a host-generated .pyc into rootfs.tar -- an
# unasserted binary in the image (G6), and dead weight besides (btctl is
# executed as a script, its __pycache__ is never consulted). A verification
# script must not mutate the tree it verifies: send it to $WORKDIR, which
# cleanup() rm -rf's on EXIT.
if qemu_target "$TARGET/usr/bin/python3" -c \
"import dbus, dbus.service, dbus.mainloop.glib; from gi.repository import GLib; import py_compile; py_compile.compile('$TARGET/usr/sbin/btctl', cfile='$WORKDIR/btctl.pyc', doraise=True)" \
>"$btctl_out" 2>&1; then
pass "btctl imports + compiles under target python (via qemu-arm)"
else
fail "btctl imports + compiles under target python" "$(tail -3 "$btctl_out" | tr '\n' ' ')"
fi
fi
# No host-generated bytecode anywhere in the image. This is a real leak path,
# not paranoia: .gitignore:9 hides __pycache__/ from `git status`, but the
# rootfs overlay is copied by rsync, not by git -- SYSTEM_RSYNC
# (work/buildroot/system/system.mk:64-68) passes only RSYNC_VCS_EXCLUSIONS
# (work/buildroot/Makefile:642-644: .svn/.git/.hg/.bzr/CVS) plus --exclude
# .empty --exclude '*~'. __pycache__ is on neither list, so a stray py_compile
# run inside board/.../rootfs-overlay/ (or, before the cfile= fix above, inside
# output/target/) ships an invisible, unreviewed binary blob to the target. Both
# routes were live and both are now closed; this asserts they stay closed.
# Scoped to /usr/sbin is NOT enough -- match anywhere except python's own
# /usr/lib/python3.N tree, which legitimately ships precompiled bytecode
# (BR2_PACKAGE_PYTHON3_PYC_ONLY / _PY_PYC, work/buildroot/package/python3/
# Config.in:32,35). Today that tree holds the ONLY __pycache__ in the image
# (site-packages/libmount/), verified against output/images/rootfs.tar.
stray_pyc=$(grep -E '/__pycache__/' "$TAR_LIST" | grep -vE '^\./usr/lib/python3\.[0-9]+/' || true)
if [ -z "$stray_pyc" ]; then
pass "no stray __pycache__ outside python3's stdlib"
else
fail "no stray __pycache__ outside python3's stdlib" "host bytecode in image: $(echo "$stray_pyc" | tr '\n' ' ')"
fi
# -- fluidsynth path difference, resolved both ways --------------------------
# Stock has /usr/sbin/fluidsynth (real ELF); the fluidsynth package installs
# /usr/bin/fluidsynth. No shipped caller uses the absolute stock path
# (midilink: PATH `fluidsynth`; timidity wrapper: PATH; uartmode: killall by
# name; Main_MiSTer: no fluidsynth reference at all -- all verified), but
# third-party user scripts may hardcode stock's path, so a compat symlink
# closes the difference outright.
require_present "usr/bin/fluidsynth" "fluidsynth binary (package path)"
if tar_has "usr/sbin/fluidsynth"; then
fs_link=$(tar tvf "$ROOTFS_TAR" -- "./usr/sbin/fluidsynth" 2>/dev/null | awk '{print $NF; exit}')
if [ "$fs_link" = "/usr/bin/fluidsynth" ]; then
pass "usr/sbin/fluidsynth compat symlink -> /usr/bin/fluidsynth (stock path resolves)"
else
fail "usr/sbin/fluidsynth compat symlink" "points at '$fs_link', expected /usr/bin/fluidsynth"
fi
else
fail "usr/sbin/fluidsynth compat symlink" "not in rootfs.tar -- stock's absolute path would dangle"
fi
# -- console/audio config ----------------------------------------------------
# asound.conf routes the ALSA default pcm into /dev/MrAudio (the in-kernel
# MiSTer SPI audio ring, CONFIG_SND_MISTER_AUDIO=y creates the device node --
# sound/drivers/MiSTer-audio-spi.c) so mpg123/aplay/fluidsynth are audible
# through the core's HDMI/analog output.
#
# NOT because hw:0 is missing -- hw:0 exists and MUST exist. MiSTer-audio-spi
# is a chardev SPI driver, not an ALSA driver (no card, no PCM), so the only
# ALSA card on this board is the patched snd-dummy: CONFIG_SND_DUMMY=y
# (board/mister/de10nano/linux.config:391, built in, enable[0]=1 at
# sound/drivers/dummy.c:51) registers it as card 0, and asound.conf's own
# innermost slave is literally `type hw; card 0` -- the `type file` plugin
# DUPLICATES the stream, so card 0 must accept S16_LE/48000/2ch or the whole
# default pcm fails to open (docs/abi-contract.md sec 8.2(a), 8.2(c)).
# The real failure mode WITHOUT this file: ALSA's default resolves to that
# dummy card, snd-dummy discards the samples and the system is silently mute
# (docs/phase0-review.md:128, "omit it and the system is silent").
if tar_has "etc/asound.conf" && tar xOf "$ROOTFS_TAR" ./etc/asound.conf 2>/dev/null | grep -qF '/dev/MrAudio'; then
pass "etc/asound.conf present, targets /dev/MrAudio"
else
fail "etc/asound.conf present, targets /dev/MrAudio" "missing, or no /dev/MrAudio route"
fi
# kbd.map blanks VC keycodes 88/113/114/115 (F12/Mute/Vol-/Vol+) -- the keys
# Main_MiSTer consumes via evdev; loading it stops the framebuffer console
# double-acting on them. Loaded by the guarded inittab line iff kbd's loadkeys
# ships (T5); the map itself is stock-identical and harmless alone.
if tar_has "etc/kbd.map" && tar xOf "$ROOTFS_TAR" ./etc/kbd.map 2>/dev/null | grep -qF 'keycode 88 ='; then
pass "etc/kbd.map present, blanks keycode 88 (F12)"
else
fail "etc/kbd.map present, blanks keycode 88 (F12)" "missing, or not the stock map"
fi
if tar xOf "$ROOTFS_TAR" ./etc/inittab 2>/dev/null | grep -qF '/usr/bin/loadkeys /etc/kbd.map'; then
pass "inittab loads kbd.map (guarded loadkeys line)"
else
fail "inittab loads kbd.map (guarded loadkeys line)" "no loadkeys line in etc/inittab"
fi
# -- JMS583 phantom-LUN guard ------------------------------------------------
JMS_RULE="etc/udev/rules.d/60-jms583-phantom.rules"
if tar_has "$JMS_RULE" && tar xOf "$ROOTFS_TAR" "./$JMS_RULE" 2>/dev/null \
| grep -qF 'ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0583"'; then
pass "60-jms583-phantom.rules present, matches JMS583 (152d:0583)"
else
fail "60-jms583-phantom.rules present, matches JMS583 (152d:0583)" "missing or wrong match"
fi
# -- vhd_mount's mount point -------------------------------------------------
# vhd_mount mounts /dev/loop1p1 on /media/rootfs; "/" is read-only at runtime,
# so the directory must ship in the image (same .gitkeep idiom as /media/fat).
if grep -qE '^\./media/rootfs/$' "$TAR_LIST"; then
pass "/media/rootfs mount point ships in the image"
else
fail "/media/rootfs mount point ships in the image" "vhd_mount has nowhere to mount on the read-only root"
fi
# -- mc (file manager + the MiSTer launcher wiring) --------------------------
require_present "usr/bin/mc" "mc binary"
require_present "usr/bin/memtool" "memtool (pengutronix, stock's usr/bin/memtool)"
# addon.tar's argv[0]/alias symlinks (memtool.c:475 dispatches on basename;
# `play` is what mc's stock sound.sh execs for au/voc/snd). Targets must not
# dangle: memtool from the package above, aplay from alsa-utils.
for spec in "usr/bin/md:memtool" "usr/bin/mw:memtool" "usr/bin/play:aplay"; do
f="${spec%%:*}"; want="${spec#*:}"
if ! tar_has "$f"; then
fail "$f symlink -> $want" "not in rootfs.tar"
continue
fi
got=$(tar tvf "$ROOTFS_TAR" -- "./$f" 2>/dev/null | awk '{print $NF; exit}')
if [ "$got" = "$want" ]; then
pass "$f symlink -> $want"
else
fail "$f symlink -> $want" "points at '$got'"
fi
done
require_present "usr/share/mc/skins/MiSTer.ini" "mc MiSTer skin"
if tar_has "root/.config/mc/ini" && tar xOf "$ROOTFS_TAR" ./root/.config/mc/ini 2>/dev/null | grep -qx 'skin=MiSTer'; then
pass "root mc config selects the MiSTer skin"
else