]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-04-JOURNAL/test-journal.sh
Merge pull request #2495 from heftig/master
[thirdparty/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 # Don't lose streams on restart
55 systemctl start forever-print-hola
56 sleep 3
57 systemctl restart systemd-journald
58 sleep 3
59 systemctl stop forever-print-hola
60 [[ ! -f "/i-lose-my-logs" ]]
61
62 touch /testok