Skip to content

Commit

Permalink
nixos/auto-cpufreq: init vm test (NixOS#350507)
Browse files Browse the repository at this point in the history
  • Loading branch information
ck3d authored Jan 2, 2025
2 parents 872efd3 + c574ade commit 32f7694
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ in {
audiobookshelf = handleTest ./audiobookshelf.nix {};
auth-mysql = handleTest ./auth-mysql.nix {};
authelia = handleTest ./authelia.nix {};
auto-cpufreq = handleTest ./auto-cpufreq.nix {};
avahi = handleTest ./avahi.nix {};
avahi-with-resolved = handleTest ./avahi.nix { networkd = true; };
ayatana-indicators = runTest ./ayatana-indicators.nix;
Expand Down
33 changes: 33 additions & 0 deletions nixos/tests/auto-cpufreq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import ./make-test-python.nix (
{ pkgs, ... }:

Check failure on line 2 in nixos/tests/auto-cpufreq.nix

View workflow job for this annotation

GitHub Actions / exp-nixf-tidy-check

sema-unused-def-lambda-noarg-formal

attribute `pkgs` of argument is not used

{
name = "auto-cpufreq-server";

nodes = {
machine =
{ pkgs, ... }:

Check failure on line 9 in nixos/tests/auto-cpufreq.nix

View workflow job for this annotation

GitHub Actions / exp-nixf-tidy-check

sema-unused-def-lambda-noarg-formal

attribute `pkgs` of argument is not used
{
# service will still start but since vm inside qemu cpufreq adjustments
# cannot be made. This will resource in the following error but the service
# remains up:
# ERROR:
# Couldn't find any of the necessary scaling governors.
services.auto-cpufreq = {
enable = true;
settings = {
charger = {
turbo = "auto";
};
};
};
};
};

testScript = ''
machine.start()
machine.wait_for_unit("auto-cpufreq.service")
machine.succeed("auto-cpufreq --force reset")
'';
}
)
5 changes: 5 additions & 0 deletions pkgs/by-name/au/auto-cpufreq/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
wrapGAppsHook3,
gtk3,
getent,
nixosTests,
}:
python3Packages.buildPythonPackage rec {
pname = "auto-cpufreq";
Expand Down Expand Up @@ -92,6 +93,10 @@ python3Packages.buildPythonPackage rec {
cp scripts/org.auto-cpufreq.pkexec.policy $out/share/polkit-1/actions
'';

passthru.tests = {
inherit (nixosTests) auto-cpufreq;
};

meta = {
mainProgram = "auto-cpufreq";
homepage = "https://github.com/AdnanHodzic/auto-cpufreq";
Expand Down

0 comments on commit 32f7694

Please sign in to comment.