summaryrefslogtreecommitdiff
path: root/common/elapi
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-09-17 12:00:06 +0200
committerStephen Gallagher <sgallagh@redhat.com>2009-09-21 10:35:11 -0400
commit3d4cc7656f62e893d2da12722e14dd475e60b512 (patch)
tree61258a50cad4c5dc9e0ef44c86cd59ead070455a /common/elapi
parent8c50bd085c0efe5fde354deee2c8118887aae29d (diff)
downloadsssd-3d4cc7656f62e893d2da12722e14dd475e60b512.tar.gz
sssd-3d4cc7656f62e893d2da12722e14dd475e60b512.tar.bz2
sssd-3d4cc7656f62e893d2da12722e14dd475e60b512.zip
ELAPI: fix varargs call, update unit tests
Diffstat (limited to 'common/elapi')
-rw-r--r--common/elapi/elapi_event.h2
-rw-r--r--common/elapi/elapi_log.c2
-rw-r--r--common/elapi/elapi_test/elapi_ut.c62
3 files changed, 58 insertions, 8 deletions
diff --git a/common/elapi/elapi_event.h b/common/elapi/elapi_event.h
index 27c297b1..dfaba771 100644
--- a/common/elapi/elapi_event.h
+++ b/common/elapi/elapi_event.h
@@ -116,7 +116,7 @@
* the event is created so initializing them
* does not make sense unless you use the base
* that does not include them.
- * The list of key value pairs should be terminated by special
+ * The list of key value pairs MUST be terminated by special
* argument E_EOARG.
*/
int elapi_create_event_template(struct collection_item **template,
diff --git a/common/elapi/elapi_log.c b/common/elapi/elapi_log.c
index 1d1bfa05..aac1e00d 100644
--- a/common/elapi/elapi_log.c
+++ b/common/elapi/elapi_log.c
@@ -411,7 +411,7 @@ int elapi_get_default_template(struct collection_item **template)
(global_dispatcher->default_template == NULL)) {
TRACE_INFO_STRING("Default template does not exit", "");
- error = elapi_set_default_template(E_BASE_DEFV1);
+ error = elapi_set_default_template(E_BASE_DEFV1, E_EOARG);
if (error) {
TRACE_ERROR_NUMBER("Set default template returned error", error);
return error;
diff --git a/common/elapi/elapi_test/elapi_ut.c b/common/elapi/elapi_test/elapi_ut.c
index 4be031e8..0a823432 100644
--- a/common/elapi/elapi_test/elapi_ut.c
+++ b/common/elapi/elapi_test/elapi_ut.c
@@ -27,6 +27,46 @@
/* THIS IS A PRIVATE HEADER - included for debugging purposes only! */
#include "elapi_priv.h"
+#define APPNAME "elapi_ut"
+#define ELAPI_CONFIG_FILE "elapi_ut.conf"
+
+typedef (*test_fn)(void);
+
+int elapi_init_test(void)
+{
+ int error = 0;
+
+ printf("elapi_init test START:\n");
+
+ error = elapi_init(APPNAME, "./"ELAPI_CONFIG_FILE);
+ if (error) {
+ printf("elapi_init failed: %d", error);
+ return error;
+ }
+
+ elapi_close();
+
+ printf("elapi_init test success!\n");
+ return 0;
+}
+
+int elapi_get_default_template_test(void)
+{
+ struct collection_item *template;
+ int error = 0;
+
+ printf("elapi_get_default_template_test test START:\n");
+
+ error = elapi_get_default_template(&template);
+ if (error) {
+ printf("elapi_get_default_template failed: %d", error);
+ return error;
+ }
+
+ printf("elapi_get_default_template test success!\n");
+ return 0;
+}
+
int simple_event_test(void)
{
int error = 0;
@@ -355,13 +395,23 @@ int complex_event_test(void)
int main(int argc, char *argv[])
{
int error = 0;
+ test_fn tests[] = { elapi_init_test,
+ elapi_get_default_template_test,
+ simple_event_test,
+ complex_event_test,
+ NULL };
+ test_fn t;
+ int i = 0;
printf("Start\n");
- if ((error = simple_event_test()) ||
- (error = complex_event_test())) {
- printf("Failed!\n");
+ while (t = tests[i++]) {
+ error = t();
+ if (error) {
+ printf("Failed!\n");
+ return error;
+ }
}
- else printf("Success!\n");
- /* Add other tests here ... */
- return error;
+
+ printf("Success!\n");
+ return 0;
}