]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/units/testsuite-48.sh
Merge pull request #18701 from bugaevc/mdns-unicast
[thirdparty/systemd.git] / test / units / testsuite-48.sh
CommitLineData
d904afc7
LB
1#!/usr/bin/env bash
2# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3# ex: ts=8 sw=4 sts=4 et filetype=sh
4set -ex
5
0ee99483 6cat >/run/systemd/system/testservice-48.target <<EOF
d904afc7
LB
7[Unit]
8Wants=testservice-48.service
9EOF
10
11systemctl daemon-reload
12
13systemctl start testservice-48.target
14
15# The filesystem on the test image, despite being ext4, seems to have a mtime
16# granularity of one second, which means the manager's unit cache won't be
17# marked as dirty when writing the unit file, unless we wait at least a full
18# second after the previous daemon-reload.
19# May 07 23:12:20 systemd-testsuite testsuite-48.sh[30]: + cat
20# May 07 23:12:20 systemd-testsuite testsuite-48.sh[30]: + ls -l --full-time /etc/systemd/system/testservice-48.service
21# May 07 23:12:20 systemd-testsuite testsuite-48.sh[52]: -rw-r--r-- 1 root root 50 2020-05-07 23:12:20.000000000 +0100 /
22# May 07 23:12:20 systemd-testsuite testsuite-48.sh[30]: + stat -f --format=%t /etc/systemd/system/testservice-48.servic
23# May 07 23:12:20 systemd-testsuite testsuite-48.sh[53]: ef53
7233e91a 24sleep 3.1
d904afc7 25
0ee99483 26cat >/run/systemd/system/testservice-48.service <<EOF
d904afc7
LB
27[Service]
28ExecStart=/bin/sleep infinity
d904afc7
LB
29EOF
30
31systemctl start testservice-48.service
32
33systemctl is-active testservice-48.service
34
7233e91a
LB
35# Stop and remove, and try again to exercise https://github.com/systemd/systemd/issues/15992
36systemctl stop testservice-48.service
37rm -f /run/systemd/system/testservice-48.service
38systemctl daemon-reload
39
40sleep 3.1
41
0ee99483 42cat >/run/systemd/system/testservice-48.service <<EOF
7233e91a
LB
43[Service]
44ExecStart=/bin/sleep infinity
45EOF
46
47# Start a non-existing unit first, so that the cache is reloaded for an unrelated
48# reason. Starting the existing unit later should still work thanks to the check
49# for the last load attempt vs cache timestamp.
50systemctl start testservice-48-nonexistent.service || true
51
52systemctl start testservice-48.service
53
54systemctl is-active testservice-48.service
55
cda66772
LB
56# Stop and remove, and try again to exercise the transaction setup code path by
57# having the target pull in the unloaded but available unit
58systemctl stop testservice-48.service testservice-48.target
59rm -f /run/systemd/system/testservice-48.service /run/systemd/system/testservice-48.target
60systemctl daemon-reload
61
62sleep 3.1
63
0ee99483 64cat >/run/systemd/system/testservice-48.target <<EOF
cda66772
LB
65[Unit]
66Conflicts=shutdown.target
67Wants=testservice-48.service
68EOF
69
70systemctl daemon-reload
71
72systemctl start testservice-48.target
73
0ee99483 74cat >/run/systemd/system/testservice-48.service <<EOF
cda66772
LB
75[Service]
76ExecStart=/bin/sleep infinity
77EOF
78
79systemctl restart testservice-48.target
80
81systemctl is-active testservice-48.service
82
0ee99483 83echo OK >/testok
d904afc7
LB
84
85exit 0