aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / tests / omegallm / efi-ident.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: AGPL-3.0-only |
| 3 | # Identity-line edge cases for the ollm UEFI build (CONTRACT section 9): boot EFI under QEMU/OVMF with |
| 4 | # a one-job JOB.TXT (adamck) and check the second OUT.TXT line for a CPUID brand string of only NULs |
| 5 | # or only blanks and for SMBIOS type 1 strings or structures that end before what eio.om reads. |
| 6 | # EMULATED evidence only: this is not the iMac. |
| 7 | # Usage: sh tests/omegallm/efi-ident.sh EFI OUTDIR |
| 8 | # Env: IMAC_IMAGE (required; see efi-image.sh), CORES (taskset list for QEMU, default 6). |
| 9 | # Cases (the SMBIOS ones on machine q35,smbios-entry-point-type=64 with one raw -smbios file, which |
| 10 | # QEMU puts first; it adds no type 1 of its own when the file starts with one): |
| 11 | # nul -cpu max,model-id= (brand all NULs) cpu=- |
| 12 | # blank -cpu max,model-id=<48 blanks> cpu=- |
| 13 | # n2 type 1 whose Version names string 3 of a one-string set smbios=OmegaTest/-/- |
| 14 | # capwalk type 1 Version 255 followed by 2 x 100 strings of 60 bytes smbios=OmegaTest/-/- |
| 15 | # capscan 5 x type 11 with 255 strings (77805 bytes), no type 1 under the 64 KiB copy smbios=-/-/- |
| 16 | # A case passes when the console shows OLLM DONE and no trap (`failed to start ...: 00000067`) and |
| 17 | # OUT.TXT's second line starts `ID ` and contains the wanted field. OUTDIR/summary.tsv has one row |
| 18 | # per case (case, want, got, verdict); OUTDIR/CASE/ keeps serial.log, qemu.txt and vol/OUT.TXT. |
| 19 | # Exits 1 if any case fails. |
| 20 | set -u |
| 21 | [ $# -eq 2 ] || { echo "usage: efi-ident.sh EFI OUTDIR" >&2; exit 2; } |
| 22 | EFI=$1 O=$2 |
| 23 | t=$(cd "$(dirname "$0")" && pwd) |
| 24 | mkdir -p "$O" |
| 25 | w=$(mktemp -d "${TMPDIR:-/tmp}/efi-ident.XXXXXX") |
| 26 | trap 'rm -rf "$w"' EXIT |
| 27 | printf 'adamck\n' > "$w/job.txt" |
| 28 | sh "$t/efi-image.sh" "$EFI" "$w/img" "$w/job.txt:JOB.TXT" > "$O/image.txt" || { echo "efi-image failed" >&2; exit 1; } |
| 29 | o8() { printf "\\$(printf %03o "$1")"; } |
| 30 | # t1 VER: type 1, handle 0x0100, Manufacturer 1, Product 2, Version VER, one string "OmegaTest". |
| 31 | t1() { printf '\001\033\000\001\001\002'; o8 "$1"; printf '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\000\000OmegaTest\000\000'; } |
| 32 | # t11 H N: type 11 (OEM strings), handle 0x0B00+H, N strings of 60 characters. |
| 33 | t11() { |
| 34 | printf '\013\005'; o8 "$1"; printf '\013'; o8 "$2" |
| 35 | s=$(printf '%060d' 0) i=0 |
| 36 | while [ "$i" -lt "$2" ]; do printf '%s\000' "$s"; i=$((i + 1)); done |
| 37 | printf '\000' |
| 38 | } |
| 39 | t1 3 > "$w/n2.bin" |
| 40 | { t1 255; t11 1 100; t11 2 100; } > "$w/capwalk.bin" |
| 41 | { for h in 1 2 3 4 5; do t11 "$h" 255; done; } > "$w/capscan.bin" |
| 42 | for b in n2 capwalk capscan; do echo "blob: $(sha256sum "$w/$b.bin" | cut -d' ' -f1) $b.bin ($(wc -c < "$w/$b.bin") bytes)"; done > "$O/blobs.txt" |
| 43 | printf 'case\twant\tgot\tverdict\n' > "$O/summary.tsv" |
| 44 | fail=0 |
| 45 | run() { # case want machine cpu smbios |
| 46 | c=$1 want=$2; d=$O/$c |
| 47 | QEMU_MACHINE=$3 QEMU_CPU=$4 QEMU_SMBIOS=$5 sh "$t/efi-qemu.sh" "$w/img" "$d" 600 > "$d.qemu.txt" 2>&1 |
| 48 | mkdir -p "$d"; mv "$d.qemu.txt" "$d/qemu.txt" |
| 49 | if tr -d '\r' < "$d/serial.log" | grep -aq 'failed to start .*: 00000067'; then got=trap3 |
| 50 | elif ! grep -q '^done=1' "$d/qemu.txt"; then got=no-done |
| 51 | else got=$(sed -n 2p "$d/vol/OUT.TXT"); fi |
| 52 | case $got in "ID "*"$want"*) v=PASS ;; *) v=FAIL; fail=1 ;; esac |
| 53 | printf '%s\t%s\t%s\t%s\n' "$c" "$want" "$got" "$v" >> "$O/summary.tsv" |
| 54 | echo "$v $c: $got" |
| 55 | } |
| 56 | run nul 'cpu=- ' q35 'max,model-id=' '' |
| 57 | run blank 'cpu=- ' q35 "max,model-id=$(printf '%48s' '')" '' |
| 58 | run n2 'smbios=OmegaTest/-/-' q35,smbios-entry-point-type=64 max "file=$w/n2.bin" |
| 59 | run capwalk 'smbios=OmegaTest/-/-' q35,smbios-entry-point-type=64 max "file=$w/capwalk.bin" |
| 60 | run capscan 'smbios=-/-/-' q35,smbios-entry-point-type=64 max "file=$w/capscan.bin" |
| 61 | [ "$fail" = 0 ] |