You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

318 lines
16 KiB

From 71a8029607b54259f28ac1fc0627c7f1e6db586a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 24 Mar 2022 11:52:35 +0100
Subject: [PATCH] test-systemctl-enable: make shellcheck happy
Quoting is not necessary in many places, but I think it's nicer
to use it consistently.
(cherry picked from commit 84fdced62c740a3b07656e84747dd721ad6a30c5)
Related: #2082131
---
test/test-systemctl-enable.sh | 76 +++++++++++++++++------------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh
index 45f3513de3..3b30f090a5 100644
--- a/test/test-systemctl-enable.sh
+++ b/test/test-systemctl-enable.sh
@@ -19,10 +19,10 @@ islink() {
test "$(readlink "$1")" = "$2" || return 2
}
-: ------enablement nonexistent--------------------------------
+: '------enable nonexistent------------------------------------'
"$systemctl" --root="$root" enable test1.service && { echo "Expected failure" >&2; exit 1; }
-: ------basic enablement--------------------------------------
+: '------basic enablement--------------------------------------'
mkdir -p "$root/etc/systemd/system"
cat >"$root/etc/systemd/system/test1.service" <<EOF
[Install]
@@ -42,7 +42,7 @@ test -h "$root/etc/systemd/system/special.target.requires/test1.service"
test ! -e "$root/etc/systemd/system/default.target.wants/test1.service"
test ! -e "$root/etc/systemd/system/special.target.requires/test1.service"
-: ------suffix guessing---------------------------------------
+: '------suffix guessing---------------------------------------'
"$systemctl" --root="$root" enable test1
test -h "$root/etc/systemd/system/default.target.wants/test1.service"
test -h "$root/etc/systemd/system/special.target.requires/test1.service"
@@ -55,7 +55,7 @@ test -h "$root/etc/systemd/system/special.target.requires/test1.service"
test ! -e "$root/etc/systemd/system/default.target.wants/test1.service"
test ! -e "$root/etc/systemd/system/special.target.requires/test1.service"
-: -------aliases----------------------------------------------
+: '-------aliases----------------------------------------------'
cat >>"$root/etc/systemd/system/test1.service" <<EOF
Alias=test1-goodalias.service
Alias=test1@badalias.service
@@ -76,7 +76,7 @@ test ! -h "$root/etc/systemd/system/test1-badalias.socket"
test -e "$root/etc/systemd/system/test1-goodalias2.service"
test -h "$root/etc/systemd/system/test1-goodalias2.service"
-: -------aliases in reeanble----------------------------------
+: '-------aliases in reeanble----------------------------------'
"$systemctl" --root="$root" reenable test1 && { echo "Expected failure" >&2; exit 1; }
islink "$root/etc/systemd/system/default.target.wants/test1.service" "../test1.service"
islink "$root/etc/systemd/system/test1-goodalias.service" "test1.service"
@@ -90,7 +90,7 @@ test ! -h "$root/etc/systemd/system/default.target.wants/test1.service"
test ! -h "$root/etc/systemd/system/special.target.requires/test1.service"
test ! -h "$root/etc/systemd/system/test1-goodalias.service"
-: -------also units-------------------------------------------
+: '-------also units-------------------------------------------'
cat >"$root/etc/systemd/system/test2.socket" <<EOF
[Install]
WantedBy=sockets.target
@@ -116,7 +116,7 @@ test ! -e "$root/etc/systemd/system/default.target.wants/test2.service"
test ! -e "$root/etc/systemd/system/sockets.target.wants/test2.socket"
-: -------link-------------------------------------------------
+: '-------link-------------------------------------------------'
# File doesn't exist yet
test ! -e "$root/link1.path"
"$systemctl" --root="$root" link '/link1.path' && { echo "Expected failure" >&2; exit 1; }
@@ -130,65 +130,65 @@ EOF
"$systemctl" --root="$root" link '/link1.path'
islink "$root/etc/systemd/system/link1.path" "/link1.path"
-: -------link already linked same path------------------------
+: '-------link already linked same path------------------------'
SYSTEMD_LOG_LEVEL=debug "$systemctl" --root="$root" link '/link1.path' # this passes
islink "$root/etc/systemd/system/link1.path" "/link1.path"
-: -------link already linked different path-------------------
+: '-------link already linked different path-------------------'
mkdir "$root/subdir"
cp "$root/link1.path" "$root/subdir/"
"$systemctl" --root="$root" link '/subdir/link1.path' && { echo "Expected failure" >&2; exit 1; }
islink "$root/etc/systemd/system/link1.path" "/link1.path"
-: -------link bad suffix--------------------------------------
+: '-------link bad suffix--------------------------------------'
cp "$root/link1.path" "$root/subdir/link1.suffix"
"$systemctl" --root="$root" link '/subdir/link1.suffix' && { echo "Expected failure" >&2; exit 1; }
test ! -e "$root/etc/systemd/system/link1.suffix"
-: -------unlink by unit name----------------------------------
+: '-------unlink by unit name----------------------------------'
"$systemctl" --root="$root" disable 'link1.path'
test ! -e "$root/etc/systemd/system/link1.path"
-: -------unlink by path---------------------------------------
+: '-------unlink by path---------------------------------------'
"$systemctl" --root="$root" link '/link1.path'
test -h "$root/etc/systemd/system/link1.path"
"$systemctl" --root="$root" disable '/link1.path'
test ! -e "$root/etc/systemd/system/link1.path"
-: -------unlink by wrong path---------------------------------
+: '-------unlink by wrong path---------------------------------'
"$systemctl" --root="$root" link '/link1.path'
test -h "$root/etc/systemd/system/link1.path"
"$systemctl" --root="$root" disable '/subdir/link1.path' # we only care about the name
test ! -e "$root/etc/systemd/system/link1.path"
-: -------link and enable--------------------------------------
+: '-------link and enable--------------------------------------'
"$systemctl" --root="$root" enable '/link1.path'
islink "$root/etc/systemd/system/link1.path" "/link1.path"
islink "$root/etc/systemd/system/paths.target.wants/link1.path" "../link1.path"
-: -------enable already linked same path----------------------
+: '-------enable already linked same path----------------------'
"$systemctl" --root="$root" enable '/link1.path'
islink "$root/etc/systemd/system/link1.path" "/link1.path"
islink "$root/etc/systemd/system/paths.target.wants/link1.path" "../link1.path"
-: -------enable already linked different path-----------------
+: '-------enable already linked different path-----------------'
"$systemctl" --root="$root" enable '/subdir/link1.path' && { echo "Expected failure" >&2; exit 1; }
islink "$root/etc/systemd/system/link1.path" "/link1.path"
islink "$root/etc/systemd/system/paths.target.wants/link1.path" "../link1.path"
-: -------enable bad suffix------------------------------------
+: '-------enable bad suffix------------------------------------'
cp "$root/link1.path" "$root/subdir/link1.suffix"
"$systemctl" --root="$root" enable '/subdir/link1.suffix' && { echo "Expected failure" >&2; exit 1; }
test ! -e "$root/etc/systemd/system/link1.suffix"
test ! -e "$root/etc/systemd/system/paths.target.wants/link1.suffix"
-: -------disable by unit name---------------------------------
+: '-------disable by unit name---------------------------------'
"$systemctl" --root="$root" disable 'link1.path'
test ! -e "$root/etc/systemd/system/link1.path"
test ! -e "$root/etc/systemd/system/paths.target.wants/link1.path"
-: -------disable by path--------------------------------------
+: '-------disable by path--------------------------------------'
"$systemctl" --root="$root" enable '/link1.path'
test -h "$root/etc/systemd/system/link1.path"
test -h "$root/etc/systemd/system/paths.target.wants/link1.path"
@@ -197,7 +197,7 @@ test ! -e "$root/etc/systemd/system/link1.path"
test ! -e "$root/etc/systemd/system/paths.target.wants/link1.path"
-: -------link then enable-------------------------------------
+: '-------link and enable-------------------------------------'
"$systemctl" --root="$root" link '/link1.path'
islink "$root/etc/systemd/system/link1.path" "/link1.path"
test ! -h "$root/etc/systemd/system/paths.target.wants/link1.path"
@@ -210,7 +210,7 @@ islink "$root/etc/systemd/system/paths.target.wants/link1.path" "../link1.path"
islink "$root/etc/systemd/system/link1.path" "/link1.path"
islink "$root/etc/systemd/system/paths.target.wants/link1.path" "../link1.path"
-: -------manual link------------------------------------------
+: '-------manual link------------------------------------------'
cat >"$root/link3.suffix" <<EOF
[Install]
WantedBy=services.target
@@ -227,18 +227,18 @@ SYSTEMD_LOG_LEVEL=debug SYSTEMD_LOG_LOCATION=1 "$systemctl" --root="$root" disab
test ! -h "$root/etc/systemd/system/link3.service"
test ! -h "$root/etc/systemd/system/services.target.wants/link3.service"
-: -------enable on masked-------------------------------------
+: '-------enable on masked-------------------------------------'
ln -s "/dev/null" "$root/etc/systemd/system/masked.service"
"$systemctl" --root="$root" enable 'masked.service' && { echo "Expected failure" >&2; exit 1; }
"$systemctl" --root="$root" enable '/etc/systemd/system/masked.service' && { echo "Expected failure" >&2; exit 1; }
-: -------enable on masked alias-------------------------------
+: '-------enable on masked alias-------------------------------'
test -h "$root/etc/systemd/system/masked.service"
ln -s "masked.service" "$root/etc/systemd/system/masked-alias.service"
"$systemctl" --root="$root" enable 'masked-alias.service' && { echo "Expected failure" >&2; exit 1; }
"$systemctl" --root="$root" enable '/etc/systemd/system/masked-alias.service' && { echo "Expected failure" >&2; exit 1; }
-: -------issue 22000: link in subdirectory--------------------
+: '-------issue 22000: link in subdirectory--------------------'
mkdir -p "$root/etc/systemd/system/myown.d"
cat >"$root/etc/systemd/system/link5-also.service" <<EOF
[Install]
@@ -259,7 +259,7 @@ test ! -h "$root/etc/systemd/system/services.target.wants/link5-also.service"
test ! -h "$root/etc/systemd/system/services.target.wants/link5.service"
islink "$root/etc/systemd/system/services.target.wants/link5-also.service" "../link5-also.service"
-: -------template enablement----------------------------------
+: '-------template enablement----------------------------------'
cat >"$root/etc/systemd/system/templ1@.service" <<EOF
[Install]
WantedBy=services.target
@@ -288,7 +288,7 @@ test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@one.service"
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@two.service"
-: -------template enablement w/ default instance--------------
+: '-------template enablement w/ default instance--------------'
cat >"$root/etc/systemd/system/templ1@.service" <<EOF
[Install]
# check enablement with
@@ -337,7 +337,7 @@ test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@one.serv
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@two.service"
test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@two.service"
-: -------removal of relative enablement symlinks--------------
+: '-------removal of relative enablement symlinks--------------'
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
ln -s '../templ1@one.service' "$root/etc/systemd/system/services.target.wants/templ1@one.service"
ln -s 'templ1@two.service' "$root/etc/systemd/system/services.target.wants/templ1@two.service"
@@ -357,7 +357,7 @@ test ! -h "$root/etc/systemd/system/services.target.wants/templ1@five.service"
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@six.service"
test ! -h "$root/etc/systemd/system/services.target.wants/templ1@seven.service"
-: -------template enablement for another template-------------
+: '-------template enablement for another template-------------'
cat >"$root/etc/systemd/system/templ2@.service" <<EOF
[Install]
RequiredBy=another-template@.target
@@ -382,7 +382,7 @@ test ! -h "$root/etc/systemd/system/another-template@.target.requires/templ2@two
test ! -h "$root/etc/systemd/system/another-template@.target.requires/templ2@.service"
test ! -h "$root/etc/systemd/system/another-template@.target.requires/templ2@two.service"
-: -------aliases w/ and w/o instance--------------------------
+: '-------aliases w/ and w/o instance--------------------------'
test ! -e "$root/etc/systemd/system/link4.service"
cat >"$root/etc/systemd/system/link4.service" <<EOF
[Install]
@@ -407,7 +407,7 @@ test ! -h "$root/etc/systemd/system/link4@inst.service"
test ! -h "$root/etc/systemd/system/link4alias.service"
test ! -h "$root/etc/systemd/system/link4alias2.service"
-: -------systemctl enable on path to unit file----------------
+: '-------systemctl enable on path to unit file----------------'
cat >"$root/etc/systemd/system/link4.service" <<EOF
[Install]
Alias=link4alias.service
@@ -425,7 +425,7 @@ test ! -h "$root/etc/systemd/system/link4.service"
test ! -h "$root/etc/systemd/system/link4alias.service"
test ! -h "$root/etc/systemd/system/link4alias2.service"
-: -------issue 661: enable on unit file--------------
+: '-------issue 661: enable on unit file--------------'
test ! -e "$root/etc/systemd/system/link5.service"
cat >"$root/etc/systemd/system/link5.service" <<EOF
[Install]
@@ -443,7 +443,7 @@ islink "$root/etc/systemd/system/link5alias2.service" "link5.service"
test ! -h "$root/etc/systemd/system/link5alias.service"
test ! -h "$root/etc/systemd/system/link5alias2.service"
-: -------issue 661: link and enable on unit file--------------
+: '-------issue 661: link and enable on unit file--------------'
test ! -e "$root/etc/systemd/system/link5copy.service"
cat >"$root/link5copy.service" <<EOF
[Install]
@@ -474,7 +474,7 @@ test ! -h "$root/etc/systemd/system/link5copy.service"
test ! -h "$root/etc/systemd/system/link5alias.service"
test ! -h "$root/etc/systemd/system/link5alias2.service"
-: ----issue 19437: plain templates in .wants/ or .requires/---
+: '----issue 19437: plain templates in .wants/ or .requires/---'
test ! -e "$root/etc/systemd/system/link5@.path"
cat >"$root/etc/systemd/system/link5@.path" <<EOF
[Install]
@@ -498,7 +498,7 @@ test ! -h "$root/etc/systemd/system/target5@.target.requires/link5@.path"
test ! -h "$root/etc/systemd/system/target5@inst.target.wants/link5@.path"
test ! -h "$root/etc/systemd/system/target5@inst.target.requires/link5@.path"
-: -------removal of symlinks not listed in [Install]----------
+: '-------removal of symlinks not listed in [Install]----------'
# c.f. 66a19d85a533b15ed32f4066ec880b5a8c06babd
test ! -e "$root/etc/systemd/system/multilink.mount"
cat >"$root/etc/systemd/system/multilink.mount" <<EOF
@@ -517,12 +517,12 @@ test ! -h "$root/etc/systemd/system/default.target.wants/"
test ! -h "$root/etc/systemd/system/multilink-alias.mount"
test ! -h "$root/etc/systemd/system/multilink-badalias.service"
-: -------merge 20017: specifiers in the unit file-------------
+: '-------merge 20017: specifiers in the unit file-------------'
test ! -e "$root/etc/systemd/system/some-some-link6@.socket"
# c.f. de61a04b188f81a85cdb5c64ddb4987dcd9d30d3
check_alias() {
- : ------------------ %$1 -------------------------------------
+ : "------------------ %$1 -------------------------------------"
cat >"$root/etc/systemd/system/some-some-link6@.socket" <<EOF
[Install]
Alias=target@$1:%$1.socket
@@ -616,7 +616,7 @@ check_alias % '%' && { echo "Expected failure because % is not legal in unit nam
check_alias z 'z' && { echo "Expected failure because %z is not known" >&2; exit 1; }
-: -------specifiers in WantedBy-------------------------------
+: '-------specifiers in WantedBy-------------------------------'
# We don't need to repeat all the tests. Let's do a basic check that specifier
# expansion is performed.
@@ -642,7 +642,7 @@ test ! -h "$root/etc/systemd/system/another-target2@.target.requires/some-some-l
# TODO: repeat the tests above for presets
-: -------SYSTEMD_OS_RELEASE relative to root------------------
+: '-------SYSTEMD_OS_RELEASE relative to root-------------------'
# check that os-release overwriting works as expected with root
test -e "$root/etc/os-release"