XCPMD Testing

Basic functionality test

Check loaded conditions

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.get_conditions
Running the above command should return a list of 36 conditions (as of this writing).

Check loaded actions

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.get_actions
Running the above command should return a list of 32 actions (as of this writing).

Add a variable

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.add_var string:'test_var1' string:'"test rule 1: on battery!"'
Running 'db-ls /power-management' should show a vars node with test_var1:"test rule 1: on battery!"

Add a rule

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.add_rule string:'test_rule1' string:'whileUsingBatt()' string:'logString($test_var1)' string:'logString("test rule 1: on AC!")'
Running 'db-ls /power-management' should show a rules node with test_rule1 and its properties.
Unplugging the laptop should cause 'test rule 1: on battery!' to print in /var/log/messages.
Plugging it back in should cause 'test rule 1: on AC!' to print in /var/log/messages.

Try to remove a variable that is in use

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.remove_var string:'test_var1'
An error message should be received, saying the variable is still in use.
Running 'db-ls /power-management' should still show test_var1 under the vars node.

Remove a rule

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.remove_rule string:test_rule1
Running 'db-ls /power-management' should show an empty rules node
Unplugging the laptop should not cause 'test rule 1: on battery!' to print
Plugging it back in should not cause 'test rule 1: on AC!' to print

Remove a variable

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.remove_var string:'test_var1'
Running 'db-ls /power-management' should show an empty vars node

Load rules from a file (test_rules.rules)

Copy the accompanying rules file to /root/xcpmd.rulesĀ 
dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.load_policy_from_file string:'/root/xcpmd.rules'
Running 'db-ls /power-management' should show several rules loaded under the rules node
If this fails due to SELinux, temporarily disable it with 'setenforce 0', rerun the dbus-send command, and reenable with 'setenforce 1'.
The rules in it are used for subsequent tests.

Test VM events

Pause any vm with 'xec-vm -n <vmname> pause'.
This should cause the message 'test rule 2: vm paused!' to print in /var/log/messages
Unpause the vm you paused with 'xec-vm -n <vmname> unpause'.
This should cause the message 'test rule 2: vm unpaused!' to print in /var/log/messages

Test VM actions

Unplugging the laptop should cause the UIVM to pause.
This can be tested either by SSH-ing in and running xec-vm, or simply by seeing if the system responds to mouse movements.
Plugging the laptop back in should cause the UIVM to unpause and become responsive to mouse and keyboard commands.

Clear policy

dbus-send --system --print-reply --dest=com.citrix.xenclient.xcpmd / com.citrix.xenclient.xcpmd.clear_policy
Unplugging the laptop should no longer pause the UIVM.
Pausing any VM should no longer cause the message 'test rule 2: vm paused!' to print in /var/log/messages
Running 'db-ls /power-management' should show empty rules and vars nodes.

Load default policy

Load the default policy by restarting XCPMD with no rules or variables in the DB.
RunningĀ 'db-ls /power-management' should show three variables and five rules.

Check default policy

Close the laptop lid. The screen should turn off.
Open the laptop lid. The screen should turn on. (It may flicker a few times.)
Unplug the laptop. The screen should dim to 75%.
Plug the laptop back in. The screen should brighten to 100%.
Press the brightness down key several times. Each time, the screen should dim slightly.
Press the brightness up key several times. Each time, the screen should brighten slightly.
Unplug the laptop and wait for the aggregate battery capacity of the system to drop below 10%. The screen should dim to 60%.
Plug the laptop back in. The screen should brighten to 100%.