diff options
author | Gergely Nagy <algernon@balabit.hu> | 2012-03-20 12:35:15 +0100 |
---|---|---|
committer | Gergely Nagy <algernon@balabit.hu> | 2012-03-20 12:35:15 +0100 |
commit | 91a80a8edd10ff888d4bb34b283a9dadf440efce (patch) | |
tree | 07f406a31c1247c6203fc57835bc7ba25980ab03 /t | |
parent | bb9abceb495ec95236edbc51c4b14091718c9f7d (diff) | |
download | libumberlog-91a80a8edd10ff888d4bb34b283a9dadf440efce.tar.gz libumberlog-91a80a8edd10ff888d4bb34b283a9dadf440efce.tar.xz libumberlog-91a80a8edd10ff888d4bb34b283a9dadf440efce.zip |
t: Make sure that discovered fields override supplied ones.
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Diffstat (limited to 't')
-rw-r--r-- | t/test_cee_format.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/test_cee_format.c b/t/test_cee_format.c index d7f886e..29a4ffd 100644 --- a/t/test_cee_format.c +++ b/t/test_cee_format.c @@ -1,8 +1,13 @@ +#define _GNU_SOURCE 1 + #include "cee-syslog.h" #include <json.h> #include <assert.h> #include <string.h> #include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> +#include <stdio.h> static void verify_value (struct json_object *jo, const char *key, @@ -124,12 +129,38 @@ test_additional_fields (void) closelog (); } +static void +test_discover_priority (void) +{ + char *msg, *pid; + struct json_object *jo; + + openlog ("cee-syslog/test_discover_priority", 0, LOG_LOCAL0); + + msg = cee_format (LOG_DEBUG, "testing 1, 2, 3...", + "pid", "%d", getpid () + 42, + NULL); + jo = parse_msg (msg); + free (msg); + + verify_value (jo, "msg", "testing 1, 2, 3..."); + + asprintf (&pid, "%d", getpid ()); + verify_value (jo, "pid", pid); + free (pid); + + json_object_put (jo); + + closelog (); +} + int main (void) { test_simple (); test_no_discover (); test_additional_fields (); + test_discover_priority (); return 0; } |