blob: 82c84baa1d4ccf31d02e25c1f025c88848a319ea [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2#
Patrick Williams92b42cb2022-09-03 06:53:57 -05003# Copyright OpenEmbedded Contributors
4#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-only
6#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007# Simple script to show a manual power prompt for when you want to use
8# automated hardware testing with testimage.bbclass but you don't have a
9# web-enabled power strip or similar to do the power on/off/cycle.
10#
11# You can enable it by enabling testimage (see the Yocto Project
12# Development manual "Performing Automated Runtime Testing" section)
13# and setting the following in your local.conf:
14#
15# TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
16#
17
18PROMPT=""
19while true; do
20 case $1 in
21 on)
22 PROMPT="Please turn device power on";;
23 off)
24 PROMPT="Please turn device power off";;
25 cycle)
26 PROMPT="Please click Done, then turn the device power off then on";;
27 "")
28 break;;
29 esac
30 shift
31done
32
33if [ "$PROMPT" = "" ] ; then
34 echo "ERROR: no power action specified on command line"
35 exit 2
36fi
37
38if [ "`which kdialog 2>/dev/null`" != "" ] ; then
39 DIALOGUTIL="kdialog"
40elif [ "`which zenity 2>/dev/null`" != "" ] ; then
41 DIALOGUTIL="zenity"
42else
43 echo "ERROR: couldn't find program to display a message, install kdialog or zenity"
44 exit 3
45fi
46
47if [ "$DIALOGUTIL" = "kdialog" ] ; then
48 kdialog --yesno "$PROMPT" --title "TestImage Power Control" --yes-label "Done" --no-label "Cancel test"
49elif [ "$DIALOGUTIL" = "zenity" ] ; then
50 zenity --question --text="$PROMPT" --title="TestImage Power Control" --ok-label="Done" --cancel-label="Cancel test"
51fi
52
53if [ "$?" != "0" ] ; then
54 echo "User cancelled test at power prompt"
55 exit 1
56fi
57