]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-04-JOURNAL/test-journal.sh
Merge pull request #2261 from evverx/fix-test-rlimit-util
[thirdparty/systemd.git] / test / TEST-04-JOURNAL / test-journal.sh
CommitLineData
1c36b4a7
EV
1#!/bin/bash
2
3set -x
4set -e
5set -o pipefail
6
7# Test stdout stream
8
9# Skip empty lines
10ID=$(journalctl --new-id128 | sed -n 2p)
11>/expected
12printf $'\n\n\n' | systemd-cat -t "$ID" --level-prefix false
e8e5a6e2 13journalctl --sync
1c36b4a7
EV
14journalctl -b -o cat -t "$ID" >/output
15cmp /expected /output
16
17ID=$(journalctl --new-id128 | sed -n 2p)
18>/expected
19printf $'<5>\n<6>\n<7>\n' | systemd-cat -t "$ID" --level-prefix true
e8e5a6e2 20journalctl --sync
1c36b4a7
EV
21journalctl -b -o cat -t "$ID" >/output
22cmp /expected /output
23
45d39b4f
EV
24# Remove trailing spaces
25ID=$(journalctl --new-id128 | sed -n 2p)
26printf "Trailing spaces\n">/expected
27printf $'<5>Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix true
e8e5a6e2 28journalctl --sync
45d39b4f
EV
29journalctl -b -o cat -t "$ID" >/output
30cmp /expected /output
31
32ID=$(journalctl --new-id128 | sed -n 2p)
33printf "Trailing spaces\n">/expected
34printf $'Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix false
e8e5a6e2 35journalctl --sync
45d39b4f
EV
36journalctl -b -o cat -t "$ID" >/output
37cmp /expected /output
38
39# Don't remove leading spaces
40ID=$(journalctl --new-id128 | sed -n 2p)
41printf $' \t Leading spaces\n'>/expected
42printf $'<5> \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix true
e8e5a6e2 43journalctl --sync
45d39b4f
EV
44journalctl -b -o cat -t "$ID" >/output
45cmp /expected /output
46
47ID=$(journalctl --new-id128 | sed -n 2p)
48printf $' \t Leading spaces\n'>/expected
49printf $' \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix false
e8e5a6e2 50journalctl --sync
45d39b4f
EV
51journalctl -b -o cat -t "$ID" >/output
52cmp /expected /output
53
3889613e
EV
54# Don't lose streams on restart
55systemctl start forever-print-hola
56sleep 3
57systemctl restart systemd-journald
58sleep 3
59systemctl stop forever-print-hola
60[[ ! -f "/i-lose-my-logs" ]]
61
1c36b4a7
EV
62touch /testok
63exit 0