Commit graph

689 commits

Author SHA1 Message Date
Martin Pitt
37fdb2c959 trivial: Fix Linux integration-test for distcheck
distcheck uses a separate build tree, thus call the script from the right
directory. Also actually ship it in release tarballs.
2011-04-26 12:48:23 +02:00
Martin Pitt
065c597b88 Respect $UPOWER_CONF_FILE_NAME in up_config_init()
The daemon test in up-self-test instantiates an UpDaemon object, which creates
an UpConfig object. Unlike UpDaemon itself, up_config_new() did not check for
$UPOWER_CONF_FILE_NAME to find the configuration file name.

This had the effect that a make check/distcheck run would always try to use the
system wide configuration file, and fail if --sysconfdir wasn't specified
appropriately.
2011-04-26 12:44:21 +02:00
Martin Pitt
5cb1f4a9a3 Consider a discharging UPS as "on battery"
Implement get_{on,low}_battery() methods on HID devices for Linux. This will
treat discharging UPSes like batteries and set the "on-battery" and
"on-low-battery" properties accordingly.

This also fixes the test_ups_ac() case in the Linux integration tests.
2011-04-26 11:50:36 +02:00
Martin Pitt
a786d2fd16 Fix "unknown" battery status guessing to not be recursive
Stop querying the global "on-battery" property when trying to guess the status
of a battery which reports as "unknown", as "on-battery" is itself defined in
terms of the states of the individual batteries. Instead, guess the state based
on whether we have any AC available; if so, we can reasonably assume
charging/discharging based on whether any AC is online. If no AC is present,
assume discharging (as we did before), but only if we have only one battery.

Stop guessing for the case where we don't have any AC device, "unknown" battery
state, and multiple batteries, as then we can't know which battery is currently
discharging.

https://bugs.freedesktop.org/show_bug.cgi?id=24371
2011-04-26 11:50:36 +02:00
Martin Pitt
7c617ba6f1 Run Linux integration tests in "make check"
If possible, run the tests under dbus-launch to ensure that there is a private
D-BUS session bus. This allows the tests to work in e. g. a clean package build
environment, and also avoids messing with the real user session bus.
2011-04-26 11:50:36 +02:00
Martin Pitt
e1f4aa38de Add integration test suite for Linux
Add src/linux/integration-test: This is a Python unittest based test suite
which provides methods for building a sandbox sysfs tree, runs upowerd
in it, and checks for correct properties.

As it is really hard to provide fake uevents, this currently only works for
properties which do not depend on dynamic system changes, i. e. you can
currently only check the status after coldplugging.

However, this already provides enough possibilities for functionality and
regression testing, and exposes some bugs with determining the "OnBattery"
property under certain conditions like the ones described in
<https://bugs.freedesktop.org/show_bug.cgi?id=24371>.

If any of the tests fails, the daemon log will be printed to stderr for easier
debugging.

With the previous commit that adds "upowerd --test", we can also run
the integration tests as non-root. If they are called as root, start upowerd
normally on the system bus, otherwise on the session bus with --test.
2011-04-26 11:50:36 +02:00
Martin Pitt
eddcf0ef3d Add option to run daemon on the session bus for testing
Add a daemon option --test which will run upowerd on the session bus.  This
allows us to run tests without interfering with the system instance. This also
avoids any root privileges entirely, which permits running integration tests as
part of a package build.
2011-04-26 11:50:36 +02:00
Martin Pitt
f65aa4dbf2 Support virtual UPS devices for testing
If a HID device is marked with the UPOWER_FAKE_DEVICE udev property, don't send
ioctl commands to it, but instead read status and percentage from udev
properties as well (UPOWER_FAKE_HID_CHARGING and UPOWER_FAKE_HID_PERCENTAGE).

This allows developers or a test suite to test the behaviour of UPSes without
actually having one.
2011-04-26 11:28:32 +02:00
Martin Pitt
c25079b652 src/.gitignore: Fix file name
"dkp-self-test" is now called "up-self-test".
2011-04-15 18:06:45 +02:00
Martin Pitt
8a9d9a47bd selftest: Globally set configuration path
Set $UPOWER_CONF_FILE_NAME before calling the tests, so that other tests can
also initialize the daemon.
2011-04-13 11:32:32 +02:00
Martin Pitt
0716e21a33 fix up-self-test build
It uses up_config_*() functions, so we need to build it against up-config.{h,c}

Fixes build failure:

up_self_test-up-daemon.o: In function `up_daemon_init':
/home/martin/upstream/upower/src/up-daemon.c:1047: undefined reference to `up_config_new'
[...]
2011-04-13 11:19:44 +02:00
Tobias Mueller
2cec4b7878 Do not overwrite aclocal flags in autogen, fixes b.fd.o #35261
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-31 19:45:24 +01:00
Richard Hughes
b458ef8250 trivial: fix whitespace issue with the last patch 2011-03-30 19:23:35 +01:00
Benson Leung
95ecdb25b2 Support batteries that report both energy and charge.
More cleanly support batteries that report both energy and charge,
but do not report power_now. One battery driver in drivers/power
(bq20z75) supports reporting energy and charge natively from the
fuel gauge, but does not report power_now. The previous legacy behavior
would ignore the existence of charge and treat current_now as
being in units of power.

Signed-off-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-30 14:16:21 +01:00
Richard Hughes
c98ca6f8f5 Add a config option 'IgnoreLid' so users with broken / inverted lid switches don't suspend at session start 2011-03-28 16:41:02 +01:00
Landry Breuil
3787531096 openbsd: fix warning, and set lid-present to no
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:25 +00:00
Landry Breuil
883da76819 openbsd: Add licence headers..
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:23 +00:00
Landry Breuil
08227a6416 openbsd: handle case when power is reported directly as Wh
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:21 +00:00
Landry Breuil
83e1e56938 openbsd: Add up_apm_device_refresh callback to device class
- move apm_fd to a global var atm, needs to be passed to a private native class
- propagate more error codes through some booleans
- history now works!

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:19 +00:00
Landry Breuil
53ba669490 openbsd: wip on acpibat_state, need to sort wh/ah units
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:16 +00:00
Landry Breuil
6dd2e35d6f openbsd: add up_backend_update_acpibat_state() and call it if acpibat0 device is found
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:15 +00:00
Landry Breuil
a65fdfc156 trivial: move #includes
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:13 +00:00
Landry Breuil
20a3759ab9 openbsd: rename get_sensor() to get_sensordev() for the sake of clarity
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:12 +00:00
Landry Breuil
1017f7399b openbsd: rename has_sensor() to get_sensor() and use it to grab the sensordev struct
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:09 +00:00
Landry Breuil
5e69186399 openbsd: add up_native_has_sensor() and use it in is_laptop()
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:07 +00:00
Landry Breuil
0580fed09a trivial: ignore libupshared too
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:05 +00:00
Landry Breuil
7dda4cd660 -Wuninitialized needs -O
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:00 +00:00
Landry Breuil
d51953c305 openbsd: assign callbacks to ac/batt device class
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:57 +00:00
Landry Breuil
8e84a6dbb4 openbsd: rip of get_on_battery/get_low_battery/get_online from freebsd backend
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:55 +00:00
Landry Breuil
08d46e4b90 trivial: fix indent
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:51 +00:00
Landry Breuil
164ac63f8d openbsd: time-to-empty is in seconds
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:49 +00:00
Landry Breuil
0d7b9fe1d5 trivial: silence warnings
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:48 +00:00
Landry Breuil
55408490d0 trivial: return NULL, shouldnt be reached anyway
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:26 +00:00
Landry Breuil
b03290f11d openbsd: Declare prototypes for get_power_info/get_battery_state_value
Pass struct apm_power_info ptr as argument instead of returning it

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:24 +00:00
Landry Breuil
564d1c47ad openbsd: cast NULL to void* to silence missing sentinel gcc warnings
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:23 +00:00
Landry Breuil
2533e75e77 openbsd: dont initialize props we wont likely set atm
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:22 +00:00
Landry Breuil
631869fdd5 openbsd: Update battery properties only if they really changed
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:20 +00:00
Landry Breuil
89c929d442 openbsd: update ac state only if state really changed
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:19 +00:00
Landry Breuil
c11e803058 openbsd: use g_debug instead of g_message, also log minutes_left
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:17 +00:00
Landry Breuil
d5b1d6d49f openbsd: move batt/ac properties update to their own separate functions
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:15 +00:00
Landry Breuil
8d2844c51c openbsd: No need for a delayed callback coldplugging devices
Coldplug them directly in up_backend_coldplug (only if is_laptop is true)

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:14 +00:00
Landry Breuil
afdef9d298 openbsd: add is_laptop boolean and only add ac/batt devices if true
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:12 +00:00
Landry Breuil
7b4c52bfb9 openbsd: set has-history & has-statistics to TRUE
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:11 +00:00
Landry Breuil
f001a92ec5 openbsd: add up_native_is_laptop()
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:09 +00:00
Landry Breuil
07100772ab openbsd: Move os-specific headers inclusion to up-apm-native.h
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:08 +00:00
Landry Breuil
527019ea82 openbsd: update ac online status too
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:07 +00:00
Landry Breuil
4ba9516b6a openbsd: cast battery_life to gdouble
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:05 +00:00
Landry Breuil
543159173a openbsd: Don't update percentage, probably missing a cast
Fix some return codes, and give sane defaults to ac/batt devices

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:04 +00:00
Landry Breuil
c9296f51ba openbsd: Use separate 'static' devices for ac and battery
Move UpApmNative object to its own header for use by UpBackend

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:02 +00:00
Landry Breuil
a5e0d246e0 openbsd: add dumb ApmNative gobject
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:01 +00:00