2 # SPDX-License-Identifier: LGPL-2.1-or-later
7 local UNIT_NAME
="${1:?}"
8 systemctl stop
"$UNIT_NAME" 2>/dev
/null ||
:
9 rm -f /{etc
,run
,usr
/lib
}/systemd
/system
/"$UNIT_NAME"
10 rm -fr /{etc
,run
,usr
/lib
}/systemd
/system
/"$UNIT_NAME".d
11 rm -fr /{etc
,run
,usr
/lib
}/systemd
/system
/"$UNIT_NAME".
{wants
,requires
}
12 if [[ $UNIT_NAME == *@
]]; then
13 local base
="${UNIT_NAME%@*}"
14 local suffix
="${UNIT_NAME##*.}"
15 systemctl stop
"$base@"*.
"$suffix" 2>/dev
/null ||
:
16 rm -f /{etc
,run
,usr
/lib
}/systemd
/system
/"$base@"*.
"$suffix"
17 rm -fr /{etc
,run
,usr
/lib
}/systemd
/system
/"$base@"*.
"$suffix".d
18 rm -fr /{etc
,run
,usr
/lib
}/systemd
/system
/"$base@"*.
"$suffix".
{wants
,requires
}
26 systemctl daemon-reload
30 local SERVICE_NAME
="${1:?}"
31 clear_units
"${SERVICE_NAME}".service
33 cat >/etc
/systemd
/system
/"$SERVICE_NAME".service
<<EOF
35 Description=$SERVICE_NAME unit
38 ExecStart=sleep 100000
40 mkdir
-p /{etc
,run
,usr
/lib
}/systemd
/system
/"$SERVICE_NAME".service.
{d
,wants
,requires
}
50 x
="$(systemctl show --value -p "${2:?}" "${1:?}")"
61 test_basic_dropins
() {
62 echo "Testing basic dropins..."
64 echo "*** test a wants b wants c"
65 create_services test15-a test15-b test15-c
66 ln -s ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.wants
/
67 ln -s ..
/test15-c.service
/etc
/systemd
/system
/test15-b.service.wants
/
68 check_ok test15-a Wants test15-b.service
69 check_ok test15-b Wants test15-c.service
71 echo "*** test a wants,requires b"
72 create_services test15-a test15-b test15-c
73 ln -s ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.wants
/
74 ln -s ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.requires
/
75 check_ok test15-a Wants test15-b.service
76 check_ok test15-a Requires test15-b.service
78 echo "*** test a wants nonexistent"
79 create_service test15-a
80 ln -s ..
/nonexistent.service
/etc
/systemd
/system
/test15-a.service.wants
/
81 check_ok test15-a Wants nonexistent.service
82 systemctl start test15-a
83 systemctl stop test15-a
85 echo "*** test a requires nonexistent"
86 ln -sf ..
/nonexistent.service
/etc
/systemd
/system
/test15-a.service.requires
/
87 systemctl daemon-reload
88 check_ok test15-a Requires nonexistent.service
90 # 'b' is already loaded when 'c' pulls it in via a dropin.
91 echo "*** test a,c require b"
92 create_services test15-a test15-b test15-c
93 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.requires
/
94 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-c.service.requires
/
95 systemctl start test15-a
96 check_ok test15-c Requires test15-b.service
97 systemctl stop test15-a test15-b
99 # 'b' is already loaded when 'c' pulls it in via an alias dropin.
100 echo "*** test a wants alias"
101 create_services test15-a test15-b test15-c
102 ln -sf test15-c.service
/etc
/systemd
/system
/test15-c1.service
103 ln -sf ..
/test15-c.service
/etc
/systemd
/system
/test15-a.service.wants
/
104 ln -sf ..
/test15-c1.service
/etc
/systemd
/system
/test15-b.service.wants
/
105 systemctl start test15-a
106 check_ok test15-a Wants test15-c.service
107 check_ok test15-b Wants test15-c.service
108 systemctl stop test15-a test15-c
110 echo "*** test service.d/ top level drop-in"
111 create_services test15-a test15-b
112 check_ko test15-a ExecCondition
"/bin/echo a"
113 check_ko test15-b ExecCondition
"/bin/echo b"
114 mkdir
-p /usr
/lib
/systemd
/system
/service.d
115 cat >/usr
/lib
/systemd
/system
/service.d
/override.conf
<<EOF
117 ExecCondition=/bin/echo %n
119 systemctl daemon-reload
120 check_ok test15-a ExecCondition
"/bin/echo test15-a"
121 check_ok test15-b ExecCondition
"/bin/echo test15-b"
122 rm -rf /usr
/lib
/systemd
/system
/service.d
124 clear_units test15-
{a
,b
,c
,c1
}.service
127 test_linked_units
() {
128 echo "Testing linked units..."
129 echo "*** test linked unit (same basename)"
131 create_service test15-a
132 mv /etc
/systemd
/system
/test15-a.service
/
133 ln -s /test15-a.service
/etc
/systemd
/system
/
134 ln -s test15-a.service
/etc
/systemd
/system
/test15-b.service
136 check_ok test15-a Names test15-a.service
137 check_ok test15-a Names test15-b.service
139 echo "*** test linked unit (cross basename)"
141 mv /test15-a.service
/test15-a@.scope
142 ln -fs /test15-a@.scope
/etc
/systemd
/system
/test15-a.service
143 systemctl daemon-reload
145 check_ok test15-a Names test15-a.service
146 check_ok test15-a Names test15-b.service
147 check_ko test15-a Names test15-a@
# test15-a@.scope is the symlink target.
148 # Make sure it is completely ignored.
151 clear_units test15-
{a
,b
}.service
154 test_template_alias
() {
155 echo "Testing instance alias..."
158 create_service test15-a@
159 ln -s test15-a@inst.service
/etc
/systemd
/system
/test15-b@inst.service
# alias
161 check_ok test15-a@inst Names test15-a@inst.service
162 check_ok test15-a@inst Names test15-b@inst.service
164 check_ok test15-a@other Names test15-a@other.service
165 check_ko test15-a@other Names test15-b@other.service
169 systemctl daemon-reload
171 check_ok test15-b@inst Names test15-a@inst.service
172 check_ok test15-b@inst Names test15-b@inst.service
174 check_ko test15-b@other Names test15-a@other.service
175 check_ok test15-b@other Names test15-b@other.service
177 clear_units test15-
{a
,b
}@.service
180 test_hierarchical_service_dropins
() {
181 echo "Testing hierarchical service dropins..."
182 echo "*** test service.d/ top level drop-in"
183 create_services a-b-c
184 check_ko a-b-c ExecCondition
"echo service.d"
185 check_ko a-b-c ExecCondition
"echo a-.service.d"
186 check_ko a-b-c ExecCondition
"echo a-b-.service.d"
187 check_ko a-b-c ExecCondition
"echo a-b-c.service.d"
189 for dropin
in service.d a-.service.d a-b-.service.d a-b-c.service.d
; do
190 mkdir
-p /usr
/lib
/systemd
/system
/$dropin
193 ExecCondition=echo $dropin
194 " >/usr
/lib
/systemd
/system
/$dropin/override.conf
195 systemctl daemon-reload
196 check_ok a-b-c ExecCondition
"echo $dropin"
198 # Check that we can start a transient service in presence of the drop-ins
199 systemd-run
-u a-b-c2.service
-p Description
='sleepy' sleep infinity
201 # The transient setting replaces the default
202 check_ok a-b-c2.service Description
"sleepy"
204 # The override takes precedence for ExecCondition
205 # (except the last iteration when it only applies to the other service)
206 if [ "$dropin" != "a-b-c.service.d" ]; then
207 check_ok a-b-c2.service ExecCondition
"echo $dropin"
210 # Check that things are the same after a reload
211 systemctl daemon-reload
212 check_ok a-b-c2.service Description
"sleepy"
213 if [ "$dropin" != "a-b-c.service.d" ]; then
214 check_ok a-b-c2.service ExecCondition
"echo $dropin"
217 systemctl stop a-b-c2.service
219 for dropin
in service.d a-.service.d a-b-.service.d a-b-c.service.d
; do
220 rm -rf /usr
/lib
/systemd
/system
/$dropin
223 clear_units a-b-c.service
226 test_hierarchical_slice_dropins
() {
227 echo "Testing hierarchical slice dropins..."
228 echo "*** test slice.d/ top level drop-in"
229 # Slice units don't even need a fragment, so we test the defaults here
230 check_ok a-b-c.slice Description
"Slice /a/b/c"
231 check_ok a-b-c.slice MemoryMax
"infinity"
234 for dropin
in slice.d a-.slice.d a-b-.slice.d a-b-c.slice.d
; do
235 mkdir
-p /usr
/lib
/systemd
/system
/$dropin
239 " >/usr
/lib
/systemd
/system
/$dropin/override.conf
240 systemctl daemon-reload
241 check_ok a-b-c.slice MemoryMax
"1000000000"
244 org.freedesktop.systemd1 \
245 /org
/freedesktop
/systemd1 \
246 org.freedesktop.systemd1.Manager \
247 StartTransientUnit
'ssa(sv)a(sa(sv))' \
248 'a-b-c.slice' 'replace' \
250 'Description' s
'slice too' \
251 'MemoryMax' t
1000000002 \
254 # The override takes precedence for MemoryMax
255 check_ok a-b-c.slice MemoryMax
"1000000000"
256 # The transient setting replaces the default
257 check_ok a-b-c.slice Description
"slice too"
259 # Check that things are the same after a reload
260 systemctl daemon-reload
261 check_ok a-b-c.slice MemoryMax
"1000000000"
262 check_ok a-b-c.slice Description
"slice too"
265 org.freedesktop.systemd1 \
266 /org
/freedesktop
/systemd1 \
267 org.freedesktop.systemd1.Manager \
269 'a-b-c.slice' 'replace'
271 rm /usr
/lib
/systemd
/system
/$dropin/override.conf
274 # Test unit with a fragment
278 " >/usr
/lib
/systemd
/system
/a-b-c.slice
279 systemctl daemon-reload
280 check_ok a-b-c.slice MemoryMax
"1000000001"
282 clear_units a-b-c.slice
285 test_transient_service_dropins
() {
286 echo "Testing dropins for a transient service..."
287 echo "*** test transient service drop-ins"
289 mkdir
-p /etc
/systemd
/system
/service.d
290 mkdir
-p /etc
/systemd
/system
/a-.service.d
291 mkdir
-p /etc
/systemd
/system
/a-b-.service.d
292 mkdir
-p /etc
/systemd
/system
/a-b-c.service.d
294 echo -e '[Service]\nStandardInputText=aaa' >/etc
/systemd
/system
/service.d
/drop1.conf
295 echo -e '[Service]\nStandardInputText=bbb' >/etc
/systemd
/system
/a-.service.d
/drop2.conf
296 echo -e '[Service]\nStandardInputText=ccc' >/etc
/systemd
/system
/a-b-.service.d
/drop3.conf
297 echo -e '[Service]\nStandardInputText=ddd' >/etc
/systemd
/system
/a-b-c.service.d
/drop4.conf
299 # There's no fragment yet, so this fails
300 systemctl
cat a-b-c.service
&& exit 1
303 systemd-run
-u a-b-c.service
-p StandardInputData
=eHh4Cg
== sleep infinity
305 data
=$
(systemctl show
-P StandardInputData a-b-c.service
)
306 # xxx\naaa\n\bbb\nccc\nddd\n → eHh4…
307 test "$data" = "eHh4CmFhYQpiYmIKY2NjCmRkZAo="
309 # Do a reload and check again
310 systemctl daemon-reload
311 data
=$
(systemctl show
-P StandardInputData a-b-c.service
)
312 test "$data" = "eHh4CmFhYQpiYmIKY2NjCmRkZAo="
314 clear_units a-b-c.service
315 rm /etc
/systemd
/system
/service.d
/drop1.conf \
316 /etc
/systemd
/system
/a-.service.d
/drop2.conf \
317 /etc
/systemd
/system
/a-b-.service.d
/drop3.conf
320 test_template_dropins
() {
321 echo "Testing template dropins..."
323 create_services foo bar@ yup@
325 # Declare some deps to check if the body was loaded
326 cat >>/etc
/systemd
/system
/bar@.service
<<EOF
328 After=bar-template-after.device
331 cat >>/etc
/systemd
/system
/yup@.service
<<EOF
333 After=yup-template-after.device
336 ln -s /etc
/systemd
/system
/bar@.service
/etc
/systemd
/system
/foo.service.wants
/bar@
1.service
337 check_ok foo Wants bar@
1.service
339 echo "*** test bar-alias@.service→bar@.service, but instance symlinks point to yup@.service ***"
340 ln -s bar@.service
/etc
/systemd
/system
/bar-alias@.service
341 ln -s bar@
1.service
/etc
/systemd
/system
/bar-alias@
1.service
342 ln -s yup@.service
/etc
/systemd
/system
/bar-alias@
2.service
343 ln -s yup@
3.service
/etc
/systemd
/system
/bar-alias@
3.service
345 # create some dropin deps
346 mkdir
-p /etc
/systemd
/system
/bar@
{,0,1,2,3}.service.requires
/
347 mkdir
-p /etc
/systemd
/system
/yup@
{,0,1,2,3}.service.requires
/
348 mkdir
-p /etc
/systemd
/system
/bar-alias@
{,0,1,2,3}.service.requires
/
350 ln -s ..
/bar-template-requires.device
/etc
/systemd
/system
/bar@.service.requires
/
351 ln -s ..
/bar-0-requires.device
/etc
/systemd
/system
/bar@
0.service.requires
/
352 ln -s ..
/bar-1-requires.device
/etc
/systemd
/system
/bar@
1.service.requires
/
353 ln -s ..
/bar-2-requires.device
/etc
/systemd
/system
/bar@
2.service.requires
/
354 ln -s ..
/bar-3-requires.device
/etc
/systemd
/system
/bar@
3.service.requires
/
356 ln -s ..
/yup-template-requires.device
/etc
/systemd
/system
/yup@.service.requires
/
357 ln -s ..
/yup-0-requires.device
/etc
/systemd
/system
/yup@
0.service.requires
/
358 ln -s ..
/yup-1-requires.device
/etc
/systemd
/system
/yup@
1.service.requires
/
359 ln -s ..
/yup-2-requires.device
/etc
/systemd
/system
/yup@
2.service.requires
/
360 ln -s ..
/yup-3-requires.device
/etc
/systemd
/system
/yup@
3.service.requires
/
362 ln -s ..
/bar-alias-template-requires.device
/etc
/systemd
/system
/bar-alias@.service.requires
/
363 ln -s ..
/bar-alias-0-requires.device
/etc
/systemd
/system
/bar-alias@
0.service.requires
/
364 ln -s ..
/bar-alias-1-requires.device
/etc
/systemd
/system
/bar-alias@
1.service.requires
/
365 ln -s ..
/bar-alias-2-requires.device
/etc
/systemd
/system
/bar-alias@
2.service.requires
/
366 ln -s ..
/bar-alias-3-requires.device
/etc
/systemd
/system
/bar-alias@
3.service.requires
/
368 systemctl daemon-reload
370 echo '*** bar@0 is aliased by bar-alias@0 ***'
371 systemctl show
-p Names
,Requires bar@
0
372 systemctl show
-p Names
,Requires bar-alias@
0
373 check_ok bar@
0 Names bar@
0
374 check_ok bar@
0 Names bar-alias@
0
376 check_ok bar@
0 After bar-template-after.device
378 check_ok bar@
0 Requires bar-0-requires.device
379 check_ok bar@
0 Requires bar-alias-0-requires.device
380 check_ok bar@
0 Requires bar-template-requires.device
381 check_ok bar@
0 Requires bar-alias-template-requires.device
382 check_ko bar@
0 Requires yup-template-requires.device
384 check_ok bar-alias@
0 After bar-template-after.device
386 check_ok bar-alias@
0 Requires bar-0-requires.device
387 check_ok bar-alias@
0 Requires bar-alias-0-requires.device
388 check_ok bar-alias@
0 Requires bar-template-requires.device
389 check_ok bar-alias@
0 Requires bar-alias-template-requires.device
390 check_ko bar-alias@
0 Requires yup-template-requires.device
391 check_ko bar-alias@
0 Requires yup-0-requires.device
393 echo '*** bar@1 is aliased by bar-alias@1 ***'
394 systemctl show
-p Names
,Requires bar@
1
395 systemctl show
-p Names
,Requires bar-alias@
1
396 check_ok bar@
1 Names bar@
1
397 check_ok bar@
1 Names bar-alias@
1
399 check_ok bar@
1 After bar-template-after.device
401 check_ok bar@
1 Requires bar-1-requires.device
402 check_ok bar@
1 Requires bar-alias-1-requires.device
403 check_ok bar@
1 Requires bar-template-requires.device
404 # See https://github.com/systemd/systemd/pull/13119#discussion_r308145418
405 check_ok bar@
1 Requires bar-alias-template-requires.device
406 check_ko bar@
1 Requires yup-template-requires.device
407 check_ko bar@
1 Requires yup-1-requires.device
409 check_ok bar-alias@
1 After bar-template-after.device
411 check_ok bar-alias@
1 Requires bar-1-requires.device
412 check_ok bar-alias@
1 Requires bar-alias-1-requires.device
413 check_ok bar-alias@
1 Requires bar-template-requires.device
414 check_ok bar-alias@
1 Requires bar-alias-template-requires.device
415 check_ko bar-alias@
1 Requires yup-template-requires.device
416 check_ko bar-alias@
1 Requires yup-1-requires.device
418 echo '*** bar-alias@2 aliases yup@2, bar@2 is independent ***'
419 systemctl show
-p Names
,Requires bar@
2
420 systemctl show
-p Names
,Requires bar-alias@
2
421 check_ok bar@
2 Names bar@
2
422 check_ko bar@
2 Names bar-alias@
2
424 check_ok bar@
2 After bar-template-after.device
426 check_ok bar@
2 Requires bar-2-requires.device
427 check_ko bar@
2 Requires bar-alias-2-requires.device
428 check_ok bar@
2 Requires bar-template-requires.device
429 check_ko bar@
2 Requires bar-alias-template-requires.device
430 check_ko bar@
2 Requires yup-template-requires.device
431 check_ko bar@
2 Requires yup-2-requires.device
433 check_ko bar-alias@
2 After bar-template-after.device
435 check_ko bar-alias@
2 Requires bar-2-requires.device
436 check_ok bar-alias@
2 Requires bar-alias-2-requires.device
437 check_ko bar-alias@
2 Requires bar-template-requires.device
438 check_ok bar-alias@
2 Requires bar-alias-template-requires.device
439 check_ok bar-alias@
2 Requires yup-template-requires.device
440 check_ok bar-alias@
2 Requires yup-2-requires.device
442 echo '*** bar-alias@3 aliases yup@3, bar@3 is independent ***'
443 systemctl show
-p Names
,Requires bar@
3
444 systemctl show
-p Names
,Requires bar-alias@
3
445 check_ok bar@
3 Names bar@
3
446 check_ko bar@
3 Names bar-alias@
3
448 check_ok bar@
3 After bar-template-after.device
450 check_ok bar@
3 Requires bar-3-requires.device
451 check_ko bar@
3 Requires bar-alias-3-requires.device
452 check_ok bar@
3 Requires bar-template-requires.device
453 check_ko bar@
3 Requires bar-alias-template-requires.device
454 check_ko bar@
3 Requires yup-template-requires.device
455 check_ko bar@
3 Requires yup-3-requires.device
457 check_ko bar-alias@
3 After bar-template-after.device
459 check_ko bar-alias@
3 Requires bar-3-requires.device
460 check_ok bar-alias@
3 Requires bar-alias-3-requires.device
461 check_ko bar-alias@
3 Requires bar-template-requires.device
462 check_ok bar-alias@
3 Requires bar-alias-template-requires.device
463 check_ok bar-alias@
3 Requires yup-template-requires.device
464 check_ok bar-alias@
3 Requires yup-3-requires.device
466 clear_units foo.service
{bar
,yup
,bar-alias
}@
{,1,2,3}.service
469 test_alias_dropins
() {
470 echo "Testing alias dropins..."
472 echo "*** test a wants b1 alias of b"
473 create_services test15-a test15-b
474 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b1.service
475 ln -sf ..
/test15-b1.service
/etc
/systemd
/system
/test15-a.service.wants
/
476 check_ok test15-a Wants test15-b.service
477 systemctl start test15-a
478 systemctl
--quiet is-active test15-b
479 systemctl stop test15-a test15-b
480 rm /etc
/systemd
/system
/test15-b1.service
481 clear_units test15-
{a
,b
}.service
483 # Check that dependencies don't vary.
485 create_services test15-a test15-x test15-y
486 mkdir
-p /etc
/systemd
/system
/test15-a1.service.wants
/
487 ln -sf test15-a.service
/etc
/systemd
/system
/test15-a1.service
488 ln -sf ..
/test15-x.service
/etc
/systemd
/system
/test15-a.service.wants
/
489 ln -sf ..
/test15-y.service
/etc
/systemd
/system
/test15-a1.service.wants
/
490 check_ok test15-a1 Wants test15-x.service
# see [1]
491 check_ok test15-a1 Wants test15-y.service
492 systemctl start test15-a
493 check_ok test15-a1 Wants test15-x.service
# see [2]
494 check_ok test15-a1 Wants test15-y.service
495 systemctl stop test15-a test15-x test15-y
496 rm /etc
/systemd
/system
/test15-a1.service
498 clear_units test15-
{a
,x
,y
}.service
501 test_masked_dropins
() {
502 echo "Testing masked dropins..."
504 create_services test15-a test15-b
506 # 'b' is masked for both deps
507 echo "*** test a wants,requires b is masked"
508 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.wants
/test15-b.service
509 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.requires
/test15-b.service
510 check_ko test15-a Wants test15-b.service
511 check_ko test15-a Requires test15-b.service
513 # 'a' wants 'b' and 'b' is masked at a lower level
514 echo "*** test a wants b, mask override"
515 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.wants
/test15-b.service
516 ln -sf /dev
/null
/usr
/lib
/systemd
/system
/test15-a.service.wants
/test15-b.service
517 check_ok test15-a Wants test15-b.service
519 # 'a' wants 'b' and 'b' is masked at a higher level
520 echo "*** test a wants b, mask"
521 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.wants
/test15-b.service
522 ln -sf ..
/test15-b.service
/usr
/lib
/systemd
/system
/test15-a.service.wants
/test15-b.service
523 check_ko test15-a Wants test15-b.service
525 # 'a' is masked but has an override config file
526 echo "*** test a is masked but has an override"
527 create_services test15-a test15-b
528 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service
529 cat >/usr
/lib
/systemd
/system
/test15-a.service.d
/override.conf
<<EOF
531 After=test15-b.service
533 check_ok test15-a UnitFileState masked
535 # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep
536 echo "*** test a wants b, b1, and one is masked"
537 create_services test15-a test15-b
538 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b1.service
539 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.wants
/test15-b.service
540 ln -sf ..
/test15-b1.service
/usr
/lib
/systemd
/system
/test15-a.service.wants
/test15-b1.service
541 systemctl
cat test15-a
542 systemctl show
-p Wants
,Requires test15-a
543 systemctl
cat test15-b1
544 systemctl show
-p Wants
,Requires test15-b1
545 check_ok test15-a Wants test15-b.service
546 check_ko test15-a Wants test15-b1.service
# the alias does not show up in the list of units
547 rm /etc
/systemd
/system
/test15-b1.service
549 # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep
550 echo "*** test a wants b, alias dep is masked"
551 create_services test15-a test15-b
552 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b1.service
553 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.wants
/test15-b1.service
554 ln -sf ..
/test15-b.service
/usr
/lib
/systemd
/system
/test15-a.service.wants
/test15-b.service
555 check_ok test15-a Wants test15-b.service
556 check_ko test15-a Wants test15-b1.service
# the alias does not show up in the list of units
557 rm /etc
/systemd
/system
/test15-b1.service
559 # 'a' has Wants=b.service but also has a masking
560 # dropin 'b': 'b' should still be pulled in.
561 echo "*** test a wants b both ways"
562 create_services test15-a test15-b
563 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.wants
/test15-b.service
564 cat >/usr
/lib
/systemd
/system
/test15-a.service.d
/wants-b.conf
<<EOF
566 Wants=test15-b.service
568 check_ok test15-a Wants test15-b.service
570 # mask a dropin that points to an nonexistent unit.
571 echo "*** test a wants nonexistent is masked"
572 create_services test15-a
573 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.requires
/nonexistent.service
574 ln -sf ..
/nonexistent.service
/usr
/lib
/systemd
/system
/test15-a.service.requires
/
575 check_ko test15-a Requires nonexistent.service
577 # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
578 # masked at a higher level.
579 echo "*** test a wants b is masked"
580 create_services test15-a test15-b test15-c
581 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.requires
/
582 ln -sf ..
/test15-b.service
/run
/systemd
/system
/test15-c.service.requires
/
583 ln -sf /dev
/null
/etc
/systemd
/system
/test15-c.service.requires
/test15-b.service
584 systemctl start test15-a
585 check_ko test15-c Requires test15-b.service
586 systemctl stop test15-a test15-b
588 # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
589 # masked at a lower level.
590 echo "*** test a requires b is masked"
591 create_services test15-a test15-b test15-c
592 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-a.service.requires
/
593 ln -sf ..
/test15-b.service
/etc
/systemd
/system
/test15-c.service.requires
/
594 ln -sf /dev
/null
/run
/systemd
/system
/test15-c.service.requires
/test15-b.service
595 systemctl start test15-a
596 check_ok test15-c Requires test15-b.service
597 systemctl stop test15-a test15-b
599 # 'a' requires 2 aliases of 'b' and one of them is a mask.
600 echo "*** test a requires alias of b, other alias masked"
601 create_services test15-a test15-b
602 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b1.service
603 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b2.service
604 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.requires
/test15-b1.service
605 ln -sf ..
/test15-b1.service
/run
/systemd
/system
/test15-a.service.requires
/
606 ln -sf ..
/test15-b2.service
/usr
/lib
/systemd
/system
/test15-a.service.requires
/
607 check_ok test15-a Requires test15-b
609 # Same as above but now 'b' is masked.
610 echo "*** test a requires alias of b, b dep masked"
611 create_services test15-a test15-b
612 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b1.service
613 ln -sf test15-b.service
/etc
/systemd
/system
/test15-b2.service
614 ln -sf ..
/test15-b1.service
/run
/systemd
/system
/test15-a.service.requires
/
615 ln -sf ..
/test15-b2.service
/usr
/lib
/systemd
/system
/test15-a.service.requires
/
616 ln -sf /dev
/null
/etc
/systemd
/system
/test15-a.service.requires
/test15-b.service
617 check_ok test15-a Requires test15-b
619 clear_units test15-
{a
,b
}.service
622 test_invalid_dropins
() {
623 echo "Testing invalid dropins..."
624 # Assertion failed on earlier versions, command exits unsuccessfully on later versions
625 systemctl
cat nonexistent@.service || true
627 systemctl daemon-reload
628 # Assertion failed on earlier versions, command exits unsuccessfully on later versions
629 systemctl
cat a@.service || true
631 clear_units a.service
635 test_symlink_dropin_directory
() {
637 echo "Testing symlink drop-in directory..."
638 create_services test15-a
639 rmdir /{etc
,run
,usr
/lib
}/systemd
/system
/test15-a.service.d
640 mkdir
-p /tmp
/testsuite-15-test15-a-dropin-directory
641 ln -s /tmp
/testsuite-15-test15-a-dropin-directory
/etc
/systemd
/system
/test15-a.service.d
642 cat >/tmp
/testsuite-15-test15-a-dropin-directory
/override.conf
<<EOF
646 ln -s /tmp
/testsuite-15-test15-a-dropin-directory-nonexistent
/run
/systemd
/system
/test15-a.service.d
647 touch /tmp
/testsuite-15-test15-a-dropin-directory-regular
648 ln -s /tmp
/testsuite-15-test15-a-dropin-directory-regular
/usr
/lib
/systemd
/system
/test15-a.service.d
649 check_ok test15-a Description hogehoge
651 clear_units test15-a.service
657 test_hierarchical_service_dropins
658 test_hierarchical_slice_dropins
659 test_transient_service_dropins
660 test_template_dropins
664 test_symlink_dropin_directory