hwdb: fix screen rotation for EXO Wings 2in1 w1125 (#36283)
[systemd.io.git] / test / units / TEST-23-UNIT-FILE.statedir.sh
blobcc30f0a27df36c4ecaa33ac196370d35a649627c
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 # shellcheck disable=SC2235
4 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
5 # ex: ts=8 sw=4 sts=4 et filetype=sh
6 set -eux
7 set -o pipefail
9 # Test unit configuration/state/cache/log/runtime data cleanup
11 export HOME=/root
12 export XDG_RUNTIME_DIR=/run/user/0
14 systemctl start user@0.service
16 ( ! test -d "$HOME"/.local/state/foo)
17 ( ! test -d "$HOME"/.config/foo)
19 systemd-run --user -p StateDirectory=foo --wait /bin/true
21 test -d "$HOME"/.local/state/foo
22 ( ! test -L "$HOME"/.local/state/foo)
23 ( ! test -d "$HOME"/.config/foo)
25 systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
27 test -d "$HOME"/.local/state/foo
28 ( ! test -L "$HOME"/.local/state/foo)
29 test -d "$HOME"/.config/foo
31 rmdir "$HOME"/.local/state/foo "$HOME"/.config/foo
33 systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
35 test -d "$HOME"/.local/state/foo
36 ( ! test -L "$HOME"/.local/state/foo)
37 test -d "$HOME"/.config/foo
39 rmdir "$HOME"/.local/state/foo "$HOME"/.config/foo
41 # Now trigger an update scenario by creating a config dir first
42 systemd-run --user -p ConfigurationDirectory=foo --wait /bin/true
44 ( ! test -d "$HOME"/.local/state/foo)
45 test -d "$HOME"/.config/foo
47 # This will look like an update and result in a symlink
48 systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
50 test -d "$HOME"/.local/state/foo
51 test -L "$HOME"/.local/state/foo
52 test -d "$HOME"/.config/foo
54 test "$(readlink "$HOME"/.local/state/foo)" = ../../.config/foo
56 # Check that this will work safely a second time
57 systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
59 ( ! systemd-run --user -p StateDirectory=foo::ro --wait sh -c "echo foo > $HOME/.local/state/foo/baz")
60 ( ! systemd-run --user -p StateDirectory=foo:bar:ro --wait sh -c "echo foo > $HOME/.local/state/foo/baz")
61 ( ! test -f "$HOME"/.local/state/foo/baz)
62 test -L "$HOME"/.local/state/bar
64 rm "$HOME"/.local/state/foo
65 rmdir "$HOME"/.config/foo