Commit graph

72 commits

Author SHA1 Message Date
Bastien Nocera
07565ef6a1 all: Remove Lid handling
It is now handled solely in logind to take power management decisions,
and in the compositor for making decisions related to available
displays.

See:
https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html
2023-07-06 11:09:42 +02:00
Bastien Nocera
e4e498e198 linux: Fix integration test to work under jhbuild
Fixes: 648abe9c27 ("tests: Test a client running while daemon restarts")
2023-07-06 10:07:08 +02:00
Bastien Nocera
f8fe036331 linux: Work-around potential race in test_headset_hotplug 2023-07-05 17:39:19 +02:00
Bastien Nocera
53ccc01be9 linux: Add test for device signals with wireless_status 2023-07-05 17:39:19 +02:00
Bastien Nocera
4d3d8759db linux: Add wait_for_mainloop() test helper 2023-07-05 17:39:19 +02:00
Michael Biebl
dec9468136 linux: Fix integration test to work with system installed upower binary
Fixes: 648abe9c27 ("tests: Test a client running while daemon restarts")
Closes: #241
2023-07-05 15:30:47 +00:00
Bastien Nocera
95de7181dd linux: Add test for is-present changes at runtime 2023-07-04 15:20:20 +02:00
Bastien Nocera
648abe9c27 tests: Test a client running while daemon restarts 2023-07-04 10:25:44 +02:00
Bastien Nocera
80bc0d7c79 linux: Add test for "wireless_status" sysfs attribute 2023-07-03 17:15:07 +02:00
Bastien Nocera
babe81a871 linux: Add headset hotplug test 2023-07-03 16:07:46 +02:00
Bastien Nocera
b83b0ff568 linux: Add test for duplicate USB/Unifying devices 2023-04-18 12:31:12 +02:00
stuarthayhurst
8356dd01d6 tests: Add test for siblings overwiting good type guesses 2023-04-17 15:02:44 +02:00
Bastien Nocera
5dbd51c47a linux: Add test about headset devices detection 2023-04-15 15:17:13 +02:00
Bastien Nocera
fa58832bd1 tests: Fix charging test in test_battery_state_guessing
Wait longer for the state guessing to actually kick in, 25 seconds was
too slow and we were getting the old state instead.
2023-04-15 14:10:23 +02:00
Bastien Nocera
40828daa8b tests: Remove assertion in test_battery_state_guessing
The history clearing doesn't work, see:
https://gitlab.freedesktop.org/upower/upower/-/issues/230
2023-04-15 13:17:59 +02:00
Bastien Nocera
5db1bce65f tests: Fix discharge rates in test_battery_state_guessing
up_device_battery_estimate_power() expects a charge/discharge rate of
0.5W to be significant, but the existing code yielded a rate of
-0.000240W.

Fix the units so that the amount of change in energy_now is at least
1W/s converted to µWh.
2023-04-15 12:16:19 +02:00
Bastien Nocera
b3c439ab4a linux: Fix getting properties in assertDevs()
Now that device loop is fixed, we also need to fix the D-Bus object
path for the devices themselves to match what UPower generates so
we can get its properties.

As we iterate over the expected array, the elements are the basenames
of those object paths. Reconstruct the full object paths by prepending
/org/freedesktop/UPower/devices/
2023-04-14 13:50:49 +02:00
Bastien Nocera
32e2cd5eb9 linux: Fix broken assertDevs() device loop
The test uses a generator to get the list of basenames for the devices:
names = (n.split('/')[-1] for n in devs)

Unfortunately, using that "names" varible will consume the generator,
and our array will be lost.

When passing a device dictionary, this code:
print(sorted(names))
print(sorted(names))
will yield:
['battery_hidpp_battery_0']
[]

Save the sorted array, and use that to test for properties equality.
2023-04-14 13:50:19 +02:00
Bastien Nocera
810c1214a5 linux: Test fix for warning when a duplicate device appears
Make the Bluetooth device appear first.
2023-02-28 14:14:59 +01:00
Bastien Nocera
32b0e098a1 linux: Test adding Bluetooth devices after daemon start
As is usually the case in reality, as bluez must be started for
Bluetooth devices to be able to connect.
2023-02-28 14:14:59 +01:00
Bastien Nocera
b6143527ef linux: Fix dbusmock addition of fake battery
We need to send the InterfacesAdded signal in case upower is already
started, so it can properly keep track of the interesting bluez devices.
2023-02-28 13:42:36 +01:00
Bastien Nocera
b7e406d9f9 linux: Add test for Logitech HID++/Bluetooth deduplication
This tests for the device-removed g_warning(), following the Alias
property on bluez devices, and the "Unhandled key" warnings.
2023-02-27 14:39:36 +01:00
Bastien Nocera
3bf5a095ac linux: Fix device paths in tests
add_device() doesn't need the full sysfs path if there's a parent,
otherwise this section of the path will be duplicated.
2023-02-27 14:12:39 +01:00
Bastien Nocera
b2cbf01090 linux: Test for "present" sysfs attribute handling 2023-02-21 15:19:46 +01:00
Maciej S. Szmigiero
dcb4600b33 enumerator-udev: also check for an idevice on "usb" subsystem
Commit 1550d50f ("linux: Remove "usb" subsystem match") broke detection of
some idevices, since it left just the "usbmisc" subsystem match while some
idevice / kernel combinations (at least an iPhone 11 on a 6.0 kernel) don't
present any such udev usbmisc devices.
However, they do present "usb" subsystem ones, so add this match back.

Leave idevice detection also for the "usbmisc" match since that's what the
original (known working) code before aforementioned commit did - it is
possible that it is required for some kernel / idevice combinations.
2022-10-29 15:32:04 +02:00
Bastien Nocera
b1edcc7cbb linux: Test whether BT mice get de-duplicated 2022-09-05 17:47:08 +02:00
Bastien Nocera
7f28aa5525 linux: Make BT mouse export its serial number
As a real mouse would.
2022-09-05 17:47:08 +02:00
Bastien Nocera
3265ce3ca6 linux: Make BT mice use the same address in tests
So we can use, one, the other, or both, and still see a single device.
2022-09-05 17:47:08 +02:00
Benjamin Berg
3c4f902fbd test: Add battery ID changing test for history loading/saving 2022-06-22 18:38:49 +02:00
Benjamin Berg
8817dec73f test: Fix flaky battery aggregation test
It seems that the test was still flaky, the reason for that would be
that we did not explicitly wait for the log line saying that the
aggregate state was calculated.

The only reason that it did not consistently fail appears to be that
searching for the state conflict caused messages to be skipped. That is
wrong, we should account for every "Calculating percentage" message to
ensure that upowerd and the test is in sync.
2022-06-21 13:26:39 +02:00
Benjamin Berg
8ec7362e93 battery: Add full/empty guessing based on capacity
Assuming we have some estimation for the current battery capacity (i.e.
percentage), we can infer a FULL/EMPTY state. Do so if the battery state
is unknown.

Related: #196
2022-06-21 11:16:27 +02:00
Benjamin Berg
14f06728b5 test: Add test for charging/discharging guessing based on rate
See: #196
2022-06-21 11:16:01 +02:00
Benjamin Berg
6fedd0f20a linux: Use new battery class and drop unused code
This makes the switch. There are a few behaviour changes with regard to
estimations (which hopefully got both simpler and more robust at the
same time).
2022-06-21 11:16:01 +02:00
Benjamin Berg
54e396e7ae test: Disable battery polling to make test more stable
Otherwise the fast repolling can get in-between, cause extra logging and
trigger a failure.
2022-06-15 14:09:14 +02:00
Benjamin Berg
4dac45e53a test: Test state guessing for one and two batteries
The state guessing code based on the AC state was not tested well.
Improve the test by testing both 1 and 2 batteries and checking the
reported state in more detail.
2022-06-14 17:51:06 +02:00
Benjamin Berg
a78ee60390 test: Properly wait for idle handler after uevents
The state aggregation test requires an idle handler to run, which can be
a bit unreliable as it may or may not run twice.

Force running it twice and add code to wait for it to complete. Do so
properly by waiting for the correct log messages rather than sleeping so
that everything is ordered nicely while not slowing down the test a lot.

Closes: #193
2022-06-09 12:38:34 +02:00
Benjamin Berg
c6a851d798 test: Add test for mice that have keys
These should not be detected as keyboards.
2022-06-08 12:55:59 +02:00
Benjamin Berg
1587b37707 test: Test all possible inputs for daemon state aggregation
This adds a test that checks all possible inputs for the battery state
aggregation. Not all states are actually tested in this case, as some
states may be handled through state inference and others might not be
well defined.
2022-06-07 16:07:03 +02:00
Benjamin Berg
792fc7bb1b supply: Consistently use 90% threshold to consider a battery full 2022-06-03 10:36:02 +02:00
Benjamin Berg
c330351937 test: Disable systemd v251 sysfs verification
The umockdev code to disable it by setting the variable does not
propagate through python. Set the variable here until there is a more
permament solution available.
2022-05-25 16:57:21 +02:00
Benjamin Berg
66eb9b9d7a test: Stop processes using cleanup function
Using tearDown is brittle, as an assertion will stop it from running
through completely. So move cleanup into a helper that is called via
addCleanup for logind and bluez.
2022-05-20 14:41:52 +02:00
Benjamin Berg
41bceac6ef test: Only assert daemon log is closed if daemon is started 2022-05-20 14:37:23 +02:00
Benjamin Berg
6d947c0532 test: Do not redirect helper stdout
There is no need to do so, so drop the redirection.
2022-05-20 14:37:02 +02:00
Benjamin Berg
f1c00e50c2 test: Allow daemon to take 5 seconds for shutdown
It seems like shutdown can take more than 2 seconds on some slow
systems. So increase to 5 seconds which hopefully is long enough.

Closes: #188
2022-05-20 14:35:23 +02:00
Benjamin Berg
c64b020f99 test: Turn off buffering when executing directly
It can be a bit unepxected if results are not printed immediately, so
turn off buffering. We could possibly also reopen sys.stdout, but this
is good enough in many cases.
2022-05-20 14:35:11 +02:00
Benjamin Berg
267f5ea8d3 linux: Fix exception check when on test daemon shutdown
subprocess.Popen.wait throws subprocess.TimeoutExpired not TimeoutError.

Related: #188
2022-05-19 11:45:55 +02:00
Benjamin Berg
ab08a4188f linux: Add test verifying sibling tracking cleanup works
This tests that the code to track siblings is working correctly and that
it will clean up the entries stored in the cache when a device
disappears.
2022-05-17 10:40:58 +02:00
Benjamin Berg
6db0627aaa linux: Add wacom tests 2022-05-16 16:42:30 +02:00
Benjamin Berg
76a99a7638 linux: Add helper to assert devices and properties
Just to make it a bit nicer to do assertions on devices and properties.
2022-05-16 16:40:00 +02:00
Benjamin Berg
275db91afd linux: Do not create intermediate proxy to fetch properties
There is no need for an intermediate proxy object, adding it just
results in extra overhead that is not needed.
2022-05-16 16:40:00 +02:00