summaryrefslogtreecommitdiff
path: root/scripts/contrib/dialog-power-control
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-04-30 13:32:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-04-30 21:52:12 +0100
commitf71e9fe7c31fa44f5185d9ab64813ba2af57ca2a (patch)
tree6dcbd303a5490608949fb792e43e82c8d6fa86f5 /scripts/contrib/dialog-power-control
parent0537269df779532245eb2954e04fc26b3edfed85 (diff)
downloadopenembedded-core-f71e9fe7c31fa44f5185d9ab64813ba2af57ca2a.tar.gz
openembedded-core-f71e9fe7c31fa44f5185d9ab64813ba2af57ca2a.tar.bz2
openembedded-core-f71e9fe7c31fa44f5185d9ab64813ba2af57ca2a.zip
scripts/contrib/dialog-power-control: add a trivial power prompt script
If you want to do automated hardware testing but don't have a controllable power strip this script can be useful so that you know when you need to cycle the power. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/contrib/dialog-power-control')
-rwxr-xr-xscripts/contrib/dialog-power-control53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/contrib/dialog-power-control b/scripts/contrib/dialog-power-control
new file mode 100755
index 0000000000..7550ea53be
--- /dev/null
+++ b/scripts/contrib/dialog-power-control
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Simple script to show a manual power prompt for when you want to use
+# automated hardware testing with testimage.bbclass but you don't have a
+# web-enabled power strip or similar to do the power on/off/cycle.
+#
+# You can enable it by enabling testimage (see the Yocto Project
+# Development manual "Performing Automated Runtime Testing" section)
+# and setting the following in your local.conf:
+#
+# TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
+#
+
+PROMPT=""
+while true; do
+ case $1 in
+ on)
+ PROMPT="Please turn device power on";;
+ off)
+ PROMPT="Please turn device power off";;
+ cycle)
+ PROMPT="Please click Done, then turn the device power off then on";;
+ "")
+ break;;
+ esac
+ shift
+done
+
+if [ "$PROMPT" = "" ] ; then
+ echo "ERROR: no power action specified on command line"
+ exit 2
+fi
+
+if [ "`which kdialog 2>/dev/null`" != "" ] ; then
+ DIALOGUTIL="kdialog"
+elif [ "`which zenity 2>/dev/null`" != "" ] ; then
+ DIALOGUTIL="zenity"
+else
+ echo "ERROR: couldn't find program to display a message, install kdialog or zenity"
+ exit 3
+fi
+
+if [ "$DIALOGUTIL" = "kdialog" ] ; then
+ kdialog --yesno "$PROMPT" --title "TestImage Power Control" --yes-label "Done" --no-label "Cancel test"
+elif [ "$DIALOGUTIL" = "zenity" ] ; then
+ zenity --question --text="$PROMPT" --title="TestImage Power Control" --ok-label="Done" --cancel-label="Cancel test"
+fi
+
+if [ "$?" != "0" ] ; then
+ echo "User cancelled test at power prompt"
+ exit 1
+fi
+