mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
test: add tests for UpheldBy= in [Install] section
This commit is contained in:
parent
38f901791f
commit
b5b1351317
@ -1135,6 +1135,9 @@ TEST(verify_alias) {
|
|||||||
verify_one(&plain_service, "alias.socket", -EXDEV, NULL);
|
verify_one(&plain_service, "alias.socket", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "alias@.service", -EXDEV, NULL);
|
verify_one(&plain_service, "alias@.service", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "alias@inst.service", -EXDEV, NULL);
|
verify_one(&plain_service, "alias@inst.service", -EXDEV, NULL);
|
||||||
|
|
||||||
|
/* Setting WantedBy= and RequiredBy= through Alias= is supported for the sake of backwards
|
||||||
|
* compatibility. */
|
||||||
verify_one(&plain_service, "foo.target.wants/plain.service", 0, NULL);
|
verify_one(&plain_service, "foo.target.wants/plain.service", 0, NULL);
|
||||||
verify_one(&plain_service, "foo.target.wants/plain.socket", -EXDEV, NULL);
|
verify_one(&plain_service, "foo.target.wants/plain.socket", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "foo.target.wants/plain@.service", -EXDEV, NULL);
|
verify_one(&plain_service, "foo.target.wants/plain@.service", -EXDEV, NULL);
|
||||||
@ -1143,9 +1146,14 @@ TEST(verify_alias) {
|
|||||||
verify_one(&plain_service, "foo.target.requires/plain.socket", -EXDEV, NULL);
|
verify_one(&plain_service, "foo.target.requires/plain.socket", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "foo.target.requires/plain@.service", -EXDEV, NULL);
|
verify_one(&plain_service, "foo.target.requires/plain@.service", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "foo.target.requires/service", -EXDEV, NULL);
|
verify_one(&plain_service, "foo.target.requires/service", -EXDEV, NULL);
|
||||||
verify_one(&plain_service, "foo.target.conf/plain.service", -EXDEV, NULL);
|
|
||||||
verify_one(&plain_service, "foo.service/plain.service", -EXDEV, NULL); /* missing dir suffix */
|
|
||||||
verify_one(&plain_service, "asdf.requires/plain.service", -EXDEV, NULL); /* invalid unit name component */
|
verify_one(&plain_service, "asdf.requires/plain.service", -EXDEV, NULL); /* invalid unit name component */
|
||||||
|
/* The newly-added UpheldBy= (.upholds/) and other suffixes should be rejected */
|
||||||
|
verify_one(&plain_service, "foo.target.upholds/plain.service", -EXDEV, NULL);
|
||||||
|
verify_one(&plain_service, "foo.target.upholds/plain.socket", -EXDEV, NULL);
|
||||||
|
verify_one(&plain_service, "foo.target.upholds/plain@.service", -EXDEV, NULL);
|
||||||
|
verify_one(&plain_service, "foo.target.upholds/service", -EXDEV, NULL);
|
||||||
|
verify_one(&plain_service, "foo.service/plain.service", -EXDEV, NULL); /* missing dir suffix */
|
||||||
|
verify_one(&plain_service, "foo.target.conf/plain.service", -EXDEV, NULL);
|
||||||
|
|
||||||
verify_one(&bare_template, "alias.service", -EXDEV, NULL);
|
verify_one(&bare_template, "alias.service", -EXDEV, NULL);
|
||||||
verify_one(&bare_template, "alias.socket", -EXDEV, NULL);
|
verify_one(&bare_template, "alias.socket", -EXDEV, NULL);
|
||||||
|
@ -269,6 +269,8 @@ Type=
|
|||||||
USBFunctionDescriptors=
|
USBFunctionDescriptors=
|
||||||
USBFunctionStrings=
|
USBFunctionStrings=
|
||||||
Unit=
|
Unit=
|
||||||
|
UpheldBy=
|
||||||
|
Upholds=
|
||||||
User=
|
User=
|
||||||
WakeSystem=
|
WakeSystem=
|
||||||
WantedBy=
|
WantedBy=
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
[Unit]
|
||||||
|
Description=Unit that sets UpheldBy= through [Install]
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/bin/sleep infinity
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
UpheldBy=testsuite-23-retry-uphold.service
|
@ -30,6 +30,8 @@ done
|
|||||||
|
|
||||||
systemctl stop testsuite-23-uphold.service
|
systemctl stop testsuite-23-uphold.service
|
||||||
|
|
||||||
|
systemctl enable testsuite-23-upheldby-install.service
|
||||||
|
|
||||||
# Idea is this:
|
# Idea is this:
|
||||||
# 1. we start testsuite-23-retry-uphold.service
|
# 1. we start testsuite-23-retry-uphold.service
|
||||||
# 2. which through Uphold= starts testsuite-23-retry-upheld.service
|
# 2. which through Uphold= starts testsuite-23-retry-upheld.service
|
||||||
@ -42,12 +44,13 @@ systemctl stop testsuite-23-uphold.service
|
|||||||
|
|
||||||
rm -f /tmp/testsuite-23-retry-fail
|
rm -f /tmp/testsuite-23-retry-fail
|
||||||
systemctl start testsuite-23-retry-uphold.service
|
systemctl start testsuite-23-retry-uphold.service
|
||||||
|
systemctl is-active testsuite-23-upheldby-install.service
|
||||||
|
|
||||||
while ! systemctl is-failed testsuite-23-retry-fail.service ; do
|
while ! systemctl is-failed testsuite-23-retry-fail.service ; do
|
||||||
sleep .5
|
sleep .5
|
||||||
done
|
done
|
||||||
|
|
||||||
systemctl is-active testsuite-23-retry-upheld.service && { echo 'unexpected success'; exit 1; }
|
(! systemctl is-active testsuite-23-retry-upheld.service)
|
||||||
|
|
||||||
touch /tmp/testsuite-23-retry-fail
|
touch /tmp/testsuite-23-retry-fail
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user