mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 22:21:26 +00:00
power-profiles-daemon: add test
This commit is contained in:
parent
9a3190a960
commit
65968a1f59
45
nixos/tests/power-profiles-daemon.nix
Normal file
45
nixos/tests/power-profiles-daemon.nix
Normal file
@ -0,0 +1,45 @@
|
||||
import ./make-test-python.nix ({ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "power-profiles-daemon";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ mvnetbiz ];
|
||||
};
|
||||
machine = { pkgs, ... }: {
|
||||
services.power-profiles-daemon.enable = true;
|
||||
environment.systemPackages = [ pkgs.glib ];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
def get_profile():
|
||||
return machine.succeed(
|
||||
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
||||
--method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile'
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def set_profile(profile):
|
||||
return machine.succeed(
|
||||
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
||||
--method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
|
||||
""".format(
|
||||
profile=profile
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
|
||||
set_profile("power-saver")
|
||||
profile = get_profile()
|
||||
if not "power-saver" in profile:
|
||||
raise Exception("Unable to set power-saver profile")
|
||||
|
||||
|
||||
set_profile("balanced")
|
||||
profile = get_profile()
|
||||
if not "balanced" in profile:
|
||||
raise Exception("Unable to set balanced profile")
|
||||
'';
|
||||
})
|
Loading…
Reference in New Issue
Block a user