test: drop whitespace after shell redirection operators

(The one case that is left unchanged is '< <(subcommand)'.)

This way, the style with no gap was already dominant. This way, the reader
immediately knows that ' < ' is a comparison operator and ' << ' is a shift.

In a few cases, replace custom EOF replacement by just EOF. There is no point
in using someting like "_EOL" unless "EOF" appears in the text.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-02-06 09:19:04 +01:00
parent ecf4be2952
commit 7a17e41dcf
38 changed files with 91 additions and 91 deletions
+2 -2
View File
@@ -53,11 +53,11 @@ echo "disable $UNIT_NAME" >/run/systemd/system-preset/99-systemd-test.preset
EDITOR='true' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
[ ! -e "/etc/systemd/system/$UNIT_NAME.d/override.conf" ]
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' > "+4"
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' >"+4"
EDITOR='mv' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' | cmp - "/etc/systemd/system/$UNIT_NAME.d/override.conf"
printf '%b' '[Service]\n' 'ExecStart=\n' 'ExecStart=sleep 10d' > "+4"
printf '%b' '[Service]\n' 'ExecStart=\n' 'ExecStart=sleep 10d' >"+4"
EDITOR='mv' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' | cmp - "/etc/systemd/system/$UNIT_NAME.d/override.conf"
+1 -1
View File
@@ -163,7 +163,7 @@ mount /usr/share/minimal_0.raw /tmp/rootdir
# Fix up os-release to drop the valid PORTABLE_SERVICES field (because we are
# bypassing the sysext logic in portabled here it will otherwise not see the
# extensions additional valid prefix)
grep -v "^PORTABLE_PREFIXES=" /tmp/rootdir/etc/os-release > /tmp/os-release-fix/etc/os-release
grep -v "^PORTABLE_PREFIXES=" /tmp/rootdir/etc/os-release >/tmp/os-release-fix/etc/os-release
mount -t overlay overlay -o lowerdir=/tmp/os-release-fix:/tmp/app1:/tmp/rootdir /tmp/overlay
+1 -1
View File
@@ -31,7 +31,7 @@ systemd-run --unit=two \
-p StartLimitBurst=3 \
-p Type=oneshot \
-p Restart=on-failure \
-p ExecStart="/bin/bash -c \"printf a >> $TMP_FILE\"" /bin/bash -c "exit 1" \
-p ExecStart="/bin/bash -c \"printf a >>$TMP_FILE\"" /bin/bash -c "exit 1" \
&& { echo 'unexpected success'; exit 1; }
# wait for at least 3 restarts
+1 -1
View File
@@ -106,7 +106,7 @@ runas testuser systemd-run --wait --user --unit=test-clock \
runas testuser systemd-run --wait --user --unit=test-kernel-tunable \
-p PrivateUsers=yes -p ProtectKernelTunables=yes \
sh -c "echo 0 > /proc/sys/user/max_user_namespaces" \
sh -c "echo 0 >/proc/sys/user/max_user_namespaces" \
&& { echo 'unexpected success'; exit 1; }
runas testuser systemd-run --wait --user --unit=test-kernel-mod \
+15 -15
View File
@@ -86,7 +86,7 @@ LOCAL"
check_adjtime_not_exist
echo 'UTC set in adjtime file'
printf '0.0 0 0\n0\nUTC\n' > /etc/adjtime
printf '0.0 0 0\n0\nUTC\n' >/etc/adjtime
timedatectl set-local-rtc 0
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
@@ -97,7 +97,7 @@ UTC"
LOCAL"
echo 'non-zero values in adjtime file'
printf '0.1 123 0\n0\nLOCAL\n' > /etc/adjtime
printf '0.1 123 0\n0\nLOCAL\n' >/etc/adjtime
timedatectl set-local-rtc 0
assert_eq "$(cat /etc/adjtime)" "0.1 123 0
0
@@ -108,7 +108,7 @@ UTC"
LOCAL"
echo 'fourth line adjtime file'
printf '0.0 0 0\n0\nLOCAL\nsomethingelse\n' > /etc/adjtime
printf '0.0 0 0\n0\nLOCAL\nsomethingelse\n' >/etc/adjtime
timedatectl set-local-rtc 0
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
@@ -121,60 +121,60 @@ LOCAL
somethingelse"
echo 'no final newline in adjtime file'
printf '0.0 0 0\n0\nUTC' > /etc/adjtime
printf '0.0 0 0\n0\nUTC' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0\n0\nUTC' > /etc/adjtime
printf '0.0 0 0\n0\nUTC' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
LOCAL"
echo 'only one line in adjtime file'
printf '0.0 0 0\n' > /etc/adjtime
printf '0.0 0 0\n' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0\n' > /etc/adjtime
printf '0.0 0 0\n' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
LOCAL"
echo 'only one line in adjtime file, no final newline'
printf '0.0 0 0' > /etc/adjtime
printf '0.0 0 0' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0' > /etc/adjtime
printf '0.0 0 0' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
LOCAL"
echo 'only two lines in adjtime file'
printf '0.0 0 0\n0\n' > /etc/adjtime
printf '0.0 0 0\n0\n' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0\n0\n' > /etc/adjtime
printf '0.0 0 0\n0\n' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
LOCAL"
echo 'only two lines in adjtime file, no final newline'
printf '0.0 0 0\n0' > /etc/adjtime
printf '0.0 0 0\n0' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0\n0' > /etc/adjtime
printf '0.0 0 0\n0' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
LOCAL"
echo 'unknown value in 3rd line of adjtime file'
printf '0.0 0 0\n0\nFOO\n' > /etc/adjtime
printf '0.0 0 0\n0\nFOO\n' >/etc/adjtime
timedatectl set-local-rtc 0
check_adjtime_not_exist
printf '0.0 0 0\n0\nFOO\n' > /etc/adjtime
printf '0.0 0 0\n0\nFOO\n' >/etc/adjtime
timedatectl set-local-rtc 1
assert_eq "$(cat /etc/adjtime)" "0.0 0 0
0
+3 -3
View File
@@ -158,7 +158,7 @@ if systemctl --version | grep -q -- +OPENSSL ; then
fi
HAVE_OPENSSL=1
# Unfortunately OpenSSL insists on reading some config file, hence provide one with mostly placeholder contents
cat >> "${image}.openssl.cnf" <<EOF
cat >>"${image}.openssl.cnf" <<EOF
[ req ]
prompt = no
distinguished_name = req_distinguished_name
@@ -178,7 +178,7 @@ EOF
# Sign Verity root hash with it
openssl smime -sign -nocerts -noattr -binary -in "${image}.roothash" -inkey "${image}.key" -signer "${image}.crt" -outform der -out "${image}.roothash.p7s"
# Generate signature partition JSON data
echo '{"rootHash":"'"${roothash}"'","signature":"'"$(base64 -w 0 < "${image}.roothash.p7s")"'"}' > "${image}.verity-sig"
echo '{"rootHash":"'"${roothash}"'","signature":"'"$(base64 -w 0 <"${image}.roothash.p7s")"'"}' >"${image}.verity-sig"
# Pad it
truncate -s "${signature_size}" "${image}.verity-sig"
# Register certificate in the (userspace) verity key ring
@@ -418,7 +418,7 @@ rm /var/lib/extensions/app-nodistro.raw
mkdir -p /run/machines /run/portables /run/extensions
touch /run/machines/a.raw /run/portables/b.raw /run/extensions/c.raw
systemd-dissect --discover --json=short > /tmp/discover.json
systemd-dissect --discover --json=short >/tmp/discover.json
grep -q -F '{"name":"a","type":"raw","class":"machine","ro":false,"path":"/run/machines/a.raw"' /tmp/discover.json
grep -q -F '{"name":"b","type":"raw","class":"portable","ro":false,"path":"/run/portables/b.raw"' /tmp/discover.json
grep -q -F '{"name":"c","type":"raw","class":"extension","ro":false,"path":"/run/extensions/c.raw"' /tmp/discover.json
+1 -1
View File
@@ -17,7 +17,7 @@ systemd-run -p LoadCredential=passwd:/etc/passwd \
rm /tmp/ts54-concat
# Test that SetCredential= acts as fallback for LoadCredential=
echo piff > /tmp/ts54-fallback
echo piff >/tmp/ts54-fallback
[ "$(systemd-run -p LoadCredential=paff:/tmp/ts54-fallback -p SetCredential=paff:poff --pipe --wait systemd-creds cat paff)" = "piff" ]
rm /tmp/ts54-fallback
[ "$(systemd-run -p LoadCredential=paff:/tmp/ts54-fallback -p SetCredential=paff:poff --pipe --wait systemd-creds cat paff)" = "poff" ]
+1 -1
View File
@@ -9,7 +9,7 @@ else
counter=0
fi
echo "$counter" > /tmp/testsuite-57.counter
echo "$counter" >/tmp/testsuite-57.counter
if [ "$counter" -eq 5 ] ; then
systemctl kill --kill-whom=main -sUSR1 testsuite-57.service
+1 -1
View File
@@ -783,7 +783,7 @@ VerityMatchKey=root
EOF
# Unfortunately OpenSSL insists on reading some config file, hence provide one with mostly placeholder contents
runas testuser tee > "$defs/verity.openssl.cnf" <<EOF
runas testuser tee >"$defs/verity.openssl.cnf" <<EOF
[ req ]
prompt = no
distinguished_name = req_distinguished_name
+1 -1
View File
@@ -158,7 +158,7 @@ test_issue_20329() {
unit=$(systemd-escape --suffix mount --path "$tmpdir")
# Set up test mount unit
cat > /run/systemd/system/"$unit" <<EOF
cat >/run/systemd/system/"$unit" <<EOF
[Mount]
What=tmpfs
Where=$tmpdir
+1 -1
View File
@@ -60,6 +60,6 @@ systemctl start --wait testsuite-62-3.service
systemctl start --wait testsuite-62-4.service
systemctl start --wait testsuite-62-5.service
echo OK > /testok
echo OK >/testok
exit 0
@@ -7,4 +7,4 @@ DevicePolicy=strict
DeviceAllow=/dev/null r
StandardOutput=file:/tmp/testsuite66serviceresults
ExecStartPre=rm -f /tmp/testsuite66serviceresults
ExecStart=/bin/bash -c "while true; do sleep 0.01 && echo meow > /dev/null && echo thisshouldnotbehere; done"
ExecStart=/bin/bash -c "while true; do sleep 0.01 && echo meow >/dev/null && echo thisshouldnotbehere; done"
+2 -2
View File
@@ -29,9 +29,9 @@ trap cleanup EXIT
build_integrity_tab()
{
cat << _EOL > "/etc/integritytab"
cat <<EOF >"/etc/integritytab"
${DM_NAME} ${loop} - integrity-algorithm=$1
_EOL
EOF
}
image_dir="$(mktemp -d -t -p / integrity.tmp.XXXXXX)"
+9 -9
View File
@@ -61,8 +61,8 @@ tpm2_pcrextend 0:sha256=00000000000000000000000000000000000000000000000000000000
rm $img
if [[ -e /usr/lib/systemd/systemd-measure ]]; then
echo HALLO > /tmp/tpmdata1
echo foobar > /tmp/tpmdata2
echo HALLO >/tmp/tpmdata1
echo foobar >/tmp/tpmdata2
cat >/tmp/result <<EOF
11:sha1=5177e4ad69db92192c10e5f80402bf81bfec8a81
@@ -119,10 +119,10 @@ if [ -e /usr/lib/systemd/systemd-measure ] && \
# Invalidate PCR, decrypting should fail now
tpm2_pcrextend 11:sha256=0000000000000000000000000000000000000000000000000000000000000000
systemd-creds decrypt /tmp/pcrtestdata.encrypted - --tpm2-signature="/tmp/pcrsign.sig" > /dev/null && { echo 'unexpected success'; exit 1; }
systemd-creds decrypt /tmp/pcrtestdata.encrypted - --tpm2-signature="/tmp/pcrsign.sig" >/dev/null && { echo 'unexpected success'; exit 1; }
# Sign new PCR state, decrypting should work now.
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: > "/tmp/pcrsign.sig2"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: >"/tmp/pcrsign.sig2"
systemd-creds decrypt /tmp/pcrtestdata.encrypted - --tpm2-signature="/tmp/pcrsign.sig2" | cmp - /tmp/pcrtestdata
# Now, do the same, but with a cryptsetup binding
@@ -144,18 +144,18 @@ if [ -e /usr/lib/systemd/systemd-measure ] && \
SYSTEMD_CRYPTSETUP_USE_TOKEN_MODULE=1 /usr/lib/systemd/systemd-cryptsetup attach test-volume2 $img - tpm2-device=auto,tpm2-signature="/tmp/pcrsign.sig2",headless=1 && { echo 'unexpected success'; exit 1; }
# But once we sign the current PCRs, we should be able to unlock again
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: > "/tmp/pcrsign.sig3"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: >"/tmp/pcrsign.sig3"
SYSTEMD_CRYPTSETUP_USE_TOKEN_MODULE=0 /usr/lib/systemd/systemd-cryptsetup attach test-volume2 $img - tpm2-device=auto,tpm2-signature="/tmp/pcrsign.sig3",headless=1
/usr/lib/systemd/systemd-cryptsetup detach test-volume2
SYSTEMD_CRYPTSETUP_USE_TOKEN_MODULE=1 /usr/lib/systemd/systemd-cryptsetup attach test-volume2 $img - tpm2-device=auto,tpm2-signature="/tmp/pcrsign.sig3",headless=1
/usr/lib/systemd/systemd-cryptsetup detach test-volume2
# Test --append mode and de-duplication. With the same parameters signing should not add a new entry
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: --append="/tmp/pcrsign.sig3" > "/tmp/pcrsign.sig4"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: --append="/tmp/pcrsign.sig3" >"/tmp/pcrsign.sig4"
cmp "/tmp/pcrsign.sig3" "/tmp/pcrsign.sig4"
# Sign one more phase, this should
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=quux:waldo --append="/tmp/pcrsign.sig4" > "/tmp/pcrsign.sig5"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=quux:waldo --append="/tmp/pcrsign.sig4" >"/tmp/pcrsign.sig5"
( ! cmp "/tmp/pcrsign.sig4" "/tmp/pcrsign.sig5" )
# Should still be good to unlock, given the old entry still exists
@@ -163,8 +163,8 @@ if [ -e /usr/lib/systemd/systemd-measure ] && \
/usr/lib/systemd/systemd-cryptsetup detach test-volume2
# Adding both signatures once more should not change anything, due to the deduplication
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: --append="/tmp/pcrsign.sig5" > "/tmp/pcrsign.sig6"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=quux:waldo --append="/tmp/pcrsign.sig6" > "/tmp/pcrsign.sig7"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=: --append="/tmp/pcrsign.sig5" >"/tmp/pcrsign.sig6"
/usr/lib/systemd/systemd-measure sign --current "${MEASURE_BANKS[@]}" --private-key="/tmp/pcrsign-private.pem" --public-key="/tmp/pcrsign-public.pem" --phase=quux:waldo --append="/tmp/pcrsign.sig6" >"/tmp/pcrsign.sig7"
cmp "/tmp/pcrsign.sig5" "/tmp/pcrsign.sig7"
rm $img
+4 -4
View File
@@ -114,17 +114,17 @@ EOF
systemctl daemon-reload
mount -t tmpfs none /sys/class/dmi/id
echo '1' > /sys/class/dmi/id/uevent
echo '1' >/sys/class/dmi/id/uevent
echo '01/01/2000' > /sys/class/dmi/id/bios_date
echo '01/01/2000' >/sys/class/dmi/id/bios_date
systemctl stop systemd-hostnamed
assert_in '2000-01-01' "$(hostnamectl)"
echo '2022' > /sys/class/dmi/id/bios_date
echo '2022' >/sys/class/dmi/id/bios_date
systemctl stop systemd-hostnamed
assert_not_in 'Firmware Date' "$(hostnamectl)"
echo 'garbage' > /sys/class/dmi/id/bios_date
echo 'garbage' >/sys/class/dmi/id/bios_date
systemctl stop systemd-hostnamed
assert_not_in 'Firmware Date' "$(hostnamectl)"
}
+1 -1
View File
@@ -79,7 +79,7 @@ test_locale() {
if command -v locale-gen >/dev/null 2>&1 &&
! localectl list-locales | grep -F "en_US.UTF-8"; then
# ensure at least one utf8 locale exist
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
echo "en_US.UTF-8 UTF-8" >/etc/locale.gen
locale-gen en_US.UTF-8
fi
+5 -5
View File
@@ -8,11 +8,11 @@ set -o pipefail
export SYSTEMD_LOG_LEVEL=debug
echo "foo.bar=42" > /tmp/foo.conf
echo "foo.bar=42" >/tmp/foo.conf
assert_rc 0 /usr/lib/systemd/systemd-sysctl /tmp/foo.conf
assert_rc 1 /usr/lib/systemd/systemd-sysctl --strict /tmp/foo.conf
echo "-foo.foo=42" > /tmp/foo.conf
echo "-foo.foo=42" >/tmp/foo.conf
assert_rc 0 /usr/lib/systemd/systemd-sysctl /tmp/foo.conf
assert_rc 0 /usr/lib/systemd/systemd-sysctl --strict /tmp/foo.conf
@@ -26,9 +26,9 @@ net.ipv4.*.*.bootp_relay=1
net.ipv4.aaa.*.disable_policy=1
EOF
echo 0 > /proc/sys/net/ipv4/conf/hoge/drop_gratuitous_arp
echo 0 > /proc/sys/net/ipv4/conf/hoge/bootp_relay
echo 0 > /proc/sys/net/ipv4/conf/hoge/disable_policy
echo 0 >/proc/sys/net/ipv4/conf/hoge/drop_gratuitous_arp
echo 0 >/proc/sys/net/ipv4/conf/hoge/bootp_relay
echo 0 >/proc/sys/net/ipv4/conf/hoge/disable_policy
assert_rc 0 /usr/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/hoge /tmp/foo.conf
assert_eq "$(cat /proc/sys/net/ipv4/conf/hoge/drop_gratuitous_arp)" "1"
+1 -1
View File
@@ -27,7 +27,7 @@ diff <(systemctl show -p OpenFile testsuite-77) - <<EOF
OpenFile=/test-77-open.dat:open:read-only
OpenFile=/test-77-file.dat
EOF
echo "New" > /test-77-new-file.dat
echo "New" >/test-77-new-file.dat
systemd-run --wait -p OpenFile=/test-77-new-file.dat:new-file:read-only "$(dirname "$0")"/testsuite-77-run.sh
assert_rc 202 systemd-run --wait -p OpenFile=/test-77-new-file.dat:new-file:read-only -p OpenFile=/test-77-mssing-file.dat:missing-file:read-only "$(dirname "$0")"/testsuite-77-run.sh