blob: 278e94711830af5994724eeda4b99472a9477807 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "power-profiles-daemon";
meta = with pkgs.lib.maintainers; {
maintainers = [ mvnetbiz ];
};
nodes.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")
'';
})
|