2015-11-17 14:21:23 +03:00
#!/bin/bash
set -x
set -e
set -o pipefail
# Test stdout stream
# Skip empty lines
ID = $( journalctl --new-id128 | sed -n 2p)
>/expected
printf $'\n\n\n' | systemd-cat -t " $ID " --level-prefix false
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-17 14:21:23 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
ID = $( journalctl --new-id128 | sed -n 2p)
>/expected
printf $'<5>\n<6>\n<7>\n' | systemd-cat -t " $ID " --level-prefix true
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-17 14:21:23 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
2015-11-18 00:41:05 +03:00
# Remove trailing spaces
ID = $( journalctl --new-id128 | sed -n 2p)
printf "Trailing spaces\n" >/expected
printf $'<5>Trailing spaces \t \n' | systemd-cat -t " $ID " --level-prefix true
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-18 00:41:05 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
ID = $( journalctl --new-id128 | sed -n 2p)
printf "Trailing spaces\n" >/expected
printf $'Trailing spaces \t \n' | systemd-cat -t " $ID " --level-prefix false
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-18 00:41:05 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
# Don't remove leading spaces
ID = $( journalctl --new-id128 | sed -n 2p)
printf $' \t Leading spaces\n' >/expected
printf $'<5> \t Leading spaces\n' | systemd-cat -t " $ID " --level-prefix true
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-18 00:41:05 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
ID = $( journalctl --new-id128 | sed -n 2p)
printf $' \t Leading spaces\n' >/expected
printf $' \t Leading spaces\n' | systemd-cat -t " $ID " --level-prefix false
2015-11-27 16:55:23 +03:00
journalctl --sync
2015-11-18 00:41:05 +03:00
journalctl -b -o cat -t " $ID " >/output
cmp /expected /output
2015-11-17 14:21:23 +03:00
touch /testok
exit 0