1import ./make-test-python.nix ({ pkgs, ... }: {
2 name = "hddfancontrol";
3 meta = with pkgs.lib.maintainers; {
4 maintainers = [ benley ];
5 };
6
7 nodes.machine = { ... }: {
8 imports = [ ../modules/profiles/minimal.nix ];
9
10 services.hddfancontrol.enable = true;
11 services.hddfancontrol.disks = ["/dev/vda"];
12 services.hddfancontrol.pwmPaths = ["/test/hwmon1/pwm1"];
13 services.hddfancontrol.extraArgs = ["--pwm-start-value=32"
14 "--pwm-stop-value=0"];
15
16 systemd.services.hddfancontrol_fixtures = {
17 description = "Install test fixtures for hddfancontrol";
18 serviceConfig = {
19 Type = "oneshot";
20 };
21 script = ''
22 mkdir -p /test/hwmon1
23 echo 255 > /test/hwmon1/pwm1
24 echo 2 > /test/hwmon1/pwm1_enable
25 '';
26 wantedBy = ["hddfancontrol.service"];
27 before = ["hddfancontrol.service"];
28 };
29
30 systemd.services.hddfancontrol.serviceConfig.ReadWritePaths = "/test";
31 };
32
33 # hddfancontrol.service will fail to start because qemu /dev/vda doesn't have
34 # any thermal interfaces, but it should ensure that fans appear to be running
35 # before it aborts.
36 testScript = ''
37 start_all()
38 machine.wait_for_unit("multi-user.target")
39 machine.succeed("journalctl -eu hddfancontrol.service|grep 'Setting fan speed'")
40 machine.shutdown()
41
42 '';
43
44})