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