mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 06:52:22 +03:00
cc5549ca12
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed. 4 sp was the most common, in particular the majority of scripts under test/ used that. Let's standarize on 4 sp, because many commandlines are long and there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp also seems to be the default indentation, so this will make it less likely that people will mess up if they don't load the editor config. (I think people often use vi, and vi has no support to load project-wide configuration automatically. We distribute a .vimrc file, but it is not loaded by default, and even the instructions in it seem to discourage its use for security reasons.) Also remove the few vim config lines that were left. We should either have them on all files, or none. Also remove some strange stuff like '#!/bin/env bash', yikes.
94 lines
2.7 KiB
Bash
Executable File
94 lines
2.7 KiB
Bash
Executable File
#!/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
|
|
journalctl --sync
|
|
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
|
|
journalctl --sync
|
|
journalctl -b -o cat -t "$ID" >/output
|
|
cmp /expected /output
|
|
|
|
# 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
|
|
journalctl --sync
|
|
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
|
|
journalctl --sync
|
|
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
|
|
journalctl --sync
|
|
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
|
|
journalctl --sync
|
|
journalctl -b -o cat -t "$ID" >/output
|
|
cmp /expected /output
|
|
|
|
# --output-fields restricts output
|
|
ID=$(journalctl --new-id128 | sed -n 2p)
|
|
printf $'foo' | systemd-cat -t "$ID" --level-prefix false
|
|
journalctl --sync
|
|
journalctl -b -o export --output-fields=MESSAGE,FOO --output-fields=PRIORITY,MESSAGE -t "$ID" >/output
|
|
[[ `grep -c . /output` -eq 6 ]]
|
|
grep -q '^__CURSOR=' /output
|
|
grep -q '^MESSAGE=foo$' /output
|
|
grep -q '^PRIORITY=6$' /output
|
|
! grep -q '^FOO=' /output
|
|
! grep -q '^SYSLOG_FACILITY=' /output
|
|
|
|
# `-b all` negates earlier use of -b (-b and -m are otherwise exclusive)
|
|
journalctl -b -1 -b all -m > /dev/null
|
|
|
|
# -b always behaves like -b0
|
|
journalctl -q -b-1 -b0 | head -1 > /expected
|
|
journalctl -q -b-1 -b | head -1 > /output
|
|
cmp /expected /output
|
|
# ... even when another option follows (both of these should fail due to -m)
|
|
{ journalctl -ball -b0 -m 2>&1 || :; } | head -1 > /expected
|
|
{ journalctl -ball -b -m 2>&1 || :; } | head -1 > /output
|
|
cmp /expected /output
|
|
|
|
# Don't lose streams on restart
|
|
systemctl start forever-print-hola
|
|
sleep 3
|
|
systemctl restart systemd-journald
|
|
sleep 3
|
|
systemctl stop forever-print-hola
|
|
[[ ! -f "/i-lose-my-logs" ]]
|
|
|
|
# https://github.com/systemd/systemd/issues/4408
|
|
rm -f /i-lose-my-logs
|
|
systemctl start forever-print-hola
|
|
sleep 3
|
|
systemctl kill --signal=SIGKILL systemd-journald
|
|
sleep 3
|
|
[[ ! -f "/i-lose-my-logs" ]]
|
|
|
|
touch /testok
|