diff --git a/battery/battery-health-check.sh b/battery/battery-health-check.sh index 918392d03593a5711fe412a9fc136bee6a908e9b..4d221b856807187e25408332c0ccfac1b8066771 100755 --- a/battery/battery-health-check.sh +++ b/battery/battery-health-check.sh @@ -24,6 +24,18 @@ else test-exception "No battery detected; job exit" fi +if ac=$(grep -l Mains /sys/class/power_supply/*/type); then + test-result ac-present --result pass + if [ $(cat $(dirname $ac)/online) -eq 1 ]; then + test-result ac-online --result pass + else + test-result ac-online --result fail + fi +else + echo "Could not find any info about AC; check kernel configuration." + test-result ac-present --result skip +fi + for battery in $batteries; do dir=$(basename $(dirname $battery)) @@ -33,6 +45,14 @@ for battery in $batteries; do continue fi + # report battery status + if status=$(cat $(dirname $battery)/status); then + echo "$dir status: $status" + test-result $dir-status --result pass + else + test-result $dir-status --result fail + fi + # test battery capacity if cap=$(cat $(dirname $battery)/capacity); then if [ "$cap" -gt "$threshold" ]; then @@ -43,12 +63,4 @@ for battery in $batteries; do else test-result $dir-capacity --result fail fi - - # report battery status - if status=$(cat $(dirname $battery)/status); then - echo "$dir status: $status" - test-result $dir-status --result pass - else - test-result $dir-status --result fail - fi done \ No newline at end of file