From 91de6c8d8b1f6134f702b078401237df2b442bcc Mon Sep 17 00:00:00 2001 From: Serhii Voloshynov Date: Wed, 8 Jun 2022 15:42:59 +0300 Subject: add test-reset script allowing to test the reset button by TeraTerm script without rebooting --- recipes-production/mfg-tests/test-reset.sh | 76 ++++++++++++++++++++++++++++++ recipes-production/mfg-tests_1.0.bb | 16 +++++++ 2 files changed, 92 insertions(+) create mode 100755 recipes-production/mfg-tests/test-reset.sh create mode 100644 recipes-production/mfg-tests_1.0.bb 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 +# ..... +# echo $? +# 0 +# #test-reset 60 +# ..... +# 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 " + 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 +} -- cgit v1.2.3