summaryrefslogtreecommitdiffstats
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:33 +0100
commit9e7b0ca3832ce7ea9826e5d90ec9f10a7772099e (patch)
treec4f7fdcb8740f224fe3d81b621b41ca5b2c1a981 /scripts/contrib/dialog-power-control
parentd20eedb18d62f719feab372d89fad0ca8a695aba (diff)
downloadpoky-9e7b0ca3832ce7ea9826e5d90ec9f10a7772099e.tar.gz
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. (From OE-Core rev: f71e9fe7c31fa44f5185d9ab64813ba2af57ca2a) 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 @@
1#!/bin/sh
2#
3# Simple script to show a manual power prompt for when you want to use
4# automated hardware testing with testimage.bbclass but you don't have a
5# web-enabled power strip or similar to do the power on/off/cycle.
6#
7# You can enable it by enabling testimage (see the Yocto Project
8# Development manual "Performing Automated Runtime Testing" section)
9# and setting the following in your local.conf:
10#
11# TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
12#
13
14PROMPT=""
15while true; do
16 case $1 in
17 on)
18 PROMPT="Please turn device power on";;
19 off)
20 PROMPT="Please turn device power off";;
21 cycle)
22 PROMPT="Please click Done, then turn the device power off then on";;
23 "")
24 break;;
25 esac
26 shift
27done
28
29if [ "$PROMPT" = "" ] ; then
30 echo "ERROR: no power action specified on command line"
31 exit 2
32fi
33
34if [ "`which kdialog 2>/dev/null`" != "" ] ; then
35 DIALOGUTIL="kdialog"
36elif [ "`which zenity 2>/dev/null`" != "" ] ; then
37 DIALOGUTIL="zenity"
38else
39 echo "ERROR: couldn't find program to display a message, install kdialog or zenity"
40 exit 3
41fi
42
43if [ "$DIALOGUTIL" = "kdialog" ] ; then
44 kdialog --yesno "$PROMPT" --title "TestImage Power Control" --yes-label "Done" --no-label "Cancel test"
45elif [ "$DIALOGUTIL" = "zenity" ] ; then
46 zenity --question --text="$PROMPT" --title="TestImage Power Control" --ok-label="Done" --cancel-label="Cancel test"
47fi
48
49if [ "$?" != "0" ] ; then
50 echo "User cancelled test at power prompt"
51 exit 1
52fi
53