summaryrefslogtreecommitdiff
path: root/recipes-production/mfg-tests
diff options
context:
space:
mode:
authorSerhii Voloshynov <serhii.voloshynov@globallogic.com>2022-06-08 15:42:59 +0300
committerJohn Klug <john.klug@multitech.com>2022-06-08 09:38:28 -0500
commit91de6c8d8b1f6134f702b078401237df2b442bcc (patch)
treeb564cb0271cc84fa0e4668ba4ab6b7b3c5207590 /recipes-production/mfg-tests
parentee0c03b180b77fcad3ffb701a76dd1a1e08268f7 (diff)
downloadmeta-mlinux-91de6c8d8b1f6134f702b078401237df2b442bcc.tar.gz
meta-mlinux-91de6c8d8b1f6134f702b078401237df2b442bcc.tar.bz2
meta-mlinux-91de6c8d8b1f6134f702b078401237df2b442bcc.zip
add test-reset script allowing to test the reset button by TeraTerm script without rebooting
Diffstat (limited to 'recipes-production/mfg-tests')
-rwxr-xr-xrecipes-production/mfg-tests/test-reset.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/recipes-production/mfg-tests/test-reset.sh b/recipes-production/mfg-tests/test-reset.sh
new file mode 100755
index 0000000..74474a1
--- /dev/null
+++ b/recipes-production/mfg-tests/test-reset.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+#the script disables main reset-handler and it allows to test the reset button
+# #test-reset 60
+# .....<user has pressed the reset button>
+# echo $?
+# 0
+# #test-reset 60
+# .....<user has not pressed the reset button>
+# echo $?
+# 2
+# in this example script is waiting for reset button pressing with 60 seconds timeout.
+# if the button was pressed, the script stops and returns '0' return code.
+# if the reset button was not pressed, the script returns '2'
+
+log="logger -t $name -s"
+name=$0
+pid="$$"
+
+if (($(id -u) != 0)); then
+ echo "You must be root to do a reset test"
+ exit 1
+fi
+
+if [ "$#" -ne 1 ]; then
+ echo "Illegal usage."
+ echo "Usage: $name <timeout>"
+ exit 1
+fi
+
+timeout=$1
+
+short_signal=10 # SIGUSR1
+long_signal=12 # SIGUSR2
+extralong_signal=1 # SIGHUP
+
+do_disable_reset_handler() {
+ #stop main reset handler
+ /etc/init.d/reset-handler stop >/dev/null 2>&1
+}
+
+do_restore_reset_handler() {
+ #restore main reset handler
+ /etc/init.d/reset-handler start >/dev/null 2>&1
+}
+
+do_press_reset() {
+ $log "reset pressed"
+ sleep 1 #it will protect if a user make 'double-click'
+ do_restore_reset_handler
+ exit 0
+}
+
+do_exit() {
+ do_restore_reset_handler
+ $log "Exiting on SIGTERM"
+ exit 2
+}
+
+trap do_press_reset $short_signal
+trap do_press_reset $long_signal
+trap do_press_reset $extralong_signal
+trap do_exit TERM
+trap do_exit SIGINT
+
+do_disable_reset_handler
+
+$log "Enabling reset-monitor for pid $pid"
+mts-io-sysfs store reset-monitor "$pid $short_signal $long_signal $extralong_signal"
+# set long press to 5 seconds for reset to defaults
+mts-io-sysfs store reset-monitor-intervals "5 30"
+
+sleep $timeout &
+wait
+
+do_restore_reset_handler
+exit 2 \ No newline at end of file