#!/bin/sh
# DF-3029 run: mount the normal daemon, then hammer random-offset reads
# from 8 threads for 240s watching for a total progress stall (lost wakeup).
set -e
cd "$(dirname "$0")"
MNT=/mnt/fuse
kldstat -n fuse >/dev/null 2>&1 || kldload fuse
mkdir -p $MNT
./fuse_daemon normal $MNT > daemon.log 2>&1 &
sleep 3
mount | grep -q "$MNT" || { echo MOUNT_MISSING; cat daemon.log; exit 1; }
chmod 755 $MNT
echo "=== warm the file (8MB read as maxx) ==="
su -m maxx -c "cat $MNT/target > /dev/null" || true
echo "=== lost-wakeup stress (8 threads x 240s) ==="
su -m maxx -c "./lostwakeup $MNT/target 8 240"; rc=$?
echo "stress rc=$rc (3 = STALL_DETECTED, 0 = no stall)"
