Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testcase to check power-mode before and after suspend #824

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions providers/base/units/suspend/suspend.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ estimated_duration: 1.2
_summary: Dumps memory info to a file for comparison after suspend
command: meminfo_resource.py > "$PLAINBOX_SESSION_SHARE"/meminfo_before_suspend

plugin: shell
category_id: com.canonical.plainbox::suspend
id: suspend/power_mode_before_suspend
estimated_duration: 1.2
requires:
module.name == 'platform_profile'
package.name == 'power-profiles-daemon'
_summary: Dumps power_mode info to a file for comparison after suspend
command: power_mode_resource.py > "$PLAINBOX_SESSION_SHARE"/power_mode_before_suspend

unit: template
template-resource: device
template-filter: device.category == 'NETWORK'
Expand Down Expand Up @@ -583,6 +593,30 @@ _description:
Verify that all memory is available after resuming from suspend.
command: meminfo_resource.py | diff "$PLAINBOX_SESSION_SHARE"/meminfo_before_suspend -

plugin: shell
category_id: com.canonical.plainbox::suspend
id: suspend/power_mode_after_suspend
estimated_duration: 1.2
requires:
module.name == 'platform_profile'
package.name == 'power-profiles-daemon'
depends: suspend/suspend_advanced_auto suspend/power_mode_before_suspend
_description:
Verify that power mode is changed after resuming from suspend.
command: power_mode_resource.py | diff "$PLAINBOX_SESSION_SHARE"/power_mode_before_suspend -

plugin: shell
category_id: com.canonical.plainbox::suspend
id: suspend/power_mode_after_suspend_auto
estimated_duration: 1.2
requires:
module.name == 'platform_profile'
package.name == 'power-profiles-daemon'
depends: suspend/suspend_advanced_auto suspend/power_mode_before_suspend
_description:
Verify that power mode is changed after resuming from suspend.
command: power_mode_resource.py | diff "$PLAINBOX_SESSION_SHARE"/power_mode_before_suspend -

binli marked this conversation as resolved.
Show resolved Hide resolved
plugin: manual
category_id: com.canonical.plainbox::suspend
id: suspend/display_after_suspend
Expand Down
49 changes: 49 additions & 0 deletions providers/resource/bin/power_mode_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
#
# This file is part of Checkbox.
#
# Copyright 2023 Canonical Ltd.
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.

#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
#

"""Modules providing a function running os or sys commands."""
import sys
import os


def main():
binli marked this conversation as resolved.
Show resolved Hide resolved
"""Dump the power mode."""
sysfs_root = "/sys/firmware/acpi/"
if not os.path.isdir(sysfs_root):
return 1

profile_filename = os.path.join(sysfs_root, "platform_profile")
if (not os.path.isfile(profile_filename) or
not os.access(profile_filename, os.R_OK)):
return 1

with open(profile_filename, "rt", encoding="utf-8") as stream:
profile = stream.read().strip().split()
if len(profile) < 1:
return 1
else:
print(profile[0])
# uncomment the following line to do local testing
#os.system(f"powerprofilesctl set power-saver")
binli marked this conversation as resolved.
Show resolved Hide resolved
return 0


if __name__ == "__main__":
sys.exit(main())
Loading