summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorGergely Nagy <algernon@madhouse-project.org>2012-04-28 18:18:32 +0200
committerGergely Nagy <algernon@madhouse-project.org>2012-04-28 18:18:32 +0200
commit8cfef10830350c565e8ee917f83b9e97016a0a62 (patch)
tree32406caa5a85df767940c2d9b1fc1c94a8c617dd /t
parent0a00d2b837d186c261d5bc31c08737e60cf4172b (diff)
downloadlibumberlog-8cfef10830350c565e8ee917f83b9e97016a0a62.tar.gz
libumberlog-8cfef10830350c565e8ee917f83b9e97016a0a62.tar.xz
libumberlog-8cfef10830350c565e8ee917f83b9e97016a0a62.zip
Add a closelog() wrapper to clear the environment
Our openlog() wrapper fills in a couple of variables, and those were kept around even after a closelog(), and thus, affected ul_format() calls even after a closelog(). This in turn, made one of the test cases fail, as that was relying on the default behaviour, which was modified due to an openlog() in an earlier test case. We now wrap closelog() aswell, and NULL out our settings to get a clean state, and add a test case to verify this behaviour aswell. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Diffstat (limited to 't')
-rw-r--r--t/test_umberlog.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 33ed8bf..b0085c6 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -236,6 +236,24 @@ test_facprio (void)
json_object_put (jo);
}
+static void
+test_closelog (void)
+{
+ char *msg;
+ struct json_object *jo;
+
+ openlog ("umberlog/test_closelog", LOG_UL_NODISCOVER, LOG_LOCAL0);
+ closelog ();
+
+ msg = ul_format (LOG_LOCAL1 | LOG_DEBUG, "%s", __FUNCTION__, NULL);
+ jo = parse_msg (msg);
+ free (msg);
+
+ verify_value (jo, "facility", "local1");
+
+ json_object_put (jo);
+}
+
int
main (void)
{
@@ -246,6 +264,7 @@ main (void)
test_no_timestamp ();
test_json_escape ();
test_facprio ();
+ test_closelog ();
return 0;
}