Commit graph

1548 commits

Author SHA1 Message Date
Benjamin Berg
792fc7bb1b supply: Consistently use 90% threshold to consider a battery full 2022-06-03 10:36:02 +02:00
Benjamin Berg
7ed8d0e9ef freebsd: Use correct up_make_safe_string definition 2022-06-03 10:35:58 +02:00
Benjamin Berg
e61bed3b90 common: Return original pointer from up_make_safe_string
This fixes the previous commmit to 190d12e292 ("common: Add a file
with common helper") which broke the string handling for the freebsd
backend.

Related: !144
2022-05-27 11:05:07 +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
190d12e292 common: Add a file with common helper
This removes some code duplication between the linux and freebsd
backend. And, this file could become home to other small helper
functions in the future.
2022-05-25 15:32:29 +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
aa646fa0ca meson: Allow unittest inspector to fail
It is only used to make the test output nicer, and it is completely fine
to fail.

Closes: #187
2022-05-17 16:02:49 +02:00
Benjamin Berg
017ac33d58 Release 0.99.18 2022-05-17 10:54:28 +02:00
Benjamin Berg
ddb0ce87e7 po: Update translation files
They were horribly outdated and many strings are not even used anymore.

Closes: #186
2022-05-17 10:54:28 +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
8c53faac81 linux: Do not rely on parent ID lookup to work at removal time
It appears that the parent ID lookup may not properly work when devices
are removed. Likely, because corresponding sysfs entries may not exist
anymore.

Fix this by attaching the ID to the stored object, allowing us to remove
it without calling device_parent_id() again.

Fixes: #185
2022-05-17 10:23:52 +02:00
Benjamin Berg
fa781e29da linux: Log debug message when siblings array becomes empty 2022-05-17 10:23:52 +02:00
Benjamin Berg
c2b7a53e71 linux: Track only first level of "input" entries for sibling matching
There is no need to track the children, as we'll already have the parent
in the lookup table and the parent will already have the correct tags.
2022-05-17 10:23:52 +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
ba728ee4eb linux: Update udev dumps to be usable with umockdev
This means adding appropriate attributes and removing some links that
appear to be duplicate.
2022-05-16 16:40:00 +02:00
Benjamin Berg
bbb3c07f56 linux: Add udev dumps for wacom devices
These are raw udev dumps, we'll need to update them so that they become
valid umockdev device descriptions.
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
Benjamin Berg
4400ad0944 linux: Move udev device discovery into a separate class
The only thing that is still discovered from the backend is the lid
switch. Though we could also handle that by having a separate signal
that is fired instead of a separate udev client.

This refactors the sibling detection to be event driven. Also changed is
that we jump certain device types when searching for a parent, which
fixes the discovery of wacom tablets for example.

Closes: #182
2022-05-16 16:40:00 +02:00
Benjamin Berg
896c77dc7d enumerator: Add UpEnumerator class and udev implementation 2022-05-16 15:48:09 +02:00
Benjamin Berg
10290e0e6d rules: Update hwdb from upstream NUT 2022-05-16 14:00:52 +02:00
Alberts Muktupāvels
96bbea846b
linux: use correct object when emitting device-removed signal
TI:14:27:16	BlueZ disappeared
TI:14:27:16	emitting device-removed: /org/bluez/hci0/dev_00_11_67_2A_6D_7A
(upowerd:228434): GLib-GObject-WARNING **: 14:27:16.218: invalid cast from 'GDBusObjectProxy' to 'UpDevice'
TI:14:27:16	up_daemon_device_removed_cb: assertion 'UP_IS_DEVICE (device)' failed
2022-05-16 14:35:22 +03:00
Benjamin Berg
2151d7c0e4 linux: Test that line-power events don't cause battery polling
This verifies that we do not start polling the battery if we got a
spurious event related to a line-power supply.
2022-05-16 09:14:07 +00:00
Benjamin Berg
b4e9cd9739 daemon: Only refresh batteries when the "online" state changes
There is no need to refresh batteries if we just re-read the status of a
line power supply without actually seeing a change ("online" vs.
"update-time" property).

Fixes: #184
2022-05-16 09:14:07 +00:00
Benjamin Berg
4cccf81cad supply: Avoid emitting notification for line power changes
Setting the property will create a notification, which in turn causes
the daemon code to trigger a battery refresh. As such, avoid actually
setting the property if it still has the same value.

Note that we shouldn't usually get spurious notifications, but it is
good to be safe here in case e.g. a bad firmware just sends out
notifications when the battery capacity changes.

Related: #184
2022-05-16 09:14:07 +00:00
Benjamin Berg
2d6080d253 supply: Drop is_power_supply attriute that never changes
The class kept track of the power-supply property internally. However,
the value is static, and it is only needed to be queried in very few
cases.

Move the property setting to an earlier time and stop touching it when
it is not needed.
2022-05-16 09:14:07 +00:00
Benjamin Berg
6cfccef2ad device-supply: Assume USB type supplies the system
The USB device type for power supplies are always USB ports of the
system. As such, we should be able to assume that they are power
supplies.

Fixes: #183
2022-05-16 09:07:57 +00:00
Benjamin Berg
b342964400 linux: Re-poll batteries after a line power change
When a change on a line power occurs, then re-poll all batteries
aggressively for a while. It is very common for batteries to take about
a second to refresh their state and many will not send appropriate
notifications in this case.

Closes: #179, #159
2022-05-13 16:07:38 +02:00
Benjamin Berg
90c84ea95c linux: Ensure clean shutdown after tests
Instead of just killing upower, try to send SIGTERM for a clean
shut-down. Kill the process if it doesn't quit within two seconds, and
check that the service exits cleanly.
2022-05-12 14:42:35 +02:00
Benjamin Berg
24917a4b66 main: Handle SIGTERM in addition to SIGINT
It is common to stop services using SIGTERM. Add an appropriate handler
that stops upower.
2022-05-12 14:39:16 +02:00
Benjamin Berg
76b4c31ee9 linux: Add non-hid parent to hidpp tests
While not needed currently, there is a discussion to ignore the "hid"
subsystem parents when searching for siblings. Add in appropriate
parents to the tests so that such a change will not result in a failure.
2022-05-12 11:16:42 +02:00
Benjamin Berg
4fca99a819 device-supply: Fix leak of serial_number string 2022-05-12 11:09:33 +02:00
Benjamin Berg
71f1908683 daemon: Fix reference counting at daemon shutdown
Commit b78a2ab980 ("daemon: Stop passing UpDevice reference to the
daemon") fixed the fact that the signal passed a reference to the
daemon. This fix also implied that the UpDaemon object does not own a
reference to the device itself, instead relying on the UpDeviceList to
keep it alive.

With this change, there is no need to drop the extra reference when
clearing the device list, remove the code accordingly.

Reported-by: Alberts Muktupāvels <alberts.muktupavels@gmail.com>
2022-05-12 10:13:15 +02:00
Benjamin Berg
565b3531d6 linux: Test changes after BT HID power_supply subtree move
This causes an add that we ignore, after that we should still see
updates from the device (and the add itself should trigger an update).

Verify that this works by setting the capacity to 20.
2022-05-11 10:16:50 +02:00
Benjamin Berg
dac0e3bc11 linux: Remove/add device if the sysfs path changed 2022-05-11 10:16:50 +02:00
Benjamin Berg
b78a2ab980 daemon: Stop passing UpDevice reference to the daemon
There is no need to do so, in particular as the signal emission code
will keep a reference to the object internally.
2022-05-10 19:19:08 +02:00
Benjamin Berg
4651088391 device: Use modern macros for class declaration
This removes the priv member from the struct, but also means that
g_autoptr works with the class.
2022-05-10 17:14:09 +02:00
Benjamin Berg
d8eb09fba3 meson: Bump required glib version to 2.58 2022-05-10 15:45:27 +02:00
Benjamin Berg
baa14729a0 meson: Bump meson version and fix deprecations 2022-05-10 15:39:24 +02:00
Benjamin Berg
a87cb420cd linux: Store lid input device outside of device list
The device list class now assumes that contained objects are UpDevice
and we cannot store UpInput objects inside it anymore. Switch the lid
switch to be stored in the linux backend directly rather than allocating
a UpDeviceList just for that.

This fixes commit ddc739f38b ("device-list: Remove unnecessary native
argument")
2022-05-10 11:06:25 +02:00
Benjamin Berg
3c520fb590 linux: Use OutputChecker to inspect daemon log
This also means the daemon log is stored even when succeeding, making it
a bit easier to inspect tests overall.
2022-05-10 11:06:18 +02:00
Benjamin Berg
11fb06d8ae ci: Permit XML to be invalid to avoid issues with colored logs 2022-05-10 11:06:18 +02:00
Benjamin Berg
b0f1e28b42 linux/freebsd: Do not print invalid characters into log
Instead, just hex-encode them, they are invalid, it is not like having
them in raw in the log is helpful.
2022-05-10 11:06:18 +02:00
Benjamin Berg
26dee1fe3f daemon: Push internal refreshes into idle handler
As these are triggered by property changes, they may happen numerous
times for a single update. Avoid executing these (potentially expensive)
updates multiple times by pushing them into the next main loop
iteration.
2022-05-10 11:06:18 +02:00
Benjamin Berg
b9bf475459 linux: Enable fatal-warnings for most tests 2022-05-10 11:06:18 +02:00