test-libudev.c revision 912541b0246ef315d4d851237483b98c9dd3f992
/*
* test-libudev
*
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <syslog.h>
#include <fcntl.h>
#include "libudev.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
{
}
{
const char *str;
int count;
struct udev_list_entry *list_entry;
count = 0;
count++;
}
if (count > 0)
count = 0;
printf("property: '%s=%s'\n",
count++;
}
if (count > 0)
printf("\n");
}
{
struct udev_device *device;
printf("no device found\n");
return -1;
}
return 0;
}
{
struct udev_device *device;
struct udev_device *device_parent;
return -1;
printf("looking at parents\n");
do {
} while (device_parent != NULL);
printf("looking at parents again\n");
do {
} while (device_parent != NULL);
return 0;
}
{
struct udev_device *device;
return -1;
return 0;
}
{
struct udev_device *device;
printf("looking up device: 'block':'sda'\n");
return -1;
printf("looking up device: 'subsystem':'pci'\n");
return -1;
printf("looking up device: 'drivers':'scsi:sd'\n");
return -1;
printf("looking up device: 'module':'printk'\n");
return -1;
return 0;
}
{
struct udev_list_entry *list_entry;
int count = 0;
struct udev_device *device;
printf("device: '%s' (%s)\n",
count++;
}
}
return count;
}
{
int fd_ep;
int fd_udev = -1;
if (fd_ep < 0) {
printf("error creating epoll fd: %m\n");
goto out;
}
if (udev_monitor == NULL) {
printf("no socket\n");
goto out;
}
printf("filter failed\n");
goto out;
}
if (udev_monitor_enable_receiving(udev_monitor) < 0) {
printf("bind failed\n");
goto out;
}
printf("fail to add fd to epoll: %m\n");
goto out;
}
printf("fail to add fd to epoll: %m\n");
goto out;
}
for (;;) {
int fdcount;
struct udev_device *device;
int i;
printf("waiting for events from udev, press ENTER to exit\n");
for (i = 0; i < fdcount; i++) {
printf("no device from socket\n");
continue;
}
printf("exiting loop\n");
goto out;
}
}
}
out:
if (fd_ep >= 0)
return 0;
}
{
struct udev_queue *udev_queue;
unsigned long long int seqnum;
struct udev_list_entry *list_entry;
if (udev_queue == NULL)
return -1;
printf("queue is empty\n");
printf("get queue list\n");
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");
printf("queued: '%s' [%s]\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry));
printf("\n");
if (list_entry != NULL) {
else
}
printf("\n");
return 0;
}
{
struct udev_enumerate *udev_enumerate;
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'net' + duplicated scan + null + zero\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'block'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'not block'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'pci, mem, vc'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'subsystem'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'property IF_FS_*=filesystem'\n");
if (udev_enumerate == NULL)
return -1;
return 0;
}
{
{}
};
char path[1024];
const char *str;
printf("no context\n");
return 1;
}
for (;;) {
int option;
if (option == -1)
break;
switch (option) {
case 'p':
break;
case 's':
break;
case 'd':
break;
case 'h':
printf("--debug --syspath= --subsystem= --help\n");
goto out;
case 'V':
goto out;
default:
goto out;
}
}
/* add sys path if needed */
}
out:
return 0;
}