summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-08-12 22:09:50 +0200
committerGergely Nagy <algernon@balabit.hu>2012-08-12 22:09:50 +0200
commit6a25c8d0973b62fb505ce618f86fe661fae6bb53 (patch)
tree02c992e090312d0c69dc98bafcf47e337d01c274
parent719f73c920523da484bf399761df19c044730284 (diff)
downloadlibumberlog-6a25c8d0973b62fb505ce618f86fe661fae6bb53.tar.gz
libumberlog-6a25c8d0973b62fb505ce618f86fe661fae6bb53.tar.xz
libumberlog-6a25c8d0973b62fb505ce618f86fe661fae6bb53.zip
Fix a few test cases
The test_overrides() test must be run first, otherwise we'll already likely not have a clean environment to test in. Furthermore, when testing discovery, make sure that NOIMPLICIT is not set. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
-rw-r--r--t/test_umberlog.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 68b5a95..9184b35 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -16,16 +16,16 @@
#include <check.h>
/**
- * Test the umberlog defaults.
+ * Test that openlog() is not overridden when using the linkable
+ * library. This must be the first test!
*/
-START_TEST (test_defaults)
+START_TEST (test_overrides)
{
char *msg;
struct json_object *jo;
-
char host[_POSIX_HOST_NAME_MAX + 1];
- ul_openlog ("umberlog/test_defaults", 0, LOG_LOCAL0);
+ openlog ("umberlog/test_overrides", 0, LOG_LOCAL0);
msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
jo = parse_msg (msg);
@@ -33,10 +33,14 @@ START_TEST (test_defaults)
gethostname (host, _POSIX_HOST_NAME_MAX);
- verify_value (jo, "msg", "hello, I'm test_defaults!");
- verify_value (jo, "facility", "local0");
+ verify_value (jo, "msg", "hello, I'm test_overrides!");
+ /* Default facility is user, and since we did not catch openlog, it
+ should not change. */
+ verify_value (jo, "facility", "user");
verify_value (jo, "priority", "debug");
- verify_value (jo, "program", "umberlog/test_defaults");
+ /* The program is also caught by openlog(), so we'll get the
+ default back, unless we use ul_openlog(). */
+ verify_value (jo, "program", "test_umberlog");
verify_value_exists (jo, "pid");
verify_value_exists (jo, "uid");
verify_value_exists (jo, "gid");
@@ -45,21 +49,21 @@ START_TEST (test_defaults)
json_object_put (jo);
- ul_closelog ();
+ closelog ();
}
END_TEST
/**
- * Test that openlog() is not overridden when using the linkable
- * library.
+ * Test the umberlog defaults.
*/
-START_TEST (test_overrides)
+START_TEST (test_defaults)
{
char *msg;
struct json_object *jo;
+
char host[_POSIX_HOST_NAME_MAX + 1];
- openlog ("umberlog/test_overrides", 0, LOG_LOCAL0);
+ ul_openlog ("umberlog/test_defaults", 0, LOG_LOCAL0);
msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
jo = parse_msg (msg);
@@ -67,14 +71,10 @@ START_TEST (test_overrides)
gethostname (host, _POSIX_HOST_NAME_MAX);
- verify_value (jo, "msg", "hello, I'm test_overrides!");
- /* Default facility is user, and since we did not catch openlog, it
- should not change. */
- verify_value (jo, "facility", "user");
+ verify_value (jo, "msg", "hello, I'm test_defaults!");
+ verify_value (jo, "facility", "local0");
verify_value (jo, "priority", "debug");
- /* The program is also caught by openlog(), so we'll get the
- default back, unless we use ul_openlog(). */
- verify_value (jo, "program", "test_umberlog");
+ verify_value (jo, "program", "umberlog/test_defaults");
verify_value_exists (jo, "pid");
verify_value_exists (jo, "uid");
verify_value_exists (jo, "gid");
@@ -83,7 +83,7 @@ START_TEST (test_overrides)
json_object_put (jo);
- closelog ();
+ ul_closelog ();
}
END_TEST
@@ -286,6 +286,7 @@ START_TEST (test_discover_priority)
struct json_object *jo;
ul_openlog ("umberlog/test_discover_priority", 0, LOG_LOCAL0);
+ ul_set_log_flags (LOG_UL_ALL);
msg = ul_format (LOG_DEBUG, "testing 1, 2, 3...",
"pid", "%d", getpid () + 42,
@@ -412,8 +413,8 @@ main (void)
s = suite_create ("Umberlog (linkable) functional testsuite");
ft = tcase_create ("Basic tests");
- tcase_add_test (ft, test_defaults);
tcase_add_test (ft, test_overrides);
+ tcase_add_test (ft, test_defaults);
tcase_add_test (ft, test_ul_openlog);
tcase_add_test (ft, test_ul_openlog_flag_ignore);
tcase_add_test (ft, test_closelog);