test: untabify
This commit is contained in:
@@ -37,7 +37,7 @@ test_enable_disable (TestFixture *fixture)
|
|||||||
|
|
||||||
/* Create port name, and add process ID so that multiple runs of this test
|
/* Create port name, and add process ID so that multiple runs of this test
|
||||||
* in the same system don't clash with each other */
|
* in the same system don't clash with each other */
|
||||||
ports[0] = g_strdup_printf ("abstract:port0:%ld", (glong) getpid ());
|
ports[0] = g_strdup_printf ("abstract:port0:%ld", (glong) getpid ());
|
||||||
g_debug ("test service generic: using abstract port at '%s'", ports[0]);
|
g_debug ("test service generic: using abstract port at '%s'", ports[0]);
|
||||||
|
|
||||||
/* Setup new port context */
|
/* Setup new port context */
|
||||||
|
186
test/lsudev.c
186
test/lsudev.c
@@ -30,94 +30,94 @@ static GMainLoop *loop = NULL;
|
|||||||
static void
|
static void
|
||||||
signal_handler (int signo)
|
signal_handler (int signo)
|
||||||
{
|
{
|
||||||
if (signo == SIGINT || signo == SIGTERM) {
|
if (signo == SIGINT || signo == SIGTERM) {
|
||||||
g_message ("Caught signal %d, shutting down...", signo);
|
g_message ("Caught signal %d, shutting down...", signo);
|
||||||
g_main_loop_quit (loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_signals (void)
|
setup_signals (void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
|
|
||||||
sigemptyset (&mask);
|
sigemptyset (&mask);
|
||||||
action.sa_handler = signal_handler;
|
action.sa_handler = signal_handler;
|
||||||
action.sa_mask = mask;
|
action.sa_mask = mask;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigaction (SIGTERM, &action, NULL);
|
sigaction (SIGTERM, &action, NULL);
|
||||||
sigaction (SIGINT, &action, NULL);
|
sigaction (SIGINT, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
println (guint indent, const char *fmt, ...)
|
println (guint indent, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
GString *output;
|
GString *output;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_return_if_fail (fmt != NULL);
|
g_return_if_fail (fmt != NULL);
|
||||||
|
|
||||||
output = g_string_sized_new (250);
|
output = g_string_sized_new (250);
|
||||||
|
|
||||||
for (i = 0; i < indent; i++)
|
for (i = 0; i < indent; i++)
|
||||||
g_string_append_c (output, ' ');
|
g_string_append_c (output, ' ');
|
||||||
|
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
g_string_append_vprintf (output, fmt, args);
|
g_string_append_vprintf (output, fmt, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
g_print ("%s\n", output->str);
|
g_print ("%s\n", output->str);
|
||||||
g_string_free (output, TRUE);
|
g_string_free (output, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_device_and_parent (GUdevDevice *device, guint indent)
|
dump_device_and_parent (GUdevDevice *device, guint indent)
|
||||||
{
|
{
|
||||||
const char **list, **iter;
|
const char **list, **iter;
|
||||||
GUdevDevice *parent;
|
GUdevDevice *parent;
|
||||||
char propstr[500];
|
char propstr[500];
|
||||||
guint32 namelen = 0, i;
|
guint32 namelen = 0, i;
|
||||||
|
|
||||||
println (indent, "------------------------------------------------------");
|
println (indent, "------------------------------------------------------");
|
||||||
println (indent, "Name: %s", g_udev_device_get_name (device));
|
println (indent, "Name: %s", g_udev_device_get_name (device));
|
||||||
println (indent, "Type: %s", g_udev_device_get_devtype (device));
|
println (indent, "Type: %s", g_udev_device_get_devtype (device));
|
||||||
println (indent, "Subsys: %s", g_udev_device_get_subsystem (device));
|
println (indent, "Subsys: %s", g_udev_device_get_subsystem (device));
|
||||||
println (indent, "Number: %s", g_udev_device_get_number (device));
|
println (indent, "Number: %s", g_udev_device_get_number (device));
|
||||||
println (indent, "Path: %s", g_udev_device_get_sysfs_path (device));
|
println (indent, "Path: %s", g_udev_device_get_sysfs_path (device));
|
||||||
println (indent, "Driver: %s", g_udev_device_get_driver (device));
|
println (indent, "Driver: %s", g_udev_device_get_driver (device));
|
||||||
println (indent, "Action: %s", g_udev_device_get_action (device));
|
println (indent, "Action: %s", g_udev_device_get_action (device));
|
||||||
println (indent, "Seq Num: %lu", g_udev_device_get_seqnum (device));
|
println (indent, "Seq Num: %lu", g_udev_device_get_seqnum (device));
|
||||||
println (indent, "Dev File: %s", g_udev_device_get_device_file (device));
|
println (indent, "Dev File: %s", g_udev_device_get_device_file (device));
|
||||||
|
|
||||||
println (indent, "");
|
println (indent, "");
|
||||||
println (indent, "Properties:");
|
println (indent, "Properties:");
|
||||||
|
|
||||||
/* Get longest property name length for alignment */
|
/* Get longest property name length for alignment */
|
||||||
list = (const char **) g_udev_device_get_property_keys (device);
|
list = (const char **) g_udev_device_get_property_keys (device);
|
||||||
for (iter = list; iter && *iter; iter++) {
|
for (iter = list; iter && *iter; iter++) {
|
||||||
if (strlen (*iter) > namelen)
|
if (strlen (*iter) > namelen)
|
||||||
namelen = strlen (*iter);
|
namelen = strlen (*iter);
|
||||||
}
|
}
|
||||||
namelen++;
|
namelen++;
|
||||||
|
|
||||||
for (iter = list; iter && *iter; iter++) {
|
for (iter = list; iter && *iter; iter++) {
|
||||||
strcpy (propstr, *iter);
|
strcpy (propstr, *iter);
|
||||||
strcat (propstr, ":");
|
strcat (propstr, ":");
|
||||||
for (i = 0; i < namelen - strlen (*iter); i++)
|
for (i = 0; i < namelen - strlen (*iter); i++)
|
||||||
strcat (propstr, " ");
|
strcat (propstr, " ");
|
||||||
strcat (propstr, g_udev_device_get_property (device, *iter));
|
strcat (propstr, g_udev_device_get_property (device, *iter));
|
||||||
println (indent + 2, "%s", propstr);
|
println (indent + 2, "%s", propstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
println (indent, "");
|
println (indent, "");
|
||||||
|
|
||||||
parent = g_udev_device_get_parent (device);
|
parent = g_udev_device_get_parent (device);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
dump_device_and_parent (parent, indent + 4);
|
dump_device_and_parent (parent, indent + 4);
|
||||||
g_object_unref (parent);
|
g_object_unref (parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -126,53 +126,53 @@ handle_uevent (GUdevClient *client,
|
|||||||
GUdevDevice *device,
|
GUdevDevice *device,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
const char *expected_subsys = user_data;
|
const char *expected_subsys = user_data;
|
||||||
const char *subsys;
|
const char *subsys;
|
||||||
|
|
||||||
g_return_if_fail (client != NULL);
|
g_return_if_fail (client != NULL);
|
||||||
g_return_if_fail (action != NULL);
|
g_return_if_fail (action != NULL);
|
||||||
g_return_if_fail (device != NULL);
|
g_return_if_fail (device != NULL);
|
||||||
|
|
||||||
/* A bit paranoid */
|
/* A bit paranoid */
|
||||||
subsys = g_udev_device_get_subsystem (device);
|
subsys = g_udev_device_get_subsystem (device);
|
||||||
g_return_if_fail (subsys != NULL);
|
g_return_if_fail (subsys != NULL);
|
||||||
|
|
||||||
g_return_if_fail (!strcmp (subsys, expected_subsys));
|
g_return_if_fail (!strcmp (subsys, expected_subsys));
|
||||||
|
|
||||||
g_print ("---- (EVENT: %s) ----\n", action);
|
g_print ("---- (EVENT: %s) ----\n", action);
|
||||||
dump_device_and_parent (device, 0);
|
dump_device_and_parent (device, 0);
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GUdevClient *client;
|
GUdevClient *client;
|
||||||
const char *subsys[2] = { NULL, NULL };
|
const char *subsys[2] = { NULL, NULL };
|
||||||
GList *list, *iter;
|
GList *list, *iter;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_warning ("Usage: %s [subsystem]", argv[0]);
|
g_warning ("Usage: %s [subsystem]", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
setup_signals ();
|
setup_signals ();
|
||||||
|
|
||||||
subsys[0] = argv[1];
|
subsys[0] = argv[1];
|
||||||
client = g_udev_client_new (subsys);
|
client = g_udev_client_new (subsys);
|
||||||
g_signal_connect (client, "uevent", G_CALLBACK (handle_uevent), (gpointer) subsys[0]);
|
g_signal_connect (client, "uevent", G_CALLBACK (handle_uevent), (gpointer) subsys[0]);
|
||||||
|
|
||||||
list = g_udev_client_query_by_subsystem (client, subsys[0]);
|
list = g_udev_client_query_by_subsystem (client, subsys[0]);
|
||||||
for (iter = list; iter; iter = g_list_next (iter)) {
|
for (iter = list; iter; iter = g_list_next (iter)) {
|
||||||
dump_device_and_parent (G_UDEV_DEVICE (iter->data), 0);
|
dump_device_and_parent (G_UDEV_DEVICE (iter->data), 0);
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
g_object_unref (G_UDEV_DEVICE (iter->data));
|
g_object_unref (G_UDEV_DEVICE (iter->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,16 +86,16 @@ show_part_info (MMSmsPart *part)
|
|||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case MM_SMS_ENCODING_GSM7:
|
case MM_SMS_ENCODING_GSM7:
|
||||||
g_print ("encoding: GSM7\n");
|
g_print ("encoding: GSM7\n");
|
||||||
break;
|
break;
|
||||||
case MM_SMS_ENCODING_UCS2:
|
case MM_SMS_ENCODING_UCS2:
|
||||||
g_print ("encoding: UCS2\n");
|
g_print ("encoding: UCS2\n");
|
||||||
break;
|
break;
|
||||||
case MM_SMS_ENCODING_8BIT:
|
case MM_SMS_ENCODING_8BIT:
|
||||||
g_print ("encoding: 8BIT\n");
|
g_print ("encoding: 8BIT\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_print ("encoding: unknown (0x%x)\n", encoding);
|
g_print ("encoding: unknown (0x%x)\n", encoding);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = mm_sms_part_get_text (part);
|
text = mm_sms_part_get_text (part);
|
||||||
@@ -152,13 +152,13 @@ show_part_info (MMSmsPart *part)
|
|||||||
|
|
||||||
if (MM_SMS_PART_IS_CDMA (part)) {
|
if (MM_SMS_PART_IS_CDMA (part)) {
|
||||||
MMSmsCdmaTeleserviceId teleservice_id;
|
MMSmsCdmaTeleserviceId teleservice_id;
|
||||||
MMSmsCdmaServiceCategory service_category;
|
MMSmsCdmaServiceCategory service_category;
|
||||||
|
|
||||||
teleservice_id = mm_sms_part_get_cdma_teleservice_id (part);
|
teleservice_id = mm_sms_part_get_cdma_teleservice_id (part);
|
||||||
g_print ("teleservice id: %s\n", mm_sms_cdma_teleservice_id_get_string (teleservice_id));
|
g_print ("teleservice id: %s\n", mm_sms_cdma_teleservice_id_get_string (teleservice_id));
|
||||||
|
|
||||||
service_category = mm_sms_part_get_cdma_service_category (part);
|
service_category = mm_sms_part_get_cdma_service_category (part);
|
||||||
g_print ("service category: %s\n", mm_sms_cdma_service_category_get_string (service_category));
|
g_print ("service category: %s\n", mm_sms_cdma_service_category_get_string (service_category));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user