mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-06 16:02:55 +00:00
mu300-led: a siren the pid file does not name stops by itself
CI caught two sirens flashing together (white lit throughout, red and blue at once): one left running by an earlier alarm kept writing next to the new one. The same could follow a restarted thermal-guard on a device. The siren now checks the pid file every round and ends when it names another process or, after the first round, nothing. Test: a stale siren stops. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeuDBrAce8rrgSJDbFJQGN
This commit is contained in:
1 parent
9e60666858
commit
1a69a41ea9
2 files changed
+30
No files matched your search
@@ -116,7 +116,15 @@ case "$1 ${2:-}" in
|
||||
for l in $SIREN; do write "$l" 0; done
|
||||
if awake; then show_all; fi ;; # the U30 Air's white is its power LED, the F50's blue its data LED
|
||||
"siren "*) # (alarm on runs this in the background)
|
||||
# Only the siren named in the pid file runs: one left behind (its alarm switched off while it was
|
||||
# between writes, a restarted service) stops by itself instead of flashing along with the new one.
|
||||
# The file is written just after the start, so a missing one counts only after the first round.
|
||||
n=0
|
||||
while :; do
|
||||
own=$(cat "$SIREN_PID" 2>/dev/null)
|
||||
if [ -n "$own" ]; then [ "$own" = $$ ] || exit 0
|
||||
elif [ $n -gt 0 ]; then exit 0; fi
|
||||
n=$((n + 1))
|
||||
for on in $SIREN; do
|
||||
for l in $SIREN; do [ "$l" = "$on" ] || write "$l" 0; done
|
||||
write "$on" 1; nap 0.25
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Small device scripts, against a fake / (MU300_SYSROOT) and stub commands: mu300-device, mu300-lan-ip, mu300-led,
|
||||
mu300-ttl. They run on Ubuntu (dash, bash) and OpenWrt (busybox ash)."""
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import unittest
|
||||
@@ -177,6 +178,27 @@ class Led(ShellTest):
|
||||
self.led(shell, 'f50', 'data', '5g') # one LED: blue on 5G too
|
||||
self.assertEqual(self.state()['sc27xx:blue'], '255')
|
||||
|
||||
def test_stale_siren_stops(self):
|
||||
# a siren the pid file does not name (left behind by a restart) stops by itself: two of them flashed
|
||||
# together, white lit throughout
|
||||
for shell in self.each_shell():
|
||||
self.reset()
|
||||
pid = self.root / 'run/mu300/led-siren.pid'
|
||||
self.led(shell, 'u30air', 'alarm', 'on')
|
||||
p = int(pid.read_text())
|
||||
pid.write_text('1\n') # someone else's now
|
||||
deadline = time.time() + 3
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
os.kill(p, 0)
|
||||
except ProcessLookupError:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
os.kill(p, 15)
|
||||
self.fail('the stale siren kept running')
|
||||
pid.unlink()
|
||||
|
||||
def test_vendor_ldo_switches_on_5_4(self):
|
||||
# the 5.4 kernel has no zte-ldoN LEDs: ZTE's zte_ldo_leds switches the same LDOs through vddcamaN_status
|
||||
for shell in self.each_shell():
|
||||
|
||||
Reference in new issue
Block a user