|
|
ac3a84 |
From 956944405391b5bbb8a4fee9ad93e14bf908f0a9 Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
|
|
ac3a84 |
Date: Fri, 13 Jan 2023 20:10:42 +0100
|
|
|
ac3a84 |
Subject: [PATCH] test: support a non-default SysV directory
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Since the directory is configurable via -Dsysvinit-path= during build,
|
|
|
ac3a84 |
it makes the test fail on Fedora/RHEL/CentOS, where it's set to
|
|
|
ac3a84 |
/etc/rc.d/init.d, instead of the default /etc/init.d. Since we can't get
|
|
|
ac3a84 |
the value at runtime (in a reasonable manner), let's just support the
|
|
|
ac3a84 |
two most common paths for now.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Follow up to 7fcf0fab078ed92a4f6c3c3658c0a9dfd67c9601.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
(cherry picked from commit fc2a0bc05e0429e468c7eaad52998292105fe7fb)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related: #2160477
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
test/units/testsuite-26.sh | 25 ++++++++++++++-----------
|
|
|
ac3a84 |
1 file changed, 14 insertions(+), 11 deletions(-)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/test/units/testsuite-26.sh b/test/units/testsuite-26.sh
|
|
|
ac3a84 |
index 37ae6069bc..916a6704d7 100755
|
|
|
ac3a84 |
--- a/test/units/testsuite-26.sh
|
|
|
ac3a84 |
+++ b/test/units/testsuite-26.sh
|
|
|
ac3a84 |
@@ -294,9 +294,12 @@ systemctl unset-environment IMPORT_THIS IMPORT_THIS_TOO
|
|
|
ac3a84 |
|
|
|
ac3a84 |
# test for sysv-generator (issue #24990)
|
|
|
ac3a84 |
if [[ -x /usr/lib/systemd/system-generators/systemd-sysv-generator ]]; then
|
|
|
ac3a84 |
- mkdir -p /etc/init.d
|
|
|
ac3a84 |
+ # This is configurable via -Dsysvinit-path=, but we can't get the value
|
|
|
ac3a84 |
+ # at runtime, so let's just support the two most common paths for now.
|
|
|
ac3a84 |
+ [[ -d /etc/rc.d/init.d ]] && SYSVINIT_PATH="/etc/rc.d/init.d" || SYSVINIT_PATH="/etc/init.d"
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
# invalid dependency
|
|
|
ac3a84 |
- cat >/etc/init.d/issue-24990 <<\EOF
|
|
|
ac3a84 |
+ cat >"${SYSVINIT_PATH:?}/issue-24990" <<\EOF
|
|
|
ac3a84 |
#!/bin/bash
|
|
|
ac3a84 |
|
|
|
ac3a84 |
### BEGIN INIT INFO
|
|
|
ac3a84 |
@@ -322,21 +325,21 @@ case "$1" in
|
|
|
ac3a84 |
esac
|
|
|
ac3a84 |
EOF
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- chmod +x /etc/init.d/issue-24990
|
|
|
ac3a84 |
+ chmod +x "$SYSVINIT_PATH/issue-24990"
|
|
|
ac3a84 |
systemctl daemon-reload
|
|
|
ac3a84 |
[[ -L /run/systemd/generator.late/test1.service ]]
|
|
|
ac3a84 |
[[ -L /run/systemd/generator.late/test2.service ]]
|
|
|
ac3a84 |
assert_eq "$(readlink -f /run/systemd/generator.late/test1.service)" "/run/systemd/generator.late/issue-24990.service"
|
|
|
ac3a84 |
assert_eq "$(readlink -f /run/systemd/generator.late/test2.service)" "/run/systemd/generator.late/issue-24990.service"
|
|
|
ac3a84 |
output=$(systemctl cat issue-24990)
|
|
|
ac3a84 |
- assert_in "SourcePath=/etc/init.d/issue-24990" "$output"
|
|
|
ac3a84 |
+ assert_in "SourcePath=$SYSVINIT_PATH/issue-24990" "$output"
|
|
|
ac3a84 |
assert_in "Description=LSB: Test" "$output"
|
|
|
ac3a84 |
assert_in "After=test1.service" "$output"
|
|
|
ac3a84 |
assert_in "After=remote-fs.target" "$output"
|
|
|
ac3a84 |
assert_in "After=network-online.target" "$output"
|
|
|
ac3a84 |
assert_in "Wants=network-online.target" "$output"
|
|
|
ac3a84 |
- assert_in "ExecStart=/etc/init.d/issue-24990 start" "$output"
|
|
|
ac3a84 |
- assert_in "ExecStop=/etc/init.d/issue-24990 stop" "$output"
|
|
|
ac3a84 |
+ assert_in "ExecStart=$SYSVINIT_PATH/issue-24990 start" "$output"
|
|
|
ac3a84 |
+ assert_in "ExecStop=$SYSVINIT_PATH/issue-24990 stop" "$output"
|
|
|
ac3a84 |
systemctl status issue-24990 || :
|
|
|
ac3a84 |
systemctl show issue-24990
|
|
|
ac3a84 |
assert_not_in "issue-24990.service" "$(systemctl show --property=After --value)"
|
|
|
ac3a84 |
@@ -350,7 +353,7 @@ EOF
|
|
|
ac3a84 |
systemctl stop issue-24990
|
|
|
ac3a84 |
|
|
|
ac3a84 |
# valid dependency
|
|
|
ac3a84 |
- cat >/etc/init.d/issue-24990 <<\EOF
|
|
|
ac3a84 |
+ cat >"$SYSVINIT_PATH/issue-24990" <<\EOF
|
|
|
ac3a84 |
#!/bin/bash
|
|
|
ac3a84 |
|
|
|
ac3a84 |
### BEGIN INIT INFO
|
|
|
ac3a84 |
@@ -376,18 +379,18 @@ case "$1" in
|
|
|
ac3a84 |
esac
|
|
|
ac3a84 |
EOF
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- chmod +x /etc/init.d/issue-24990
|
|
|
ac3a84 |
+ chmod +x "$SYSVINIT_PATH/issue-24990"
|
|
|
ac3a84 |
systemctl daemon-reload
|
|
|
ac3a84 |
[[ -L /run/systemd/generator.late/test1.service ]]
|
|
|
ac3a84 |
[[ -L /run/systemd/generator.late/test2.service ]]
|
|
|
ac3a84 |
assert_eq "$(readlink -f /run/systemd/generator.late/test1.service)" "/run/systemd/generator.late/issue-24990.service"
|
|
|
ac3a84 |
assert_eq "$(readlink -f /run/systemd/generator.late/test2.service)" "/run/systemd/generator.late/issue-24990.service"
|
|
|
ac3a84 |
output=$(systemctl cat issue-24990)
|
|
|
ac3a84 |
- assert_in "SourcePath=/etc/init.d/issue-24990" "$output"
|
|
|
ac3a84 |
+ assert_in "SourcePath=$SYSVINIT_PATH/issue-24990" "$output"
|
|
|
ac3a84 |
assert_in "Description=LSB: Test" "$output"
|
|
|
ac3a84 |
assert_in "After=remote-fs.target" "$output"
|
|
|
ac3a84 |
- assert_in "ExecStart=/etc/init.d/issue-24990 start" "$output"
|
|
|
ac3a84 |
- assert_in "ExecStop=/etc/init.d/issue-24990 stop" "$output"
|
|
|
ac3a84 |
+ assert_in "ExecStart=$SYSVINIT_PATH/issue-24990 start" "$output"
|
|
|
ac3a84 |
+ assert_in "ExecStop=$SYSVINIT_PATH/issue-24990 stop" "$output"
|
|
|
ac3a84 |
systemctl status issue-24990 || :
|
|
|
ac3a84 |
systemctl show issue-24990
|
|
|
ac3a84 |
assert_not_in "issue-24990.service" "$(systemctl show --property=After --value)"
|