plugin: manual
name: power-management/shutdown-boot
description:
 PURPOSE:
     This test will check your system shutdown/booting cycle.
 STEPS:
     1. Shutdown your machine.
     2. Boot your machine.
     3. Repeat steps 1 and 2 at least 5 times.
 VERIFICATION:
     Did the system shutdown and rebooted correctly?

plugin: shell
name: power-management/fwts_wakealarm
environ: CHECKBOX_DATA
user: root
description: Test ACPI Wakealarm (fwts wakealarm)
requires:
 package.name == 'fwts'
command: fwts_test -f aborted -t wakealarm -l $CHECKBOX_DATA/fwts-wakealarm.log

plugin: attachment
name: power-management/fwts_wakealarm-log-attach
depends: power-management/fwts_wakealarm
description: Attach log from fwts wakealarm test
requires:
 package.name == 'fwts'
command: [ -e ${CHECKBOX_DATA}/fwts-wakealarm.log ] && cat ${CHECKBOX_DATA}/fwts-wakealarm.log

plugin: user-interact-verify
name: power-management/poweroff
depends: power-management/fwts_wakealarm
user: root
environ: CHECKBOX_DATA
requires:
 package.name == 'upstart'
 package.name == 'fwts'
command: pm_test poweroff --log-level=debug --log-dir=$CHECKBOX_DATA
description:
 PURPOSE:
  This test will check the system's ability to power-off and boot.
 STEPS:
  1. Select "Test" to begin.
  2. The machine will shut down.
  3. Power the machine back on.
  4. After rebooting, wait for the test prompts to inform you that the test is complete.
  5. Once the test has completed, restart checkbox and select 'Re-run' when prompted.
 VERIFICATION:
  If the machine successfully shuts down and boots, select 'Yes', otherwise,
  select 'No'.

plugin: attachment
name: power-management/poweroff-log-attach
command: tar cvfz power-management_poweroff.tgz $CHECKBOX_DATA/*poweroff.1.log && cat $CHECKBOX_DATA/power-management_poweroff.tgz
description:
 This will attach any logs from the power-management/poweroff test to the results.

plugin: user-interact-verify
name: power-management/reboot
user: root
environ: CHECKBOX_DATA
requires:
 package.name == 'upstart'
 package.name == 'fwts'
command: pm_test reboot --log-level=debug --log-dir=$CHECKBOX_DATA
description:
 PURPOSE:
  This test will check the system's ability to reboot cleanly.
 STEPS:
  1. Select "Test" to begin.
  2. The machine will reboot.
  3. After rebooting, wait for the test prompts to inform you that the test is complete.
  4. Once the test has completed, restart checkbox and select Re-Run when prompted.
 VERIFICATION:
  If the machine successfully reboots, select Yes then select Next.

plugin: attachment
name: power-management/reboot-log-attach
command: tar cvfz power-management_reboot.tgz $CHECKBOX_DATA/*reboot.1.log && cat $CHECKBOX_DATA/power-management_reboot.tgz
description:
 This will attach any logs from the power-management/reboot test to the results.

plugin: manual
name: power-management/lid
description:
 PURPOSE:
     This test will check your lid sensors.
 STEPS:
     1. Close your laptop lid.
 VERIFICATION:
    Does closing your laptop lid cause your system to suspend?

plugin: user-interact
name: power-management/lid_close
requires: device.product == 'Lid Switch'
command:
 for i in `seq 20`; do
  state=`cat /proc/acpi/button/lid/*/state | awk '{print $2}'`
  [ "$state" = "closed" ] && exit 0 || sleep 0.5
 done
 exit 1
description:
 PURPOSE:
     This test will check your lid sensors
 STEPS:
     1. Click "Test".
     2. Close and open the lid.
 VERIFICATION:
     Did the screen turn off while the lid was closed?

plugin: user-interact
name: power-management/lid_open
requires: device.product == 'Lid Switch'
command:
 for i in `seq 20`; do
  state=`cat /proc/acpi/button/lid/*/state | awk '{print $2}'`
  [ "$state" = "open" ] && exit 0 || sleep 0.5
 done
 exit 1
description:
 PURPOSE:
     This test will check your lid sensors.
 STEPS:
     1. Click "Test".
     2. Close the lid.
     3. Wait 5 seconds with the lid closed.
     4. Open the lid.
 VERIFICATION:
     Did the system resume when the lid was opened?

plugin: shell
name: power-management/rtc
requires:
  rtc.state == 'supported'
  package.name == 'util-linux'
user: root
command: hwclock -r
estimated_duration: 0.02
description:
 Verify that the Real-time clock (RTC) device functions properly, if present

plugin: shell
name: power-management/tickless_idle
description: Check to see if CONFIG_NO_HZ is set in the kernel (this is just a simple regression check)
command:
 zgrep 'CONFIG_NO_HZ=y' /boot/config-`uname -r` >/dev/null 2>&1 || ( echo "WARNING: Tickless Idle is NOT set" >&2 && exit 1 )

plugin: manual
name: power-management/unplug_ac
description:
 PURPOSE:
     This test will ensure that the AC is unplugged for the battery drain tests to run.
 STEPS:
     1. Unplug laptop from AC.
 VERIFICATION:
     Was the laptop unplugged from AC?

plugin: shell
name: power-management/battery_drain_idle
requires: package.name == 'upower'
depends: power-management/unplug_ac
description: Checks the battery drain during idle.  Reports time until empty
 and capacity as well.
command:
 battery_test -t 90 --idle

plugin: shell
name: power-management/battery_drain_movie
requires:
 package.name == 'upower'
depends: power-management/unplug_ac
description: Checks the battery drain while watching a movie.  Reports time
 until empty and capacity as well.  Requires MOVIE_VAR to be set.
command:
 battery_test -t 90 --movie $MOVIE_VAR

plugin: shell
name: power-management/battery_drain_sleep
user: root
requires:
 package.name == 'upower'
 package.name == 'fwts'
depends: power-management/unplug_ac
description: Checks the battery drain during suspend.  Reports time until
 empty and capacity as well.
command:
 battery_test -t 120 --sleep

plugin: manual
name: power-management/plug_ac
depends: power-management/battery_drain_idle power-management/battery_drain_movie power-management/battery_drain_sleep
description:
 PURPOSE:
     This test will ensure that the AC is plugged back in after the battery.
     tests
 STEPS:
     1. Plug laptop into AC.
 VERIFICATION:
     Was the laptop plugged into AC?

plugin: user-interact-verify
name: power-management/reboot_manual
user:root
command: shutdown -r now
description:
 PURPOSE:
     This test will verify that your system can successfully reboot.
 STEPS:
     1. Select 'Test' to initiate a system reboot.
     2. When the grub boot menu is displayed, boot into Ubuntu (Or allow the
     system to automatically boot on its own).
     3. Once the system has restarted, log in and restart checkbox-certification-server.
     4. Select 'Re-Run' to return to this test.
     5. Select 'Yes' to indicate the test has passed if the system rebooted
     successfully, otherwise, select 'No' to indicate there was a problem.
 VERIFICATION:
     Did the system reboot correctly?

plugin: user-interact-verify
name: power-management/shutdown_manual
user: root
command: shutdown -h now
description:
 PURPOSE:
     This test will check your system shutdown/booting cycle
 STEPS:
     1. Select 'Test' to initiate a system shutdown.
     2. Power the system back on.
     3. From the grub menu, boot into the Xen Hypervisor.
     4. When the system has restarted, log in and restart checkbox-certification-server.
     5. Select 'Re-Run' to return to this test.
     6. Select 'Yes' to indicate the test has passed if the machine shut down
     successfully otherwise, Select 'No' to indicate there was a problem.
 VERIFICATION:
     Did the system shutdown and boot correctly?
