summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrecipes-production/mfg-tests/test-reset.sh76
-rw-r--r--recipes-production/mfg-tests_1.0.bb16
2 files changed, 92 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
diff --git a/recipes-production/mfg-tests_1.0.bb b/recipes-production/mfg-tests_1.0.bb
new file mode 100644
index 0000000..3827551
--- /dev/null
+++ b/recipes-production/mfg-tests_1.0.bb
@@ -0,0 +1,16 @@
+DESCRIPTION = "Reset button test script"
+SECTION = "base"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+PR = "r1"
+RDEPENDS_${PN} += "bash"
+
+
+SRC_URI = "\
+ file://test-reset.sh \
+"
+
+do_install () {
+ install -d ${D}${sbindir}
+ install -m 0755 ${WORKDIR}/test-reset.sh ${D}${sbindir}/test-reset
+}