File: TEST-17-UDEV.diskseq.sh

package info (click to toggle)
systemd 259-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 105,132 kB
  • sloc: ansic: 726,480; xml: 121,118; python: 36,740; sh: 35,016; cpp: 946; makefile: 273; awk: 102; lisp: 13; sed: 1
file content (71 lines) | stat: -rwxr-xr-x 1,582 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# shellcheck disable=SC2010
# shellcheck disable=SC2012
# shellcheck disable=SC2317
set -ex
set -o pipefail

# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh

# This is a test case for issue #34637.

at_exit() (
    set +e

    systemctl stop test-diskseq.service || :
    rm -f /run/systemd/system/test-diskseq.service
    systemctl daemon-reload

    [[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR"

    udevadm control --log-level=info
)

trap at_exit EXIT

udevadm control --log-level=debug

TMPDIR="$(mktemp -d)"
truncate -s 16M "$TMPDIR"/foo.raw
mkfs.ext4 -L foo "$TMPDIR"/foo.raw

mkdir -p /run/systemd/system/
cat >/run/systemd/system/test-diskseq.service <<EOF
[Unit]
StartLimitIntervalSec=0
[Service]
ExecStart=false
Restart=on-failure
MountImages=$TMPDIR/foo.raw:/var
EOF
systemctl daemon-reload

udevadm settle --timeout=30

# Check if no lock file exists, if the lock directory exists.
if [[ -d /run/udev/links.lock/ ]]; then
    [[ "$(ls /run/udev/links.lock/ | wc -l)" == 0 ]]
fi

# Save the current number of the directories.
NUM_DISKSEQ=$(ls /run/udev/links/ | grep -c by-diskseq || :)

systemctl start --no-block test-diskseq.service

for _ in {0..100}; do
    sleep .1
    n=$(ls /run/udev/links/ | grep -c by-diskseq || :)
    (( n <= NUM_DISKSEQ + 1 ))
done

systemctl stop test-diskseq.service || :

udevadm settle --timeout=30

# Check if the lock directory exists, but no lock file exists in it.
[[ -d /run/udev/links.lock/ ]]
[[ "$(ls /run/udev/links.lock/ | wc -l)" == 0 ]]

exit 0