summaryrefslogtreecommitdiffstats
path: root/common/elapi/elapi_ut.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-08-07 15:50:34 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-08-12 12:24:27 -0400
commit1771d32e945b758326951384f0e17121042ad74e (patch)
tree070df00bcb1e049a1bdf794922b9b970479942a8 /common/elapi/elapi_ut.c
parentd59ba3139bba2d28c1209f62c01a7017c26dd635 (diff)
downloadsssd-1771d32e945b758326951384f0e17121042ad74e.tar.gz
sssd-1771d32e945b758326951384f0e17121042ad74e.tar.xz
sssd-1771d32e945b758326951384f0e17121042ad74e.zip
ELAPI Next round of functionality - logging part of the interface
a) Added the main logging interface which allows creating dispatcher and logging messages or events. Can't actully log anything yet since the sinks are stubbed out. b) Made default template be a part of the default dispatcher. c) Updated UNIT test. d) Some of the calls are stubbed out but they are there to indicate where next round of work will be.
Diffstat (limited to 'common/elapi/elapi_ut.c')
-rw-r--r--common/elapi/elapi_ut.c83
1 files changed, 72 insertions, 11 deletions
diff --git a/common/elapi/elapi_ut.c b/common/elapi/elapi_ut.c
index b9493da12..2866411f6 100644
--- a/common/elapi/elapi_ut.c
+++ b/common/elapi/elapi_ut.c
@@ -68,11 +68,21 @@ int simple_event_test(void)
return error;
}
- col_debug_collection(event, COL_TRAVERSE_DEFAULT);
- col_debug_collection(event, COL_TRAVERSE_FLAT);
+ error = elapi_log(event);
elapi_destroy_event(event);
+ if (error) {
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+ error = elapi_msg(NULL, "a", "b", "c", "d", E_EOARG);
+ if (error) {
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
printf("Simple test success!\n");
return error;
@@ -81,10 +91,11 @@ int simple_event_test(void)
int complex_event_test(void)
{
int error = 0;
- struct collection_item *template;
- struct collection_item *event, *event_copy;
+ struct collection_item *template = NULL;
+ struct collection_item *event = NULL, *event_copy = NULL;
char bin[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
- struct collection_item *col;
+ struct collection_item *col = NULL;
+ struct elapi_dispatcher *dispatcher = NULL;
printf("Complex test START:\n");
@@ -126,10 +137,18 @@ int complex_event_test(void)
col_debug_collection(template, COL_TRAVERSE_FLAT);
col_debug_collection(event, COL_TRAVERSE_FLAT);
+ error = elapi_log(event);
- elapi_destroy_event_template(template);
elapi_destroy_event(event);
+ if (error) {
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+
+ elapi_destroy_event_template(template);
+
error = elapi_create_event_template(
&template,
E_BASE_DEFV1 | E_BASE_HOSTEXT,
@@ -150,7 +169,7 @@ int complex_event_test(void)
}
if ((error = col_create_collection(&col, "test", 0)) ||
- /* We are forsing overwrite with different type */
+ /* We are forcing overwrite with different type */
(error = col_add_int_property(col, NULL, "unsigned_number", 1)) ||
(error = col_add_long_property(col, NULL, "bin", 100000000L))) {
elapi_destroy_event_template(template);
@@ -181,8 +200,6 @@ int complex_event_test(void)
col_debug_collection(event, COL_TRAVERSE_FLAT);
- elapi_destroy_event_template(template);
-
if ((error = col_create_collection(&col, "test", 0)) ||
/* We are forsing overwrite with different type */
(error = col_add_int_property(col, NULL, "zzz", 1)) ||
@@ -204,6 +221,7 @@ int complex_event_test(void)
if (error) {
printf("Failed to set create template %d\n", error);
elapi_destroy_event(event);
+ elapi_destroy_event_template(template);
col_destroy_collection(col);
return error;
}
@@ -211,17 +229,60 @@ int complex_event_test(void)
col_destroy_collection(col);
error = elapi_copy_event(&event_copy, event);
-
if (error) {
printf("Failed to set create template %d\n", error);
elapi_destroy_event(event);
+ elapi_destroy_event_template(template);
+ return error;
+ }
+
+ error = elapi_create_dispatcher(&dispatcher, "elapi_ut", "./sdfdsdf");
+ if (error) {
+ elapi_destroy_event(event);
+ elapi_destroy_event(event_copy);
+ elapi_destroy_event_template(template);
+ printf("Failed to create dispatcher %d\n", error);
return error;
}
+ error = elapi_dsp_log(dispatcher, event);
+
elapi_destroy_event(event);
- col_debug_collection(event_copy, COL_TRAVERSE_FLAT);
+
+ if (error) {
+ elapi_destroy_event(event_copy);
+ elapi_destroy_event_template(template);
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+ error = elapi_dsp_log(dispatcher, event_copy);
+
elapi_destroy_event(event_copy);
+ if (error) {
+ elapi_destroy_event_template(template);
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+ error = elapi_dsp_msg(dispatcher, template, "a", "b", "c", "d", E_EOARG);
+ if (error) {
+ elapi_destroy_event_template(template);
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+ error = elapi_dsp_msg(dispatcher, NULL, "a", "b", "c", "d", E_EOARG);
+ if (error) {
+ elapi_destroy_event_template(template);
+ printf("Failed to log event! %d\n", error);
+ return error;
+ }
+
+ elapi_destroy_event_template(template);
+ elapi_destroy_dispatcher(dispatcher);
+
return error;
}