mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixosTests.installed-tests.power-profiles-daemon: init
This commit is contained in:
parent
6e64f03c12
commit
bb9ea6763d
4 changed files with 103 additions and 2 deletions
|
@ -104,5 +104,6 @@ in
|
||||||
malcontent = callInstalledTest ./malcontent.nix {};
|
malcontent = callInstalledTest ./malcontent.nix {};
|
||||||
ostree = callInstalledTest ./ostree.nix {};
|
ostree = callInstalledTest ./ostree.nix {};
|
||||||
pipewire = callInstalledTest ./pipewire.nix {};
|
pipewire = callInstalledTest ./pipewire.nix {};
|
||||||
|
power-profiles-daemon = callInstalledTest ./power-profiles-daemon.nix {};
|
||||||
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
|
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
|
||||||
}
|
}
|
||||||
|
|
9
nixos/tests/installed-tests/power-profiles-daemon.nix
Normal file
9
nixos/tests/installed-tests/power-profiles-daemon.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ pkgs, lib, makeInstalledTest, ... }:
|
||||||
|
|
||||||
|
makeInstalledTest {
|
||||||
|
tested = pkgs.power-profiles-daemon;
|
||||||
|
|
||||||
|
testConfig = {
|
||||||
|
services.power-profiles-daemon.enable = true;
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
, meson
|
, meson
|
||||||
, ninja
|
, ninja
|
||||||
, fetchFromGitLab
|
, fetchFromGitLab
|
||||||
|
, fetchpatch
|
||||||
, libgudev
|
, libgudev
|
||||||
, glib
|
, glib
|
||||||
, polkit
|
, polkit
|
||||||
|
@ -15,17 +16,26 @@
|
||||||
, libxml2
|
, libxml2
|
||||||
, libxslt
|
, libxslt
|
||||||
, upower
|
, upower
|
||||||
|
, umockdev
|
||||||
, systemd
|
, systemd
|
||||||
, python3
|
, python3
|
||||||
, wrapGAppsNoGuiHook
|
, wrapGAppsNoGuiHook
|
||||||
, nixosTests
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
testPythonPkgs = ps: with ps; [
|
||||||
|
pygobject3
|
||||||
|
dbus-python
|
||||||
|
python-dbusmock
|
||||||
|
];
|
||||||
|
testTypelibPath = lib.makeSearchPathOutput "lib" "lib/girepository-1.0" [ umockdev ];
|
||||||
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "power-profiles-daemon";
|
pname = "power-profiles-daemon";
|
||||||
version = "0.10.1";
|
version = "0.10.1";
|
||||||
|
|
||||||
outputs = [ "out" "devdoc" ];
|
outputs = [ "out" "devdoc" "installedTests" ];
|
||||||
|
|
||||||
src = fetchFromGitLab {
|
src = fetchFromGitLab {
|
||||||
domain = "gitlab.freedesktop.org";
|
domain = "gitlab.freedesktop.org";
|
||||||
|
@ -35,6 +45,18 @@ stdenv.mkDerivation rec {
|
||||||
sha256 = "sha256-sQWiCHc0kEELdmPq9Qdk7OKDUgbM5R44639feC7gjJc=";
|
sha256 = "sha256-sQWiCHc0kEELdmPq9Qdk7OKDUgbM5R44639feC7gjJc=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# Enable installed tests.
|
||||||
|
# https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/merge_requests/92
|
||||||
|
(fetchpatch {
|
||||||
|
url = "https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/3c64d9e1732eb6425e33013c452f1c4aa7a26f7e.patch";
|
||||||
|
sha256 = "din5VuZZwARNDInHtl44yJK8pLmlxr5eoD4iMT4a8HA=";
|
||||||
|
})
|
||||||
|
|
||||||
|
# Install installed tests to separate output.
|
||||||
|
./installed-tests-path.patch
|
||||||
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkg-config
|
pkg-config
|
||||||
meson
|
meson
|
||||||
|
@ -46,9 +68,11 @@ stdenv.mkDerivation rec {
|
||||||
libxml2 # for xmllint for stripping GResources
|
libxml2 # for xmllint for stripping GResources
|
||||||
libxslt # for xsltproc for building docs
|
libxslt # for xsltproc for building docs
|
||||||
gobject-introspection
|
gobject-introspection
|
||||||
python3
|
|
||||||
wrapGAppsNoGuiHook
|
wrapGAppsNoGuiHook
|
||||||
python3.pkgs.wrapPython
|
python3.pkgs.wrapPython
|
||||||
|
|
||||||
|
# For finding tests.
|
||||||
|
(python3.withPackages testPythonPkgs)
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
@ -68,6 +92,7 @@ stdenv.mkDerivation rec {
|
||||||
];
|
];
|
||||||
|
|
||||||
mesonFlags = [
|
mesonFlags = [
|
||||||
|
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
|
||||||
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
||||||
"-Dgtk_doc=true"
|
"-Dgtk_doc=true"
|
||||||
];
|
];
|
||||||
|
@ -81,6 +106,18 @@ stdenv.mkDerivation rec {
|
||||||
patchShebangs tests/unittest_inspector.py
|
patchShebangs tests/unittest_inspector.py
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
preConfigure = ''
|
||||||
|
# For finding tests.
|
||||||
|
GI_TYPELIB_PATH_original=$GI_TYPELIB_PATH
|
||||||
|
addToSearchPath GI_TYPELIB_PATH "${testTypelibPath}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
postConfigure = ''
|
||||||
|
# Restore the original value to prevent the program from depending on umockdev.
|
||||||
|
export GI_TYPELIB_PATH=$GI_TYPELIB_PATH_original
|
||||||
|
unset GI_TYPELIB_PATH_original
|
||||||
|
'';
|
||||||
|
|
||||||
preInstall = ''
|
preInstall = ''
|
||||||
# We have pkexec on PATH so Meson will try to use it when installation fails
|
# We have pkexec on PATH so Meson will try to use it when installation fails
|
||||||
# due to being unable to write to e.g. /etc.
|
# due to being unable to write to e.g. /etc.
|
||||||
|
@ -96,11 +133,28 @@ stdenv.mkDerivation rec {
|
||||||
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
||||||
# Make Python libraries available
|
# Make Python libraries available
|
||||||
wrapPythonProgramsIn "$out/bin" "$pythonPath"
|
wrapPythonProgramsIn "$out/bin" "$pythonPath"
|
||||||
|
|
||||||
|
# Make Python libraries available for installed tests
|
||||||
|
makeWrapperArgs+=(
|
||||||
|
--prefix GI_TYPELIB_PATH : "${testTypelibPath}"
|
||||||
|
--prefix PATH : "${lib.makeBinPath [ umockdev ]}"
|
||||||
|
# Vala does not use absolute paths in typelibs
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/47226
|
||||||
|
# Also umockdev binaries use relative paths for LD_PRELOAD.
|
||||||
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ umockdev ]}"
|
||||||
|
# dbusmock calls its templates using exec so our regular patching of Python scripts
|
||||||
|
# to add package directories to site will not carry over.
|
||||||
|
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/mockobject.py#L51
|
||||||
|
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/__main__.py#L60-L62
|
||||||
|
--prefix PYTHONPATH : "${lib.makeSearchPath python3.sitePackages (testPythonPkgs python3.pkgs)}"
|
||||||
|
)
|
||||||
|
wrapPythonProgramsIn "$installedTests/libexec/installed-tests" "$pythonPath ${lib.concatStringsSep " " (testPythonPkgs python3.pkgs)}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
tests = {
|
tests = {
|
||||||
nixos = nixosTests.power-profiles-daemon;
|
nixos = nixosTests.power-profiles-daemon;
|
||||||
|
installed-tests = nixosTests.installed-tests.power-profiles-daemon;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
diff --git a/meson_options.txt b/meson_options.txt
|
||||||
|
index 7e89619..76497db 100644
|
||||||
|
--- a/meson_options.txt
|
||||||
|
+++ b/meson_options.txt
|
||||||
|
@@ -1,3 +1,4 @@
|
||||||
|
+option('installed_test_prefix', type: 'string', description: 'Prefix for installed tests')
|
||||||
|
option('systemdsystemunitdir',
|
||||||
|
description: 'systemd unit directory',
|
||||||
|
type: 'string',
|
||||||
|
diff --git a/tests/meson.build b/tests/meson.build
|
||||||
|
index b306a7f..7670e1b 100644
|
||||||
|
--- a/tests/meson.build
|
||||||
|
+++ b/tests/meson.build
|
||||||
|
@@ -2,8 +2,8 @@ envs = environment()
|
||||||
|
envs.set ('top_builddir', meson.build_root())
|
||||||
|
envs.set ('top_srcdir', meson.source_root())
|
||||||
|
|
||||||
|
-installed_test_bindir = libexecdir / 'installed-tests' / meson.project_name()
|
||||||
|
-installed_test_datadir = datadir / 'installed-tests' / meson.project_name()
|
||||||
|
+installed_test_bindir = get_option('installed_test_prefix') / 'libexec' / 'installed-tests' / meson.project_name()
|
||||||
|
+installed_test_datadir = get_option('installed_test_prefix') / 'share' / 'installed-tests' / meson.project_name()
|
||||||
|
|
||||||
|
python3 = find_program('python3')
|
||||||
|
unittest_inspector = find_program('unittest_inspector.py')
|
||||||
|
diff --git a/tests/integration-test.py b/tests/integration-test.py
|
||||||
|
index 22dc42c..0f92b76 100755
|
||||||
|
--- a/tests/integration-test.py
|
||||||
|
+++ b/tests/integration-test.py
|
||||||
|
@@ -67,7 +67,7 @@ class Tests(dbusmock.DBusTestCase):
|
||||||
|
print('Testing binaries from JHBuild (%s)' % cls.daemon_path)
|
||||||
|
else:
|
||||||
|
cls.daemon_path = None
|
||||||
|
- with open('/usr/lib/systemd/system/power-profiles-daemon.service') as f:
|
||||||
|
+ with open('/run/current-system/sw/lib/systemd/system/power-profiles-daemon.service') as f:
|
||||||
|
for line in f:
|
||||||
|
if line.startswith('ExecStart='):
|
||||||
|
cls.daemon_path = line.split('=', 1)[1].strip()
|
Loading…
Add table
Add a link
Reference in a new issue