]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/logger/errors
4 # Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
6 # This file is part of util-linux.
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
19 TS_TOPDIR
="${0%/*}/../.."
22 .
$TS_TOPDIR/functions.sh
26 ts_check_test_command
"$TS_HELPER_LOGGER"
29 export LOGGER_TEST_TIMEOFDAY
="1234567890.123456"
30 export LOGGER_TEST_HOSTNAME
="test-hostname"
31 export LOGGER_TEST_GETPID
="98765"
33 DEVLOG
="$(mktemp "/tmp
/ultest-
$TS_COMPONENT-$TS_TESTNAME-XXXXXX")" \
34 || ts_die
"mktemp failed"
35 SOCKIN
="${TS_OUTDIR}/${TS_TESTNAME}_socketin"
36 ts_init_socket_to_file
$DEVLOG $SOCKIN
40 # logger without --no-act to write all data to the socket
41 echo "socket data, ${TS_SUBNAME}:" |socat
-u - UNIX-CONNECT
:$DEVLOG
42 $TS_HELPER_LOGGER -u $DEVLOG --stderr "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG
43 echo "ret: $?" >> "$TS_OUTPUT"
44 echo |socat
-u - UNIX-CONNECT
:$DEVLOG
47 function logger_printf
{
48 # logger without --no-act to write all data to the socket
51 echo "socket data, ${TS_SUBNAME}:" |socat
-u - UNIX-CONNECT
:$DEVLOG
52 printf "$fmt" |
$TS_HELPER_LOGGER -u $DEVLOG --stderr "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG
53 echo "ret: $?" >> "$TS_OUTPUT"
54 echo |socat
-u - UNIX-CONNECT
:$DEVLOG
57 ts_init_subtest
"kern_priority"
58 logger_fun
-t "prio" -p kern.emerg
"message"
61 ts_init_subtest
"kern_priority_numeric"
62 logger_fun
-t "prio" -p 0 "message"
65 ts_init_subtest
"invalid_prio"
66 logger_fun
-t "prio" -p 8 "message"
70 ts_init_subtest
"rfc5424_exceed_size"
71 logger_fun
-t "rfc5424_exceed_size" --rfc5424 --size 3 "abcd"
74 ts_init_subtest
"id_with_space"
75 logger_fun
-t "id_with_space" --id="A B" "message"
76 logger_fun
-t "rfc5424_id_with_space" --rfc5424 --id="A B" "message"
77 logger_fun
-t "id_with_space" --id="1 23" "message"
78 logger_fun
-t "id_with_leading space" --id=" 123" "message"
79 logger_fun
-t "id_with_trailing space" --id="123 " "message"
84 ts_init_subtest
"tag_with_space"
85 logger_fun
-t "A B" "tag_with_space"
86 logger_fun
-t "A B" --rfc5424 "tag_with_space_rfc5424"
90 logger_fun
--tcp -t "tcp" "message"
93 ts_init_subtest
"multi-line"
94 logger_printf
"AAA\nBBB\nCCC\n" -t "multi"
97 ts_init_subtest
"rfc5424_msgid_with_space"
98 logger_fun
-t "rfc5424_msgid_with_space" --rfc5424 --msgid="A B" "message"
101 ts_init_subtest
"invalid_socket"
102 logger_fun
-u /bad
/boy
-t "invalid_socket" "message"
105 ts_init_subtest
"check_socket"
106 ts_log
"Check written socket data of all subtests."
109 wait $SOCAT_PID &>/dev
/null
110 cat "$SOCKIN" >> $TS_OUTPUT 2>> $TS_ERRLOG
111 rm -f "$DEVLOG" "$SOCKIN"