#!/bin/bash set -ex set -o pipefail # tests for udev watch function check_validity() { local f ID_OR_HANDLE for f in /run/udev/watch/*; do ID_OR_HANDLE=$(readlink $f) test -L /run/udev/watch/${ID_OR_HANDLE} test $(readlink /run/udev/watch/${ID_OR_HANDLE}) = $(basename $f) done } function check() { local i j for ((i=0;i<2;i++)); do systemctl restart systemd-udevd.service udevadm control --ping udevadm settle sleep 1 check_validity for ((j=0;j<2;j++)); do udevadm trigger -w --action add --subsystem-match=block udevadm settle sleep 1 check_validity done for ((j=0;j<2;j++)); do udevadm trigger -w --action change --subsystem-match=block udevadm settle sleep 1 check_validity done done } mkdir -p /run/udev/rules.d/ cat >/run/udev/rules.d/00-debug.rules </run/udev/rules.d/50-testsuite.rules </run/udev/rules.d/50-testsuite.rules <