#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -eux set -o pipefail # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh teardown_test_dependencies() ( set +eux if mountpoint /tmp/deptest; then umount /tmp/deptest fi if [[ -n "${LOOP}" ]]; then losetup -d "${LOOP}" || : fi if [[ -n "${LOOP_0}" ]]; then losetup -d "${LOOP_0}" || : fi if [[ -n "${LOOP_1}" ]]; then losetup -d "${LOOP_1}" || : fi rm -f /tmp/TEST-60-MOUNT-RATELIMIT-dependencies-0.img rm -f /tmp/TEST-60-MOUNT-RATELIMIT-dependencies-1.img rm -f /run/systemd/system/tmp-deptest.mount systemctl daemon-reload return 0 ) setup_loop() { truncate -s 30m "/tmp/TEST-60-MOUNT-RATELIMIT-dependencies-${1?}.img" sfdisk --wipe=always "/tmp/TEST-60-MOUNT-RATELIMIT-dependencies-${1?}.img" </run/systemd/system/tmp-deptest.mount </run/systemd/system/"$unit" <&2 "Test mount \"$unit\" unit isn't mounted" return 1 } mountpoint -q "$tmpdir" trap 'systemctl stop $unit' RETURN # Trigger the mount ratelimiting cd "$(mktemp -d)" mkdir foo for _ in {1..50}; do mount --bind foo foo umount foo done # Unmount the test mount and start it immediately again via systemd umount "$tmpdir" systemctl start "$unit" # Make sure it is seen as mounted by systemd and it actually is mounted [[ "$(systemctl show --property SubState --value "$unit")" = "mounted" ]] || { echo >&2 "Test mount \"$unit\" unit isn't in \"mounted\" state" return 1 } mountpoint -q "$tmpdir" || { echo >&2 "Test mount \"$unit\" is in \"mounted\" state, actually is not mounted" return 1 } } testcase_issue_23796() { # test for reexecuting with background mount job local mount_path mount_mytmpfs since mount_path="$(command -v mount 2>/dev/null)" mount_mytmpfs="${mount_path/\/bin/\/sbin}.mytmpfs" cat >"$mount_mytmpfs" </run/systemd/system/tmp-hoge.mount </run/systemd/journald.conf.d/99-ratelimit.conf <