#!/bin/sh
# DF-0813 run: set up a hammer2 mount (root) and drive churn (unprivileged).
# This must be run in two stages:
#   1. root:  sudo sh setup_h2.sh        # create+newfs+mount hammer2 image
#   2. user:  H2DIR=/mnt/h2 ./run.sh     # drive the churn stress harness
#
# Expected (bug present): a kernel panic (NULL deref in hammer2_flush /
#   hammer2_chain_ref) under heavy concurrent flush+unlink churn.
#   The race is tight — it may require many minutes of churn to win.
# Expected (bug fixed): harness completes with no panic; guest stays up.
set -e
cd "$(dirname "$0")"
DIR="${H2DIR:-/mnt/h2}"
SECS="${SECS:-120}"
echo "DF-0813: driving hammer2 flush churn on $DIR for ${SECS}s"
echo "(run as unprivileged user with write access to a hammer2 mount)"
H2DIR="$DIR" NW=12 NS=4 SECS="$SECS" ./dirstress_h2
H2DIR="$DIR" NIO=10 NSYNC=3 SECS=60 ./churn_h2
echo "RUN_DONE (check dmesg/boot.log for panic)"
