#!/bin/sh
# DF-0916 run script - exercises both the buggy and the fixed-algorithm
# demonstrators with three representative inputs and prints the
# before/after contrast.
#
#   tv_sec=0          - sane value, should terminate instantly in both.
#   tv_sec=INT64_MAX  - malicious, drives the buggy loop into livelock.
#   tv_sec=-1         - reinterpreted as u_long = UINT64_MAX; worse case.
#
# The buggy binary is given a 5e8-iteration cap so the harness cannot
# livelock the test machine; the kernel has no such cap.
# (No `set -e`: the buggy binary intentionally returns non-zero on livelock.)
cd "$(dirname "$0")"
echo "############ DF-0916 smb_time_unix2dos livelock - BEFORE (buggy) ############"
echo "### tv_sec=0 (sane)"
./trigger 0
echo
echo "### tv_sec=INT64_MAX (9223372036854775807)"
./trigger 9223372036854775807
echo
echo "### tv_sec=-1 (reinterpreted u_long = UINT64_MAX)"
./trigger -1
echo
echo "############ DF-0916 smb_time_unix2dos livelock - AFTER (fixed) ############"
echo "### tv_sec=0 (sane)"
./trigger_fixed 0
echo
echo "### tv_sec=INT64_MAX (9223372036854775807)"
./trigger_fixed 9223372036854775807
echo
echo "### tv_sec=-1 (reinterpreted u_long = UINT64_MAX)"
./trigger_fixed -1
