#!/bin/sh
# DF-5091 runtime trigger: demonstrate that the ACPI notify/fixed-event
# handlers registered by acpi_button_attach() (context = softc) can never
# be torn down, and that no unload/detach path reaches them today.
#
# Run as root on the DragonFly guest. Safe: read-only probes + a failing
# kldunload. Expected outcome (see run.log):
#   - acpi_button driver registered in the (builtin) kernel
#   - NO acpi_button device instance attached on this guest (buttons are
#     handled by acpi.c's own fixed-event handlers, acpi.c:1978-1993)
#   - no acpi.ko module exists -> kldunload cannot reach the driver
#   - guest stays up, no fault

echo "== uname =="
uname -a
echo
echo "== kldstat (module table) =="
kldstat
echo
echo "== acpi_button driver registered? =="
kldstat -v 2>/dev/null | grep -i button
echo
echo "== acpi_button device attached? (dmesg) =="
dmesg | grep -i "acpi_button"
echo "rc=$? (1 = no acpi_button device instance)"
dmesg | grep -i "button"
echo
echo "== button sysctls (owned by acpi.c, not acpi_button.c) =="
sysctl -N -a | grep -i button
echo
echo "== attempt to unload the code owning the handlers =="
kldunload acpi
echo "kldunload acpi rc=$?"
kldunload -a
echo "kldunload -a rc=$?"
echo
echo "== guest still alive =="
uptime
