summaryrefslogtreecommitdiff
path: root/test/resettest.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/resettest.sh')
-rwxr-xr-xtest/resettest.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/resettest.sh b/test/resettest.sh
new file mode 100755
index 0000000..b0cb9e1
--- /dev/null
+++ b/test/resettest.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Register for with radio-reset-monitor to
+# get a signal when radio-reset occurs.
+# Child process exists so the parent
+# does not need to worry about resets
+# starting before it can get through
+# checks, and possibly sleeping forever.
+# pgrep was needed to kill the sleep.
+# wait is called to wait for the SIGUSR1 signal.
+# The child never terminates.
+# The hope is that the parent will fall into wait
+# before the child registers for the radio-reset.
+# checking for do_wait is risky if the kernel ever
+# changes. The child will exit if the reset is not
+# in process.
+#
+
+USR1=10
+TERM=15
+function sleep_reset
+{
+ # Wait for parent to enter wait.
+ trap "kill $!;kill $BASHPID" $TERM
+ while [[ $(ps -h -o wchan -p $PPID) != do_wait ]] ; do usleep 100 ; done
+ echo Register parent for SIGUSR1
+ echo "$$" "$USR1" >/sys/devices/platform/mts-io/radio-reset-monitor
+ discovered=$(cat /sys/devices/platform/mts-io/radio-udev-discovery)
+ if ((discovered == 1)) ; then
+ # reset is not in progress.
+ exit 0
+ fi
+ sleep 4294967295 # Hopefully forever
+ exit 0
+}
+
+date
+trap ":" $USR1
+in_reset=$(cat /sys/devices/platform/mts-io/radio-udev-discovery)
+if ((in_reset == 0)) ; then
+ sleep_reset &
+ wait $!
+ # pgrep is needed to find the sleep process
+ pgrep -P $! | xargs kill
+fi
+echo Radio Reset is done.
+date