Commit graph

45 commits

Author SHA1 Message Date
Bastien Nocera
2fbf57b9bd tests: Simplify reading platform_profile value
Which allows us to ignore trailing spaces in the sysfs attribute, as
power-profiles-daemon writes those mock files without a linefeed, but
the real kernel (or some of our setup functions) would always append
a linefeed.
2021-03-19 13:18:43 +01:00
Bastien Nocera
d650d2e6b9 tests: Add helper which strips trailing newlines from sysfs attributes
This will come in handy.
2021-03-19 13:18:43 +01:00
Bastien Nocera
c7fb31632b main: Use a single driver for all the profiles
Of all the drivers that we've implemented, not a single one needed to
have different drivers to handle its different profiles, so simplify
things by having all the profiles be handled by a unique driver.

We still have separate drivers for separate types of hardware.
2021-03-19 11:06:37 +01:00
Martin Pitt
225d6e51d5 tests: Close leaked "unclosed file"
Fixes warning:
/usr/lib64/python3.9/unittest/case.py:550: ResourceWarning: unclosed file <_io.BufferedReader name=10>
  method()

See https://github.com/martinpitt/python-dbusmock/issues/67#issuecomment-800979091
2021-03-17 14:10:18 +01:00
Bastien Nocera
4c86f30cda tests: Add HP WMI test 2021-03-17 13:25:30 +01:00
Bastien Nocera
a12820ab4f platform-profile: Restore existing profile on start 2021-03-16 17:11:37 +01:00
Bastien Nocera
c06f53cadc tests: Add missing trailing linefeeds to platform_profile tests 2021-03-16 16:50:37 +01:00
Bastien Nocera
59c5bc1749 tests: Add missing trailing linefeeds to intel-pstate tests 2021-03-16 16:50:37 +01:00
Bastien Nocera
b3ab935ac8 intel-pstate: Fix inhibition not being detected
We should have inhibited the performance profile when "no_turbo" was set
to "1", but we didn't take the linefeed into account, so we never
actually read that value.
2021-03-16 16:49:36 +01:00
Hans de Goede
efa7e4f48e platform-profile: Fix ThinkPad lapmode detection with libgudev <= 234
g_udev_device_get_sysfs_attr_as_boolean_uncached in libgudev <= 234 does
not work, see: https://gitlab.gnome.org/GNOME/libgudev/-/issues/7

Since the dytc_lapmode file always contains an integer 0/1 value we
can easily workaround this libgudev issue by switching to
g_udev_device_get_sysfs_attr_as_int_uncached.

Also update the tests to include the '\n' for the dytc_lapmode sysfs
attribute values, like on real hardware.
2021-03-16 12:06:30 +01:00
Hans de Goede
1cbeca326e platform-profile: Fix the driver to work with real hardware
The platform_profile_choices sysfs file contains the available profiles
separated by spaces, not newlines, with a newline at the end (as all
text based sysfs files have a newline at the end).

Replace the g_strsplit(..., "\n", -1) with a g_strsplit_set (..., " \n", -1)
so that the choices get split on the spaces, and the trailing "\n" gets
discarded.

Also update the integration-test to match.
2021-03-16 12:06:28 +01:00
Bastien Nocera
07dbe8e8da tests: Change platform_profile in the right order
Change platform_profile_choices before platform_profile, so we only get
probed when all the profile choices are available.

This behaviour is similar to what the kernel drivers do, setting up
the bitmask of choices, before running platform_profile_register().
2021-03-15 13:18:17 +01:00
Bastien Nocera
556b8b3f98 tests: Work-around profiles reload taking too long 2021-03-15 12:38:55 +01:00
Bastien Nocera
2569d8e59f tests: Add test for the deferred probe 2021-02-09 10:06:43 +01:00
Bastien Nocera
6236c1bccf main: Exit with 1 if there are startup D-Bus errors
If there are D-Bus errors on startup such as the daemon already being
started, make main() return with an error.
2021-02-08 16:58:41 +01:00
Bastien Nocera
ec1188d347 lenovo-dytc: Rename to platform-profile
As the only Lenovo DYTC specific interface is now optional, rename the
driver.
2021-02-08 16:01:18 +01:00
Bastien Nocera
3b949722e9 tests: Remove dytc_lapmode creation from tests
This ensures that commit "lenovo-dytc: Make dytc_lapmode proximity
sensor optional" works as expected.
2021-02-08 15:58:04 +01:00
Bastien Nocera
7efbfec6fc tests: Split off creation of platform_profile from dytc device
As the proximity sensor should be optional.
2021-02-08 15:25:11 +01:00
Bastien Nocera
19199f8673 tests: Remove extra debug 2020-11-19 17:32:13 +01:00
Bastien Nocera
4242f2a127 lenovo-dytc: Use new ACPI platform_profile API
See https://patchwork.kernel.org/project/platform-driver-x86/patch/20201115004402.342838-1-markpearson@lenovo.com/
2020-11-19 17:32:13 +01:00
Bastien Nocera
28ae49375d build: Pass top_srcdir to test suite 2020-11-19 17:32:13 +01:00
Bastien Nocera
169a8cd788 tests: Factor out creation of dytc device 2020-11-19 17:32:13 +01:00
Bastien Nocera
c8b303406c intel-pstate: Fix paths when running under umockdev
UMOCKDEV_DIR is the mock root directory, not the mock /sys directory.
2020-11-05 17:00:54 +01:00
Bastien Nocera
85c94a6993 tests: Remove libtool usage
There's never any need for us to use libtool to spawn the daemon, we
don't use autotools.
2020-11-05 11:06:31 +01:00
Bastien Nocera
f343f4be04 main: And listen to "profile-changed" signal
This should allow drivers to change their profile internally, and
trickle back up to the UI, such as when using keyboard shortcuts.

Closes: #15
2020-09-15 15:29:05 +02:00
Bastien Nocera
c7e984403d tests: Remove unused uevents
The real kernel driver doesn't emit uevents when the state changes, just
file change notifications, so there's no need to emit those events
anymore.
2020-09-15 15:29:05 +02:00
Bastien Nocera
b219d729d7 tests: Crash if there are warnings in the daemon 2020-09-15 11:51:11 +02:00
Bastien Nocera
07ad49a0f8 tests: Remove a number of uses of have_text_in_log()
have_text_in_log() just checks for the presence of that string in the
log for the *whole* test, not just for that text to appear. We should be
checking the number of instances before the change and after the change
if we wanted to do this well, but it's easier to wait a little for a
property change on the D-Bus interface.
2020-09-15 11:51:04 +02:00
Bastien Nocera
ebf9e5b7c8 lenovo-dytc: Implement perfmode
Implement dytc_perfmode, as per https://patchwork.kernel.org/patch/11678983/
2020-09-09 12:33:20 +02:00
Bastien Nocera
953eb716fd tests: Fix tests for lenovo_dytc driver changes
We'll also need a dytc_perfmode sysfs file to have a working lenovo_dytc
PpdDriver.
2020-09-09 12:33:20 +02:00
Bastien Nocera
d6ef7bcfc8 tests: Fix one of the tests for slower machines
======================================================================
FAIL: test_intel_pstate_balance (__main__.Tests)
Intel P-State driver (balance)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/power-profiles-daemon-0.1/tests/integration-test", line 375, in test_intel_pstate_balance
    self.assertEqual(contents, b'balance_power')
AssertionError: b'' != b'balance_power'
----------------------------------------------------------------------
2020-09-09 11:39:45 +02:00
Bastien Nocera
95a67713cf intel-pstate: Inhibit perf mode when overheating
thermald can disable turbo altogether if needed to avoid reaching
too high operating temperatures, so make the p-state driver monitor
this, and mark the performance mode as inhibited if "no_turbo" is
set.

Closes: #14
2020-09-08 18:09:04 +02:00
Bastien Nocera
8243b945ce tests: Add tests for on-battery P-State driver 2020-09-04 15:10:16 +02:00
Bastien Nocera
3af71eb131 intel-pstate: Monitor battery status to choose right balanced pref
Prefer "balance_performance" p-state preference when the machine is on
mains, and "balance_power" when it's on battery.
2020-09-04 15:10:16 +02:00
Bastien Nocera
45ccd0b230 tests: Add Intel P-State driver tests 2020-09-04 15:10:16 +02:00
Bastien Nocera
8b3d366219 main: Get rid of "SelectedProfile" property
The original idea was to have a "SelectedProfile" property that would be
settable by the user, but could be different from the "ActiveProfile" if
the hardware's performance mode wasn't available for example.

It turns out that having 2 separate states makes for very confusing UI,
so if the performance profile becomes inhibited and it's the current one,
the active profile will automatically switch to balanced and stay there.
2020-08-12 16:55:58 +02:00
Bastien Nocera
a531044de4 main: Add fake performance driver 2020-08-12 15:31:54 +02:00
Bastien Nocera
f5b489aaf9 tests: Test previous commit fix
Test for "main: Fix PerformanceInhibited property not being up-to-date"
2020-08-12 15:22:41 +02:00
Bastien Nocera
97f449a497 main: Add "Actions" property
That allows API users to programmatically check whether a particular
functionality is implemented in the daemon, eg. if we wanted to move
GPU performance modes from gamemode to this daemon, gamemode could
query whether that feature was implemented and available in the backend.

Closes: #12
2020-08-12 11:31:34 +02:00
Bastien Nocera
e347845096 main: Rename Inhibited to PerformanceInhibited
Make it clear that we don't expect any profile to ever be inhibited,
apart from the performance profile.
2020-08-10 16:42:07 +02:00
Bastien Nocera
bc2961a406 tests: Test "Fix transitions if one profile is inhibited" 2020-08-10 15:43:20 +02:00
Bastien Nocera
b8798b5c20 lenovo-dytc: Handle power-saver profile as well 2020-08-06 14:42:48 +02:00
Bastien Nocera
17b655f9f5 main: Make PpdProfile into a bitmask
So that drivers can support multiple profiles.
2020-08-05 15:29:27 +02:00
Bastien Nocera
84c6470803 tests: Add trickle-charge action integration test 2020-07-20 17:04:17 +02:00
Bastien Nocera
46ea9c7875 tests: Add integration tests 2020-07-16 17:07:10 +02:00