summaryrefslogtreecommitdiffstats
path: root/src/test/test-log.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-21 14:51:56 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-21 14:54:04 +0100
commit81b3565efdb08df93596cc7a79ece57b528a69f3 (patch)
treed2981acd639cb313d15a832e2d7a99de4c7467cf /src/test/test-log.c
parentlog: Avoid pushing the same fields more than once on the log context (diff)
downloadsystemd-81b3565efdb08df93596cc7a79ece57b528a69f3.tar.xz
systemd-81b3565efdb08df93596cc7a79ece57b528a69f3.zip
log: Add key/value support to the log context
Now that we have reference counting, it's useful to be able to push single key values onto the log context separately, so that we don't have to allocate new storage to join the separate string together into a single field which means we won't be able to reuse a context containing the same field.
Diffstat (limited to 'src/test/test-log.c')
-rw-r--r--src/test/test-log.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/test-log.c b/src/test/test-log.c
index cfbd45c2e3..4fc4bc9087 100644
--- a/src/test/test-log.c
+++ b/src/test/test-log.c
@@ -116,7 +116,7 @@ static void test_log_context(void) {
_cleanup_(log_context_unrefp) LogContext *ctx = NULL;
char **strv = STRV_MAKE("SIXTH=ijn", "SEVENTH=PRP");
- assert_se(ctx = log_context_new(strv, /*owned=*/ false));
+ assert_se(ctx = log_context_new_strv(strv, /*owned=*/ false));
assert_se(log_context_num_contexts() == 1);
assert_se(log_context_num_fields() == 2);
@@ -160,6 +160,17 @@ static void test_log_context(void) {
test_log_syntax();
}
+ {
+ LOG_CONTEXT_PUSH_KEY_VALUE("ABC=", "QED");
+ LOG_CONTEXT_PUSH_KEY_VALUE("ABC=", "QED");
+ assert_se(log_context_num_contexts() == 1);
+ assert_se(log_context_num_fields() == 1);
+
+ test_log_struct();
+ test_long_lines();
+ test_log_syntax();
+ }
+
assert_se(log_context_num_contexts() == 0);
assert_se(log_context_num_fields() == 0);
}