summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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