]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-log.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2012 Lennart Poettering
9 #include "format-util.h"
11 #include "process-util.h"
14 assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD
, LOG_FTP
| LOG_DEBUG
))
15 == LOG_REALM_SYSTEMD
);
16 assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV
, LOG_LOCAL7
| LOG_DEBUG
))
18 assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD
, LOG_LOCAL3
| LOG_DEBUG
) & LOG_FACMASK
)
20 assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV
, LOG_USER
| LOG_INFO
) & LOG_PRIMASK
)
23 #define X10(x) x x x x x x x x x x
24 #define X100(x) X10(X10(x))
25 #define X1000(x) X100(X10(x))
27 static void test_log_console(void) {
29 "MESSAGE=Waldo PID="PID_FMT
, getpid_cached(),
33 static void test_log_journal(void) {
35 "MESSAGE=Foobar PID="PID_FMT
, getpid_cached(),
39 "MESSAGE=Foobar PID="PID_FMT
, getpid_cached(),
40 "FORMAT_STR_TEST=1=%i A=%c 2=%hi 3=%li 4=%lli 1=%p foo=%s 2.5=%g 3.5=%g 4.5=%Lg",
41 (int) 1, 'A', (short) 2, (long int) 3, (long long int) 4, (void*) 1, "foo", (float) 2.5f
, (double) 3.5, (long double) 4.5,
45 static void test_long_lines(void) {
46 log_object_internal(LOG_NOTICE
,
48 X1000("abcd_") ".txt",
55 "asdfasdf %s asdfasdfa", "foobar");
58 int main(int argc
, char* argv
[]) {
61 for (target
= 0; target
< _LOG_TARGET_MAX
; target
++) {
62 log_set_target(target
);