Commit 7a518579 authored by Ian Murdock's avatar Ian Murdock
Browse files

Updated tests to reflect event system API changes.

parent e9f9388a
/* test-consume.c: Test delivery of events, with attributes (consumer). */
static char rcsid[] = "$Id: test-attr-consume.c,v 1.2 2001-11-06 17:24:16 imurdock Exp $";
static char rcsid[] = "$Id: test-attr-consume.c,v 1.3 2002-01-29 12:18:48 imurdock Exp $";
#include <event.h>
static void callback(event_handle_t handle, event_notification_t notification,
void *data);
char *host, event_type_t type, void *data);
int
main(int argc, char **argv)
......@@ -53,43 +53,23 @@ main(int argc, char **argv)
}
static void
callback(event_handle_t handle, event_notification_t notification, void *data)
callback(event_handle_t handle, event_notification_t notification, char *host,
event_type_t type, void *data)
{
char *message = (char *) data;
char *host;
event_type_t type;
double attr_double;
int32_t attr_int32;
int64_t attr_int64;
char *attr_string;
char attr_string[64];
struct timeval attr_opaque;
TRACE("the message is: %s\n", message);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_STRING, "host",
(event_attr_value_t *) &host)
== 0)
{
ERROR("could not get host attribute\n");
return;
}
TRACE("data: %s\n", (char *) data);
TRACE("host: %s\n", host);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_STRING, "type",
(event_attr_value_t *) &type)
== 0)
{
ERROR("could not get type attribute\n");
return;
}
TRACE("type: %d\n", type);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_DOUBLE, "double",
(event_attr_value_t *) &attr_double)
if (event_notification_get_double(handle, notification, "double",
&attr_double)
== 0)
{
ERROR("could not get double attribute\n");
......@@ -98,9 +78,8 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
TRACE("double: %f\n", attr_double);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_DOUBLE, "int32",
(event_attr_value_t *) &attr_int32)
if (event_notification_get_int32(handle, notification, "int32",
&attr_int32)
== 0)
{
ERROR("could not get int32 attribute\n");
......@@ -109,9 +88,8 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
TRACE("int32: %d\n", attr_int32);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_DOUBLE, "int64",
(event_attr_value_t *) &attr_int64)
if (event_notification_get_int64(handle, notification, "int64",
&attr_int64)
== 0)
{
ERROR("could not get int64 attribute\n");
......@@ -120,9 +98,20 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
TRACE("int64: %lld\n", attr_int64);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_DOUBLE, "string",
(event_attr_value_t *) &attr_string)
if (event_notification_get_opaque(handle, notification, "opaque",
&attr_opaque, sizeof(attr_opaque))
== 0)
{
ERROR("could not get opaque attribute\n");
return;
}
TRACE("opaque: (tv_sec=%ld, tv_usec=%ld)\n",
attr_opaque.tv_sec,
attr_opaque.tv_usec);
if (event_notification_get_string(handle, notification, "string",
attr_string, 64)
== 0)
{
ERROR("could not get string attribute\n");
......
/* test-attr-produce.c: Test delivery of events, with attributes (producer). */
static char rcsid[] = "$Id: test-attr-produce.c,v 1.2 2001-11-06 17:24:16 imurdock Exp $";
static char rcsid[] = "$Id: test-attr-produce.c,v 1.3 2002-01-29 12:18:49 imurdock Exp $";
#include <event.h>
......@@ -11,6 +11,7 @@ main(int argc, char **argv)
event_notification_t notification;
char *server = NULL;
int c;
struct timeval time;
while ((c = getopt(argc, argv, "s:")) != -1) {
switch (c) {
......@@ -39,33 +40,41 @@ main(int argc, char **argv)
return 1;
}
if (event_notification_attr_put(handle, notification,
EVENT_ATTR_DOUBLE, "double",
(event_attr_value_t) 1.23)
if (event_notification_put_double(handle, notification, "double", 1.23)
== 0)
{
ERROR("could not put double attribute\n");
return 1;
}
if (event_notification_attr_put(handle, notification,
EVENT_ATTR_INT32, "int32",
(event_attr_value_t) 123)
if (event_notification_put_int32(handle, notification, "int32", 123)
== 0)
{
ERROR("could not put int32 attribute\n");
return 1;
}
if (event_notification_attr_put(handle, notification,
EVENT_ATTR_INT64, "int64",
(event_attr_value_t) 100000000000)
if (event_notification_put_int64(handle, notification, "int64",
100000000000)
== 0)
{
ERROR("could not put int64 attribute\n");
return 1;
}
if (event_notification_attr_put(handle, notification,
EVENT_ATTR_STRING, "string",
(event_attr_value_t) "foo")
gettimeofday(&time, NULL);
TRACE("time.tv_sec = %ld, time.tv_usec = %ld\n",
time.tv_sec,
time.tv_usec);
if (event_notification_put_opaque(handle, notification, "opaque", &time,
sizeof(time))
== 0)
{
ERROR("could not put opaque attribute\n");
return 1;
}
if (event_notification_put_string(handle, notification, "string", "foo")
== 0)
{
ERROR("could not put string attribute\n");
......
/* test-consume.c: Test delivery of events (consumer). */
static char rcsid[] = "$Id: test-consume.c,v 1.2 2001-11-06 17:24:16 imurdock Exp $";
static char rcsid[] = "$Id: test-consume.c,v 1.3 2002-01-29 12:18:49 imurdock Exp $";
#include <event.h>
static void callback(event_handle_t handle, event_notification_t notification,
void *data);
char *host, event_type_t type, void *data);
int
main(int argc, char **argv)
......@@ -53,33 +53,10 @@ main(int argc, char **argv)
}
static void
callback(event_handle_t handle, event_notification_t notification, void *data)
callback(event_handle_t handle, event_notification_t notification, char *host,
event_type_t type, void *data)
{
char *message = (char *) data;
char *host;
event_type_t type;
TRACE("the message is: %s\n", message);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_STRING, "host",
(event_attr_value_t *) &host)
== 0)
{
ERROR("could not get host attribute\n");
return;
}
TRACE("data: %s\n", (char *) data);
TRACE("host: %s\n", host);
if (event_notification_attr_get(handle, notification,
EVENT_ATTR_STRING, "type",
(event_attr_value_t *) &type)
== 0)
{
ERROR("could not get type attribute\n");
return;
}
TRACE("type: %d\n", type);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment