Files
makronix/mobile/tools/reboot-loop.sh
T
lotherkandClaude Sonnet 5.5 73c9de51a6 licence: the CNCL line in every file Makronix wrote (tools, docs, www, mobile, top level)
consmirror.c: the BSD notice is replaced (Makronix's own file).  Files with
changes of other sessions pending are left for their commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 11:50:26 +00:00

53 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
#
# Warm-reboot a running phone N times (sysrq b) and count the boots that do
# not come back: a test for boot races. Each round waits up to WAIT
# seconds (default 90) for ssh -- at the phone's IPv4 address or, when the
# host has lost its IPv4 on the USB link, at its IPv6 link-local address
# (phone_addr, tools/lib.sh), so a missing host address is not taken for a
# hang. Stops at the first boot that answers neither: an unreachable phone
# cannot be rebooted. With netconsole running (tools/netconsole-listen.sh
# LOG), each line names the LOG lines of its boot.
#
# Usage: reboot-loop.sh [N] [LOG]
set -u
. "$(dirname "$0")/lib.sh"
n=${1:-10}
log=${2:-}
wait=${WAIT:-90}
lines() {
if [ -n "$log" ] && [ -f "$log" ]; then
wc -l < "$log" | tr -d ' '
else
echo 0
fi
}
a=$(phone_addr) || die "phone not reachable"
hangs=0 i=1
while [ "$i" -le "$n" ]; do
start=$(lines)
phone_ssh "$a" 'sync; echo b > /proc/sysrq-trigger' >/dev/null 2>&1
sleep 15
t=0
while ! a=$(phone_addr) && [ "$t" -lt "$wait" ]; do
sleep 3
t=$((t + 3))
done
if [ -z "$a" ]; then
hangs=1
echo "run $i: NOT REACHABLE (log lines from $start)"
break
fi
echo "run $i: up at $a (log lines $start-$(lines))"
sleep 5
i=$((i + 1))
done
[ "$i" -gt "$n" ] && i=$n
echo "$i runs, $hangs not reachable"
[ "$hangs" -eq 0 ]