#!/bin/sh
# DF-4647 FIX VALIDATION: same rig as df4647final.sh but with the FIXED
# module (detach takes the fujitsu ACPI serial).  Expected: kldunload
# blocks until B's handler has completed -> B completes NORMALLY (rc=0,
# real value written), no use-after-free, no ENOENT for B.
L=/root/df4647_fixrun.log
: > $L
ts() { date +%s; }
kldload /root/acpi_fujitsu_fixed.ko
sleep 1
echo "T0=$(ts)" >> $L
( echo "A_START=$(ts)" >> $L; sysctl -w hw.acpi.fujitsu.volume=7 > /root/A.log 2>&1; echo "A_DONE=$(ts) rc=$?" >> $L ) &
sleep 1
( echo "B_START=$(ts)" >> $L; sysctl -w hw.acpi.fujitsu.lcd_brightness=5 > /root/B.log 2>&1; echo "B_DONE=$(ts) rc=$?" >> $L ) &
sleep 1
echo "T_UNLOAD_START=$(ts)" >> $L
kldunload acpi_fujitsu_fixed.ko >> $L 2>&1
echo "T_UNLOAD_DONE=$(ts) rc=$? gone=$(kldstat | grep -c fujitsu)" >> $L
sleep 4
echo "A: $(tail -1 /root/A.log)" >> $L
echo "B: $(tail -1 /root/B.log)" >> $L
echo "T_END=$(ts)" >> $L
cat $L
