Commit graph

361 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
b27fa341ec tests: Stop the daemon using termination
This implies a SIGTERM, and so will trigger the daemon clean teardown,
making it exit correctly.

In this way the coverage data is correctly generated, making finally our
coverage reports to be real!

Fixes: #137
2024-02-14 22:07:30 +00:00
Marco Trevisan (Treviño)
ccade23e30 power-profiles-daemon: Use autopointer to handle PpdApp data
In this way we always free it. Not just on successful exit.
2024-02-14 22:07:30 +00:00
Marco Trevisan (Treviño)
a0ff4af7ef power-profiles-manager: Exit cleanly on SIGTERM and SIGINT
In case we get a SIGINT or SIGTERM signal, quit the main loop so that we
perform all the teardown operations, including notifying clients and cleaning
up all the allocated resources.
2024-02-14 22:07:30 +00:00
Marco Trevisan (Treviño)
37bf20bb55 tests: Show full logs if PPD_TEST_VERBOSE env is set and use it in meson
It can be useful to inspect the daemon logs in any case, so let's show
the logs details when running in meson.

Then it's up to use the `--verbose` parameter to decide whether to see
them or to inspect them from the generated logs.
2024-02-14 21:33:05 +00:00
Mario Limonciello
940c262b74 amdgpu: reduce panel_power_saving values
The loss of color fidelity in battery mode is too dramatic, especially
with dark content (such as GNOME in dark mode or a dark background terminal).
2024-02-14 13:41:22 -06:00
Marco Trevisan (Treviño)
2a36abda82 tests: Add utility function to eventually check active profile 2024-02-14 19:43:43 +01:00
Marco Trevisan (Treviño)
d174b46498 tests: Simplify files writing
Avoid repeating the same pattern everywhere, just do it once with an
utility function.
2024-02-14 19:36:29 +01:00
Marco Trevisan (Treviño)
a1d8585aec tests: Wait for file contents to match expected ones
Daemon may take some moments to do IO operations, and the tests
may be too fast in reading this.

As per previous cleanups this become a problem when testing in
slower scenarios (as valgrind), so take the opportunity to
cleanup the tests so that we always wait for file contents to
match the expected one.
2024-02-14 19:36:29 +01:00
Marco Trevisan (Treviño)
14edcbfd89 tests: Simplify assert_eventually() using GLib.Timeout
Also use milliseconds instead of deciseconds.
2024-02-14 18:37:24 +01:00
Marco Trevisan (Treviño)
6cf48b4a42 tests: Use python unittest assertions instead of native ones 2024-02-14 17:47:36 +01:00
Marco Trevisan (Treviño)
a518f333e0 tests: Avoid creating a new proxy for each dbus call
Just use the previously allocated, and do not cache anything on it
2024-02-14 17:47:36 +01:00
Marco Trevisan (Treviño)
b75275c757 power-profiles-daemon: Add debug info when the bus names are aquired 2024-02-14 17:38:39 +01:00
Marco Trevisan (Treviño)
867af41ab8 tests: Also ensure that the powerprofilesctl commands match with daemon 2024-02-14 17:38:39 +01:00
Mario Limonciello
13c4202fc7 tests: drop unused read_file() method 2024-02-14 10:37:17 -06:00
Mario Limonciello
e1c0a48b2c tests: Add integration tests to scrape the output of powerprofilesctl 2024-02-14 10:37:15 -06:00
Mario Limonciello
18a9c66681 Use python argparse and decorators instead of reinventing both 2024-02-14 10:37:14 -06:00
Mario Limonciello
718fde54d2 Don't modify powerprofilesctl at build time
Python version and binary used at build time might not be the same
as the installed OS.  Instead reference python3 from environment.
2024-02-14 00:03:31 -06:00
Mario Limonciello
c750f7e791 Reformat powerprofilesctl.in with black 2024-02-14 00:03:31 -06:00
Mario Limonciello
ba2cf0d6f8 Add a Version property and read it with powerprofilesctl 2024-02-14 00:03:28 -06:00
Marco Trevisan (Treviño)
40f3361473 power-profiles-daemon: Emit ProfileReleased when an holder is released
We used to send the signal only when cleaning up the holders, but we
should notify them also when an holder has been released for whatever
reason.
2024-02-14 05:17:49 +00:00
Marco Trevisan (Treviño)
91e907e11f power-profiles-daemon: Emit requester released signal on matching iface/path 2024-02-14 05:17:49 +00:00
Marco Trevisan (Treviño)
07132892f0 tests: Ensure that properties changed events are emitted 2024-02-14 05:17:49 +00:00
Mario Limonciello
e5b107a625 Send signals on both interfaces
Some clients (notably GNOME) look specifically for both the path and
interface.  To avoid breaking them on profile change events make sure
to emit signals on both the legacy and modern interface.
2024-02-14 05:17:49 +00:00
Marco Trevisan (Treviño)
f88ba64d1e ci: Add valgrind job 2024-02-14 04:27:39 +01:00
Marco Trevisan (Treviño)
44f000b5a7 build: Add valgrind setup
Add ability to run tests under valgrind using --setup=valgrind
2024-02-14 04:27:39 +01:00
Marco Trevisan (Treviño)
37a62a3a1b ci: Add job to run tests with address sanitizer 2024-02-14 04:22:52 +01:00
Marco Trevisan (Treviño)
a58f8ed62b ci: Factorize common dependencies installation phase 2024-02-14 04:15:20 +01:00
Marco Trevisan (Treviño)
59ea84d061 tests: Allow tests running with address sanitizers
We need to manually preload the asan library, so read where that is
using some meson machinery inherited from fprintd.
2024-02-14 04:00:20 +01:00
Marco Trevisan (Treviño)
7ea83f33f7 ci: Add scan-build job to perform static analysis 2024-02-14 00:09:44 +00:00
Marco Trevisan (Treviño)
d127ea3908 meson: Bump meson required version to 0.59
It's the first one providing scan-build support
2024-02-14 00:09:44 +00:00
Mario Limonciello
70849a6686 amdgpu: Handle disconnected panels correctly
Some systems have multiple GPUs with an eDP output but the panel
isn't connected to all of them (or it's controlled by a mux).

Handle this case by ensuring that the panel is connected when
before writing an attribute.
2024-02-13 23:20:42 +00:00
Mario Limonciello
07a77652b1 Add support for POWER_PROFILE_DAEMON_ACTION_BLOCK
This can let people avoid loading actions that on their system
in the event of a problem or desire not to use.
2024-02-13 23:20:42 +00:00
Mario Limonciello
41ed5d33a8 Add support for a amdgpu panel power savings action
This activates the DRM connector attribute `panel_power_savings`
which takes a range from 0 to 4 to indicate how aggresively to enable
panel power savings.

Link: https://lore.kernel.org/amd-gfx/0b94b25a-9ffa-41a5-b931-ad84e1892d36@amd.com/T/#m079d7c357626cf3a80cd9ba6239b3fe4fcf8937e
2024-02-13 23:20:42 +00:00
Mario Limonciello
9a740c02d6 Add a ppd_utils_write_sysfs_int() helper
Suggested-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2024-02-13 23:20:42 +00:00
Mario Limonciello
002255cbdd Change the ppd_action_probe() return type to PpdProbeResult 2024-02-13 23:20:42 +00:00
Mario Limonciello
15ce19d623 Move PpdProbeResult to ppd-profile.h
It's used by both `PpdDriver` and `PpdAction`
2024-02-13 23:20:42 +00:00
Mario Limonciello
c749dfc444 Fix launching powerprofilesctl
The active profile is on org.freedesktop.DBus.Properties

Fixes: 3b29b0e ("cleanup: Use UPower namespace as default DBus name preserving old one")
2024-02-13 16:12:16 -06:00
Marco Trevisan (Treviño)
32f5abfb82 powerprofilesctl: Use global variable to hold names and infaces 2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
3b29b0e52b cleanup: Use UPower namespace as default DBus name preserving old one
Expose the daemon as 'org.freedesktop.UPower.PowerProfiles' by default
but we also own the old 'net.hadess.PowerProfiles' name for
compatibility resons.

Also dbus objects are now registered also in the path
/org/freedesktop/UPower/PowerProfiles and they implement the
org.freedesktop.UPower.PowerProfiles interface.

Even in this case we preserve the compatibility with the old ones.

To make this switch as most reliable as possible, the code is now
generated for dbus configuration files preserving the previous ones as
base.

Tests are now performed checking both names, to ensure again that we're
not breaking the expectations for the old APIs consumers.
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
520622ba70 data: Rename policykit policies to UPower namespace
We're part of UPower now so let's use the freedesktop standard namespace
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
53115abf35 build: Bump meson requirement to 0.58
It's still quite old, but provides some features we may want to use in
future, so let's use a newer version since we're about to release a new
major version of p-p-d too.
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
143e35da0c docs: Handle warnings for unknown definitions 2024-02-13 20:36:09 +00:00
Marco Trevisan (Treviño)
f37b74b65a build: Support building with old polkit
Some distros as LTS ones may still have old versions of polkit
gobject.

Since we only depend on the new polkit because of auto-pointers,
let's add a tiny compatibility layer to make possible to get
p-p-d also working on older stable distros as OEMs may like.
2024-02-13 21:18:25 +01:00
Mario Limonciello
9f25cec345 Install custom debug message handler
Remove a lot of the unnecessary stuff about the process, and instead
pad out the domain to make it more accessible.

If running on an interactive terminal add color coding for warnings
and errors. If this behavior is not desirable for an interactive terminal,
NO_COLOR=0 can be set in the environment.
2024-02-13 20:10:30 +00:00
Mario Limonciello
e11eb6c28e Set the log domain for all source files 2024-02-13 20:10:30 +00:00
Mario Limonciello
291f8debe9 Add pre-commit rule for running python black 2024-02-13 20:04:46 +00:00
Mario Limonciello
55f2040e08 Add a unit test target for pylint on integration tests 2024-02-13 20:04:46 +00:00
Mario Limonciello
4896b3f1ec Reformat all integration tests using black and pylint 2024-02-13 20:04:46 +00:00
Mario Limonciello
f742b017b1 Reformat unittest_inspector.py using pylint and black 2024-02-13 20:04:46 +00:00
Mario Limonciello
8e49826403 Rename integration tests python file 2024-02-13 20:04:46 +00:00