]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-log.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2012 Lennart Poettering
11 #include "format-util.h"
13 #include "process-util.h"
16 assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD
, LOG_FTP
| LOG_DEBUG
))
17 == LOG_REALM_SYSTEMD
);
18 assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV
, LOG_LOCAL7
| LOG_DEBUG
))
20 assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD
, LOG_LOCAL3
| LOG_DEBUG
) & LOG_FACMASK
)
22 assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV
, LOG_USER
| LOG_INFO
) & LOG_PRIMASK
)
25 #define X10(x) x x x x x x x x x x
26 #define X100(x) X10(X10(x))
27 #define X1000(x) X100(X10(x))
29 static void test_log_console(void) {
31 "MESSAGE=Waldo PID="PID_FMT
, getpid_cached(),
35 static void test_log_journal(void) {
37 "MESSAGE=Foobar PID="PID_FMT
, getpid_cached(),
41 "MESSAGE=Foobar PID="PID_FMT
, getpid_cached(),
42 "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",
43 (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,
47 static void test_long_lines(void) {
48 log_object_internal(LOG_NOTICE
,
50 X1000("abcd_") ".txt",
57 "asdfasdf %s asdfasdfa", "foobar");
60 int main(int argc
, char* argv
[]) {
63 for (target
= 0; target
< _LOG_TARGET_MAX
; target
++) {
64 log_set_target(target
);