nixosTests.power-profiles-daemon: test profilectl CLI
We also take advantage of that change to point to the new dbus canonical names.
This commit is contained in:
parent
93679d4d0a
commit
1da7dfa57d
1 changed files with 16 additions and 5 deletions
|
@ -8,22 +8,22 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||||
nodes.machine = { pkgs, ... }: {
|
nodes.machine = { pkgs, ... }: {
|
||||||
security.polkit.enable = true;
|
security.polkit.enable = true;
|
||||||
services.power-profiles-daemon.enable = true;
|
services.power-profiles-daemon.enable = true;
|
||||||
environment.systemPackages = [ pkgs.glib ];
|
environment.systemPackages = [ pkgs.glib pkgs.power-profiles-daemon ];
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
def get_profile():
|
def get_profile():
|
||||||
return machine.succeed(
|
return machine.succeed(
|
||||||
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
"""gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
|
||||||
--method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile'
|
--method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def set_profile(profile):
|
def set_profile(profile):
|
||||||
return machine.succeed(
|
return machine.succeed(
|
||||||
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
"""gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
|
||||||
--method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
|
--method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
|
||||||
""".format(
|
""".format(
|
||||||
profile=profile
|
profile=profile
|
||||||
)
|
)
|
||||||
|
@ -42,5 +42,16 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||||
profile = get_profile()
|
profile = get_profile()
|
||||||
if not "balanced" in profile:
|
if not "balanced" in profile:
|
||||||
raise Exception("Unable to set balanced profile")
|
raise Exception("Unable to set balanced profile")
|
||||||
|
|
||||||
|
# test powerprofilectl CLI
|
||||||
|
machine.succeed("powerprofilesctl set power-saver")
|
||||||
|
profile = get_profile()
|
||||||
|
if not "power-saver" in profile:
|
||||||
|
raise Exception("Unable to set power-saver profile with powerprofilectl")
|
||||||
|
|
||||||
|
machine.succeed("powerprofilesctl set balanced")
|
||||||
|
profile = get_profile()
|
||||||
|
if not "balanced" in profile:
|
||||||
|
raise Exception("Unable to set balanced profile with powerprofilectl")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue