1#!/usr/bin/env bash 2# SPDX-License-Identifier: LGPL-2.1-or-later 3set -ex 4set -o pipefail 5 6mkdir -p /run/udev/rules.d/ 7 8rm -f /run/udev/rules.d/50-testsuite.rules 9udevadm control --reload 10udevadm trigger --settle /dev/sda 11 12while : ; do 13 ( 14 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service 15 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service 16 systemctl show -p WantedBy foobar.service | grep -q -v sda 17 systemctl show -p WantedBy waldo.service | grep -q -v sda 18 ) && break 19 20 sleep .5 21done 22 23cat >/run/udev/rules.d/50-testsuite.rules <<EOF 24SUBSYSTEM=="block", KERNEL=="sda", OPTIONS="log_level=debug" 25ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service" 26EOF 27udevadm control --reload 28udevadm trigger --settle /dev/sda 29 30while : ; do 31 ( 32 udevadm info /dev/sda | grep -q SYSTEMD_WANTS=foobar.service 33 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service 34 systemctl show -p WantedBy foobar.service | grep -q sda 35 systemctl show -p WantedBy waldo.service | grep -q -v sda 36 ) && break 37 38 sleep .5 39done 40 41cat >/run/udev/rules.d/50-testsuite.rules <<EOF 42SUBSYSTEM=="block", KERNEL=="sda", OPTIONS="log_level=debug" 43ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service" 44EOF 45udevadm control --reload 46udevadm trigger --settle /dev/sda 47 48while : ; do 49 ( 50 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service 51 udevadm info /dev/sda | grep -q SYSTEMD_WANTS=waldo.service 52 systemctl show -p WantedBy foobar.service | grep -q -v sda 53 systemctl show -p WantedBy waldo.service | grep -q sda 54 ) && break 55 56 sleep .5 57done 58 59rm /run/udev/rules.d/50-testsuite.rules 60 61udevadm control --reload 62udevadm trigger --settle /dev/sda 63 64while : ; do 65 ( 66 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service 67 udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service 68 systemctl show -p WantedBy foobar.service | grep -q -v sda 69 systemctl show -p WantedBy waldo.service | grep -q -v sda 70 ) && break 71 72 sleep .5 73done 74 75exit 0 76