summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <raof@ubuntu.com>2013-12-19 12:37:27 +0800
committerRichard Hughes <richard@hughsie.com>2014-01-15 15:30:39 +0000
commit700e46119c5add30a8e71c5cca2107745651a2a6 (patch)
tree81e3d2f0f06f929c17cfaf63c6fdb98f882f5ecb
parent125b9aac29de830d76bb6edf0e0107851a278dc5 (diff)
downloadcolord-700e46119c5add30a8e71c5cca2107745651a2a6.tar.gz
libcolorhug: Handle failure to initialise GUsb in self-tests
This can fail, and does in my VMs and on the Ubuntu autopkgtest infrastructure. Since there are other tests of libcolorhug that can usefully be run, handle this like a failure to find a ColorHug on the USB bus, which is already non-fatal.
-rw-r--r--lib/colorhug/ch-self-test.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/colorhug/ch-self-test.c b/lib/colorhug/ch-self-test.c
index e2c4de6..f24d893 100644
--- a/lib/colorhug/ch-self-test.c
+++ b/lib/colorhug/ch-self-test.c
@@ -95,6 +95,9 @@ ch_test_device_queue_func (void)
/* try to find any ColorHug devices */
usb_ctx = g_usb_context_new (NULL);
+ if (usb_ctx == NULL)
+ return;
+
list = g_usb_device_list_new (usb_ctx);
g_usb_device_list_coldplug (list);
devices = g_usb_device_list_get_devices (list);
@@ -454,6 +457,13 @@ ch_client_get_default (GError **error)
/* try to find the ColorHug device */
usb_ctx = g_usb_context_new (NULL);
+ if (usb_ctx == NULL) {
+ g_set_error(error,
+ G_USB_DEVICE_ERROR,
+ G_USB_DEVICE_ERROR_NO_DEVICE,
+ "No device found; USB initialisation failed");
+ return NULL;
+ }
list = g_usb_device_list_new (usb_ctx);
g_usb_device_list_coldplug (list);
device = g_usb_device_list_find_by_vid_pid (list,