]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/units/testsuite-46.sh
Merge pull request #21517 from yuwata/network-long-hw-addr
[thirdparty/systemd.git] / test / units / testsuite-46.sh
CommitLineData
ff12a795 1#!/usr/bin/env bash
7b3cec95 2# SPDX-License-Identifier: LGPL-2.1-or-later
084575ff 3set -eux
6ead3917
LP
4set -o pipefail
5
6# Check if homectl is installed, and if it isn't bail out early instead of failing
7if ! test -x /usr/bin/homectl ; then
0ee99483 8 echo OK >/testok
6ead3917
LP
9 exit 0
10fi
11
12inspect() {
68bb821e
ZJS
13 # As updating disk-size-related attributes can take some time on some
14 # filesystems, let's drop these fields before comparing the outputs to
15 # avoid unexpected fails. To see the full outputs of both homectl &
16 # userdbctl (for debugging purposes) drop the fields just before the
17 # comparison.
38825267
FS
18 local USERNAME="${1:?missing argument}"
19 homectl inspect "$USERNAME" | tee /tmp/a
20 userdbctl user "$USERNAME" | tee /tmp/b
68bb821e 21
12852528
FS
22 # diff uses the grep BREs for pattern matching
23 diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp/{a,b}
68bb821e 24 rm /tmp/{a,b}
6ead3917
LP
25}
26
27systemd-analyze log-level debug
28systemd-analyze log-target console
c42234ab 29systemctl service-log-level systemd-homed debug
6ead3917 30
41caad6f
LP
31# Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely.
32mkdir -p /home-pool
33mount -t tmpfs tmpfs /home-pool -o size=290M
34
30548633 35# we enable --luks-discard= since we run our tests in a tight VM, hence don't
41caad6f
LP
36# needlessly pressure for storage. We also set the cheapest KDF, since we don't
37# want to waste CI CPU cycles on it.
38NEWPASSWORD=xEhErW0ndafV4s homectl create test-user \
75f6ae06 39 --disk-size=min \
41caad6f
LP
40 --luks-discard=yes \
41 --image-path=/home-pool/test-user.home \
42 --luks-pbkdf-type=pbkdf2 \
43 --luks-pbkdf-time-cost=1ms
6ead3917
LP
44inspect test-user
45
46PASSWORD=xEhErW0ndafV4s homectl authenticate test-user
47
48PASSWORD=xEhErW0ndafV4s homectl activate test-user
49inspect test-user
50
51PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Inline test"
52inspect test-user
53
54homectl deactivate test-user
55inspect test-user
56
57PASSWORD=xEhErW0ndafV4s NEWPASSWORD=yPN4N0fYNKUkOq homectl passwd test-user
58inspect test-user
59
60PASSWORD=yPN4N0fYNKUkOq homectl activate test-user
61inspect test-user
62
63SYSTEMD_LOG_LEVEL=debug PASSWORD=yPN4N0fYNKUkOq NEWPASSWORD=xEhErW0ndafV4s homectl passwd test-user
64inspect test-user
65
66homectl deactivate test-user
67inspect test-user
68
69PASSWORD=xEhErW0ndafV4s homectl activate test-user
70inspect test-user
71
993b9057 72homectl deactivate test-user
6ead3917
LP
73inspect test-user
74
75PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Offline test"
76inspect test-user
77
78PASSWORD=xEhErW0ndafV4s homectl activate test-user
79inspect test-user
80
993b9057 81homectl deactivate test-user
6ead3917
LP
82inspect test-user
83
a89b6750
LP
84# Do some resize tests, but only if we run on real kernels, as quota inside of containers will fail
85if ! systemd-detect-virt -cq ; then
86 # grow while inactive
87 PASSWORD=xEhErW0ndafV4s homectl resize test-user 300M
88 inspect test-user
89
90 # minimize while inactive
9f5827e0 91 PASSWORD=xEhErW0ndafV4s homectl resize test-user min
a89b6750
LP
92 inspect test-user
93
94 PASSWORD=xEhErW0ndafV4s homectl activate test-user
95 inspect test-user
96
97 # grow while active
9f5827e0 98 PASSWORD=xEhErW0ndafV4s homectl resize test-user max
a89b6750
LP
99 inspect test-user
100
101 # minimize while active
102 PASSWORD=xEhErW0ndafV4s homectl resize test-user 0
103 inspect test-user
104
105 # grow while active
106 PASSWORD=xEhErW0ndafV4s homectl resize test-user 300M
107 inspect test-user
108
109 # shrink to original size while active
110 PASSWORD=xEhErW0ndafV4s homectl resize test-user 256M
111 inspect test-user
112
993b9057 113 homectl deactivate test-user
a89b6750
LP
114 inspect test-user
115fi
116
b9bfa250
ZJS
117PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
118PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
119 && { echo 'unexpected success'; exit 1; }
6ead3917
LP
120PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz
121PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
122PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
b9bfa250
ZJS
123PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
124PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
125 && { echo 'unexpected success'; exit 1; }
6ead3917
LP
126
127homectl remove test-user
128
129systemd-analyze log-level info
130
0ee99483 131echo OK >/testok
6ead3917
LP
132
133exit 0