diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-01 09:34:07 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-01 09:34:07 +0200 |
commit | 64ccdf8269e1e0fbde7acbe4837c2c2f2c41659c (patch) | |
tree | 16c8af72094ad8ed387eac96af26c3befc03346d /udev/lib/test-libudev.c | |
parent | d41b956e7f31b2ad708c1cce86eae9e9ba365a6c (diff) |
libudev: add queue interface
Diffstat (limited to 'udev/lib/test-libudev.c')
-rw-r--r-- | udev/lib/test-libudev.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/udev/lib/test-libudev.c b/udev/lib/test-libudev.c index 5e9897c715..9c7acb048a 100644 --- a/udev/lib/test-libudev.c +++ b/udev/lib/test-libudev.c @@ -19,6 +19,7 @@ #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> @@ -168,10 +169,9 @@ static int test_enumerate_print_list(struct udev_enumerate *enumerate) device = udev_device_new_from_syspath(udev_enumerate_get_udev(enumerate), udev_list_entry_get_name(list_entry)); if (device != NULL) { - printf("device: '%s' (%s) '%s'\n", + printf("device: '%s' (%s)\n", udev_device_get_syspath(device), - udev_device_get_subsystem(device), - udev_device_get_sysname(device)); + udev_device_get_subsystem(device)); udev_device_unref(device); count++; } @@ -230,6 +230,49 @@ static int test_monitor(struct udev *udev, const char *socket_path) return 0; } +static int test_queue(struct udev *udev) +{ + struct udev_queue *udev_queue; + unsigned long long int seqnum; + struct udev_list_entry *list_entry; + + udev_queue = udev_queue_new(udev); + if (udev_queue == NULL) + return -1; + seqnum = udev_queue_get_kernel_seqnum(udev_queue); + printf("seqnum kernel: %llu\n", seqnum); + seqnum = udev_queue_get_udev_seqnum(udev_queue); + printf("seqnum udev : %llu\n", seqnum); + + if (udev_queue_get_queue_is_empty(udev_queue)) + printf("queue is empty\n"); + printf("get queue list\n"); + udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue)) + printf("queued: '%s' [%s]\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry)); + printf("\n"); + printf("get queue list again\n"); + udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue)) + printf("queued: '%s' [%s]\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry)); + printf("\n"); + printf("get failed list\n"); + udev_list_entry_foreach(list_entry, udev_queue_get_failed_list_entry(udev_queue)) + printf("failed: '%s'\n", udev_list_entry_get_name(list_entry)); + printf("\n"); + + list_entry = udev_queue_get_queued_list_entry(udev_queue); + if (list_entry != NULL) { + printf("event [%llu] is queued\n", seqnum); + seqnum = strtoull(udev_list_entry_get_value(list_entry), NULL, 10); + if (udev_queue_get_seqnum_is_finished(udev_queue, seqnum)) + printf("event [%llu] is not finished\n", seqnum); + else + printf("event [%llu] is finished\n", seqnum); + } + printf("\n"); + udev_queue_unref(udev_queue); + return 0; +} + int main(int argc, char *argv[], char *envp[]) { struct udev *udev = NULL; @@ -351,6 +394,8 @@ int main(int argc, char *argv[], char *envp[]) test_enumerate_print_list(udev_enumerate); udev_enumerate_unref(udev_enumerate); + test_queue(udev); + test_monitor(udev, socket); out: udev_unref(udev); |