]> git.proxmox.com Git - systemd.git/blob - test/TEST-04-JOURNAL/test-journal.sh
New upstream version 236
[systemd.git] / test / TEST-04-JOURNAL / test-journal.sh
1 #!/bin/bash
2
3 set -x
4 set -e
5 set -o pipefail
6
7 # Test stdout stream
8
9 # Skip empty lines
10 ID=$(journalctl --new-id128 | sed -n 2p)
11 >/expected
12 printf $'\n\n\n' | systemd-cat -t "$ID" --level-prefix false
13 journalctl --sync
14 journalctl -b -o cat -t "$ID" >/output
15 cmp /expected /output
16
17 ID=$(journalctl --new-id128 | sed -n 2p)
18 >/expected
19 printf $'<5>\n<6>\n<7>\n' | systemd-cat -t "$ID" --level-prefix true
20 journalctl --sync
21 journalctl -b -o cat -t "$ID" >/output
22 cmp /expected /output
23
24 # Remove trailing spaces
25 ID=$(journalctl --new-id128 | sed -n 2p)
26 printf "Trailing spaces\n">/expected
27 printf $'<5>Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix true
28 journalctl --sync
29 journalctl -b -o cat -t "$ID" >/output
30 cmp /expected /output
31
32 ID=$(journalctl --new-id128 | sed -n 2p)
33 printf "Trailing spaces\n">/expected
34 printf $'Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix false
35 journalctl --sync
36 journalctl -b -o cat -t "$ID" >/output
37 cmp /expected /output
38
39 # Don't remove leading spaces
40 ID=$(journalctl --new-id128 | sed -n 2p)
41 printf $' \t Leading spaces\n'>/expected
42 printf $'<5> \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix true
43 journalctl --sync
44 journalctl -b -o cat -t "$ID" >/output
45 cmp /expected /output
46
47 ID=$(journalctl --new-id128 | sed -n 2p)
48 printf $' \t Leading spaces\n'>/expected
49 printf $' \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix false
50 journalctl --sync
51 journalctl -b -o cat -t "$ID" >/output
52 cmp /expected /output
53
54 # --output-fields restricts output
55 ID=$(journalctl --new-id128 | sed -n 2p)
56 printf $'foo' | systemd-cat -t "$ID" --level-prefix false
57 journalctl --sync
58 journalctl -b -o export --output-fields=MESSAGE,FOO --output-fields=PRIORITY,MESSAGE -t "$ID" >/output
59 [[ `grep -c . /output` -eq 6 ]]
60 grep -q '^__CURSOR=' /output
61 grep -q '^MESSAGE=foo$' /output
62 grep -q '^PRIORITY=6$' /output
63 ! grep -q '^FOO=' /output
64 ! grep -q '^SYSLOG_FACILITY=' /output
65
66 # Don't lose streams on restart
67 systemctl start forever-print-hola
68 sleep 3
69 systemctl restart systemd-journald
70 sleep 3
71 systemctl stop forever-print-hola
72 [[ ! -f "/i-lose-my-logs" ]]
73
74 # https://github.com/systemd/systemd/issues/4408
75 rm -f /i-lose-my-logs
76 systemctl start forever-print-hola
77 sleep 3
78 systemctl kill --signal=SIGKILL systemd-journald
79 sleep 3
80 [[ ! -f "/i-lose-my-logs" ]]
81
82 touch /testok