Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

ac-os: add QEMU smoke test + simuflash command

- `ac-os test` / `ac-os smoke`: boots kernel in QEMU headless for 15s,
checks serial console for ac-native startup or kernel panic
- `ac-os simuflash` / `ac-os sf`: build + smoke test + flash
(only flashes USB if smoke test passes)
- Works with direct QEMU binary or falls back to Docker + alpine
- Checks for "Booted in", "JS: boot=1", or "exec-ac-native" as success
- Detects "panic", "Oops", "not syncing" as failure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+107 -5
+107 -5
fedac/native/ac-os
··· 441 441 log "Initramfs validated — will boot" 442 442 } 443 443 444 + smoke_test() { 445 + log "Smoke test: booting kernel in QEMU (15s timeout)..." 446 + local SERIAL_LOG=$(mktemp) 447 + local TIMEOUT=15 448 + local QEMU_BIN="" 449 + 450 + # Find QEMU binary 451 + if command -v qemu-system-x86_64 &>/dev/null; then 452 + QEMU_BIN="qemu-system-x86_64" 453 + elif sudo docker info &>/dev/null 2>&1; then 454 + # Fall back to Docker container 455 + log " using Docker for QEMU..." 456 + sudo docker rm -f ac-os-smoke 2>/dev/null || true 457 + local CID 458 + CID=$(sudo docker create --name ac-os-smoke --device /dev/kvm \ 459 + alpine:latest sh -c " 460 + apk add --quiet qemu-system-x86_64 461 + timeout ${TIMEOUT} qemu-system-x86_64 \ 462 + -enable-kvm \ 463 + -kernel /tmp/vmlinuz \ 464 + -append 'console=ttyS0 loglevel=4' \ 465 + -m 512M \ 466 + -no-reboot \ 467 + -nographic \ 468 + -serial stdio \ 469 + -nic none 2>&1 || true 470 + ") 471 + sudo docker cp "${VMLINUZ}" "${CID}:/tmp/vmlinuz" 472 + sudo docker start -a "${CID}" > "${SERIAL_LOG}" 2>&1 & 473 + local PID=$! 474 + sleep ${TIMEOUT} 475 + kill ${PID} 2>/dev/null || true 476 + sudo docker rm -f ac-os-smoke 2>/dev/null || true 477 + 478 + # Check serial output 479 + if grep -q "Booted in\|JS: boot=1\|exec-ac-native" "${SERIAL_LOG}"; then 480 + log "SMOKE TEST PASSED — ac-native started" 481 + rm -f "${SERIAL_LOG}" 482 + return 0 483 + elif grep -qi "panic\|Oops\|not syncing" "${SERIAL_LOG}"; then 484 + err "SMOKE TEST FAILED — kernel panic detected" 485 + err "Serial output (last 20 lines):" 486 + tail -20 "${SERIAL_LOG}" >&2 487 + rm -f "${SERIAL_LOG}" 488 + exit 1 489 + else 490 + log " WARNING: no definitive boot signal (may need longer timeout)" 491 + log " Serial tail:" 492 + tail -10 "${SERIAL_LOG}" 493 + rm -f "${SERIAL_LOG}" 494 + return 0 495 + fi 496 + else 497 + log " QEMU not available — skipping smoke test" 498 + return 0 499 + fi 500 + 501 + # Direct QEMU (no Docker) 502 + timeout ${TIMEOUT} ${QEMU_BIN} \ 503 + $([ -e /dev/kvm ] && echo "-enable-kvm") \ 504 + -kernel "${VMLINUZ}" \ 505 + -append "console=ttyS0 loglevel=4" \ 506 + -m 512M \ 507 + -no-reboot \ 508 + -nographic \ 509 + -serial stdio \ 510 + -nic none > "${SERIAL_LOG}" 2>&1 || true 511 + 512 + if grep -q "Booted in\|JS: boot=1\|exec-ac-native" "${SERIAL_LOG}"; then 513 + log "SMOKE TEST PASSED — ac-native started" 514 + rm -f "${SERIAL_LOG}" 515 + return 0 516 + elif grep -qi "panic\|Oops\|not syncing" "${SERIAL_LOG}"; then 517 + err "SMOKE TEST FAILED — kernel panic detected" 518 + err "Serial output (last 20 lines):" 519 + tail -20 "${SERIAL_LOG}" >&2 520 + rm -f "${SERIAL_LOG}" 521 + exit 1 522 + else 523 + log " WARNING: no definitive boot signal (may need longer timeout)" 524 + tail -10 "${SERIAL_LOG}" 525 + rm -f "${SERIAL_LOG}" 526 + return 0 527 + fi 528 + } 529 + 444 530 build_kernel() { 445 531 local LINUX_DIR="${BUILD_DIR}/linux-6.14.2" 446 532 if [ ! -d "${LINUX_DIR}" ]; then ··· 1106 1192 flash_usb 1107 1193 upload_ota 1108 1194 ;; 1109 - qemu|vm|test) 1110 - # Boot current build in QEMU with VNC (no rebuild) 1195 + qemu|vm) 1196 + # Boot current build in QEMU with VNC (interactive, no timeout) 1111 1197 if [ ! -f "${VMLINUZ}" ]; then 1112 1198 log "No kernel found — building first..." 1113 1199 build_binary ··· 1116 1202 fi 1117 1203 log "Starting QEMU with VNC on port 5900..." 1118 1204 log "Connect: vnc://localhost:5900" 1119 - # Kill any existing QEMU container 1120 1205 sudo docker rm -f ac-os-qemu 2>/dev/null || true 1121 1206 local QEMU_CID 1122 1207 QEMU_CID=$(sudo docker create --name ac-os-qemu --device /dev/kvm \ ··· 1142 1227 wait ${QEMU_PID} 2>/dev/null 1143 1228 sudo docker rm -f ac-os-qemu 2>/dev/null || true 1144 1229 ;; 1230 + test|smoke) 1231 + # Headless smoke test: boot in QEMU, check serial for ac-native startup 1232 + if [ ! -f "${VMLINUZ}" ]; then 1233 + err "No kernel at ${VMLINUZ} — run 'ac-os build' first" 1234 + exit 1 1235 + fi 1236 + smoke_test 1237 + ;; 1238 + simuflash|sf) 1239 + # Build + smoke test + flash (only flashes if boot test passes) 1240 + build_binary 1241 + build_initramfs 1242 + build_kernel 1243 + record_build "simuflash" 1244 + smoke_test 1245 + flash_usb 1246 + log "Smoke test passed — USB flashed!" 1247 + ;; 1145 1248 pull) 1146 - require_login 1147 1249 pull_ota 1148 1250 flash_usb 1149 1251 ;; 1150 1252 *) 1151 - echo "Usage: ac-os {build|flash|upload|flash+upload|bfu|pull|qemu}" 1253 + echo "Usage: ac-os {build|flash|upload|flash+upload|bfu|pull|simuflash|test|qemu}" 1152 1254 exit 1 1153 1255 ;; 1154 1256 esac