diff options
author | Matt Votava <mvnetbiz@gmail.com> | 2020-09-15 01:15:48 -0700 |
---|---|---|
committer | Jan Tojnar <jtojnar@gmail.com> | 2021-02-09 01:25:57 +0100 |
commit | 65968a1f5948b8c428c42770a5739ebe75cf5a06 (patch) | |
tree | 8f5bc800d1edd65dc908b1e1711c6c4da389e067 /nixos/tests | |
parent | 9a3190a960b9c3e15ce1518b6545b4bc921cf459 (diff) |
power-profiles-daemon: add test
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/power-profiles-daemon.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nixos/tests/power-profiles-daemon.nix b/nixos/tests/power-profiles-daemon.nix new file mode 100644 index 0000000000000..422008316f078 --- /dev/null +++ b/nixos/tests/power-profiles-daemon.nix @@ -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") + ''; +}) |