blob: 7550ea53be4e6d8164fae396ffc719c6afe48aca [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/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