test/battery: fix tests…

pull/2031/head
John D Pell 2022-03-03 23:14:33 -08:00
parent 6734baf950
commit dc380e9ed6
1 changed files with 2 additions and 2 deletions

View File

@ -195,14 +195,14 @@ function setup_acpi {
# Creates a `upower` function that simulates output like the real `upower` command. # Creates a `upower` function that simulates output like the real `upower` command.
# The passed in parameter is used for the remaining battery percentage. # The passed in parameter is used for the remaining battery percentage.
function setup_upower { function setup_upower {
trap -p PIPE | grep -q PIPE || trap '' PIPE
percent="$1" percent="$1"
BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM"
function upower { function upower {
case $1 in case $1 in
'-e'|'--enumerate') '-e'|'--enumerate')
# don't just `echo` twice because `grep` will close the pipe after matching the first line... printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
echo "$BAT0"$'\n'"/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
;; ;;
'-i'|'--show-info') '-i'|'--show-info')
if [[ $2 == "$BAT0" ]] if [[ $2 == "$BAT0" ]]